mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +03:00
0030076: Visualization, TKV3d - API to update certain vertex attribute(s) without recomputing a presentation
Graphic3d_Buffer can be now optionally initialized as non-interleaved array of vertex attributes and provides an interface to invalidate buffer sub-range tracked by OpenGl_PrimitiveArray.
This commit is contained in:
@@ -157,10 +157,11 @@ private:
|
||||
// =======================================================================
|
||||
Select3D_SensitivePrimitiveArray::Select3D_SensitivePrimitiveArray (const Handle(SelectBasics_EntityOwner)& theOwnerId)
|
||||
: Select3D_SensitiveSet (theOwnerId),
|
||||
myPosData (NULL),
|
||||
myPosStride (Standard_Size(-1)),
|
||||
myPrimType (Graphic3d_TOPA_UNDEFINED),
|
||||
myIndexLower (0),
|
||||
myIndexUpper (0),
|
||||
myPosOffset (Standard_Size(-1)),
|
||||
myPatchSizeMax (1),
|
||||
myPatchDistance (ShortRealLast()),
|
||||
myIs3d (false),
|
||||
@@ -243,7 +244,8 @@ bool Select3D_SensitivePrimitiveArray::InitTriangulation (const Handle(Graphic3d
|
||||
myIndices.Nullify();
|
||||
myIndexLower = 0;
|
||||
myIndexUpper = 0;
|
||||
myPosOffset = Standard_Size(-1);
|
||||
myPosData = NULL;
|
||||
myPosStride = Standard_Size(-1);
|
||||
myBvhIndices.release();
|
||||
myIs3d = false;
|
||||
myInitLocation = theInitLoc;
|
||||
@@ -254,27 +256,19 @@ bool Select3D_SensitivePrimitiveArray::InitTriangulation (const Handle(Graphic3d
|
||||
return false;
|
||||
}
|
||||
|
||||
for (Standard_Integer anAttribIter = 0; anAttribIter < theVerts->NbAttributes; ++anAttribIter)
|
||||
Standard_Integer aPosAttribIndex = 0;
|
||||
myPosData = theVerts->AttributeData (Graphic3d_TOA_POS, aPosAttribIndex, myPosStride);
|
||||
if (myPosData == NULL)
|
||||
{
|
||||
const Graphic3d_Attribute& anAttrib = theVerts->Attribute (anAttribIter);
|
||||
if (anAttrib.Id == Graphic3d_TOA_POS)
|
||||
{
|
||||
if (anAttrib.DataType == Graphic3d_TOD_VEC3
|
||||
|| anAttrib.DataType == Graphic3d_TOD_VEC4)
|
||||
{
|
||||
myIs3d = true;
|
||||
}
|
||||
else if (anAttrib.DataType != Graphic3d_TOD_VEC2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
myPosOffset = theVerts->AttributeOffset (anAttribIter);
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (myPosOffset == Standard_Size(-1))
|
||||
|
||||
const Graphic3d_Attribute& anAttrib = theVerts->Attribute (aPosAttribIndex);
|
||||
myIs3d = anAttrib.DataType == Graphic3d_TOD_VEC3
|
||||
|| anAttrib.DataType == Graphic3d_TOD_VEC4;
|
||||
if (!myIs3d && anAttrib.DataType != Graphic3d_TOD_VEC2)
|
||||
{
|
||||
myPosData = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -422,7 +416,8 @@ bool Select3D_SensitivePrimitiveArray::InitPoints (const Handle(Graphic3d_Buffer
|
||||
myIndices.Nullify();
|
||||
myIndexLower = 0;
|
||||
myIndexUpper = 0;
|
||||
myPosOffset = Standard_Size(-1);
|
||||
myPosData = NULL;
|
||||
myPosStride = Standard_Size(-1);
|
||||
myBvhIndices.release();
|
||||
myIs3d = false;
|
||||
myInitLocation = theInitLoc;
|
||||
@@ -432,27 +427,19 @@ bool Select3D_SensitivePrimitiveArray::InitPoints (const Handle(Graphic3d_Buffer
|
||||
return false;
|
||||
}
|
||||
|
||||
for (Standard_Integer anAttribIter = 0; anAttribIter < theVerts->NbAttributes; ++anAttribIter)
|
||||
Standard_Integer aPosAttribIndex = 0;
|
||||
myPosData = theVerts->AttributeData (Graphic3d_TOA_POS, aPosAttribIndex, myPosStride);
|
||||
if (myPosData == NULL)
|
||||
{
|
||||
const Graphic3d_Attribute& anAttrib = theVerts->Attribute (anAttribIter);
|
||||
if (anAttrib.Id == Graphic3d_TOA_POS)
|
||||
{
|
||||
if (anAttrib.DataType == Graphic3d_TOD_VEC3
|
||||
|| anAttrib.DataType == Graphic3d_TOD_VEC4)
|
||||
{
|
||||
myIs3d = true;
|
||||
}
|
||||
else if (anAttrib.DataType != Graphic3d_TOD_VEC2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
myPosOffset = theVerts->AttributeOffset (anAttribIter);
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (myPosOffset == Standard_Size(-1))
|
||||
|
||||
const Graphic3d_Attribute& anAttrib = theVerts->Attribute (aPosAttribIndex);
|
||||
myIs3d = anAttrib.DataType == Graphic3d_TOD_VEC3
|
||||
|| anAttrib.DataType == Graphic3d_TOD_VEC4;
|
||||
if (!myIs3d && anAttrib.DataType != Graphic3d_TOD_VEC2)
|
||||
{
|
||||
myPosData = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -268,13 +268,13 @@ protected:
|
||||
//! Auxiliary getter.
|
||||
const Graphic3d_Vec3& getPosVec3 (const Standard_Integer theIndex) const
|
||||
{
|
||||
return *reinterpret_cast<const Graphic3d_Vec3* >(myVerts->value (theIndex) + myPosOffset);
|
||||
return *reinterpret_cast<const Graphic3d_Vec3* >(myPosData + myPosStride * theIndex);
|
||||
}
|
||||
|
||||
//! Auxiliary getter.
|
||||
const Graphic3d_Vec2& getPosVec2 (const Standard_Integer theIndex) const
|
||||
{
|
||||
return *reinterpret_cast<const Graphic3d_Vec2* >(myVerts->value (theIndex) + myPosOffset);
|
||||
return *reinterpret_cast<const Graphic3d_Vec2* >(myPosData + myPosStride * theIndex);
|
||||
}
|
||||
|
||||
//! Checks whether the element with index theIdx overlaps the current selecting volume
|
||||
@@ -303,10 +303,11 @@ private:
|
||||
|
||||
Handle(Graphic3d_Buffer) myVerts; //!< source data - nodes position
|
||||
Handle(Graphic3d_IndexBuffer) myIndices; //!< source data - primitive indexes
|
||||
const Standard_Byte* myPosData; //!< position vertex attribute data
|
||||
Standard_Size myPosStride; //!< position vertex attribute stride in bytes
|
||||
Graphic3d_TypeOfPrimitiveArray myPrimType; //!< primitives type
|
||||
Standard_Integer myIndexLower; //!< index range - first index in myIndices (inclusive)
|
||||
Standard_Integer myIndexUpper; //!< index range - last index in myIndices (inclusive)
|
||||
Standard_Size myPosOffset; //!< offset to the position vertex attribute
|
||||
Standard_Integer myPatchSizeMax; //!< patch size limit (1 by default)
|
||||
float myPatchDistance; //!< distance between elements in patch
|
||||
bool myIs3d; //!< flag indicating that position attribute has 3 components
|
||||
|
Reference in New Issue
Block a user