diff --git a/newton-4.00/applications/toolsAndWrapers/newtonUnreal/newton/Source/ThirdParty/newtonLibrary/Public/dCollision/ndShapeCompound.cpp b/newton-4.00/applications/toolsAndWrapers/newtonUnreal/newton/Source/ThirdParty/newtonLibrary/Public/dCollision/ndShapeCompound.cpp index 23ccdff15..b59fbee05 100644 --- a/newton-4.00/applications/toolsAndWrapers/newtonUnreal/newton/Source/ThirdParty/newtonLibrary/Public/dCollision/ndShapeCompound.cpp +++ b/newton-4.00/applications/toolsAndWrapers/newtonUnreal/newton/Source/ThirdParty/newtonLibrary/Public/dCollision/ndShapeCompound.cpp @@ -455,8 +455,14 @@ void ndShapeCompound::DebugShape(const ndMatrix& matrix, ndShapeDebugNotify& deb ndFloat32 ndShapeCompound::GetVolume() const { - ndAssert(0); - return ndFloat32(0.0f); + ndFloat32 volume = ndFloat32 (0.0f); + ndTreeArray::Iterator iter(m_array); + for (iter.Begin(); iter; iter++) + { + const ndShapeInstance* const collision = iter.GetNode()->GetInfo()->GetShape(); + volume += collision->GetVolume(); + } + return volume; } ndFloat32 ndShapeCompound::GetBoxMinRadius() const diff --git a/newton-4.00/applications/toolsAndWrapers/newtonUnreal/newton/Source/newton/Private/NewtonCollisionConvexApproximate.cpp b/newton-4.00/applications/toolsAndWrapers/newtonUnreal/newton/Source/newton/Private/NewtonCollisionConvexApproximate.cpp index 994edfb51..478ca9fcc 100644 --- a/newton-4.00/applications/toolsAndWrapers/newtonUnreal/newton/Source/newton/Private/NewtonCollisionConvexApproximate.cpp +++ b/newton-4.00/applications/toolsAndWrapers/newtonUnreal/newton/Source/newton/Private/NewtonCollisionConvexApproximate.cpp @@ -260,26 +260,28 @@ long long UNewtonCollisionConvexApproximate::CalculateStaticMeshHash() const const UStaticMesh* const staticMesh = staticComponent->GetStaticMesh().Get(); check(staticMesh); const FStaticMeshRenderData* const renderData = staticMesh->GetRenderData(); - check(renderData); - const FStaticMeshLODResourcesArray& renderResource = renderData->LODResources; + if (renderData) + { + const FStaticMeshLODResourcesArray& renderResource = renderData->LODResources; - //const FVector uScale(GetComponentTransform().GetScale3D()); - //const ndVector scale(ndFloat32(uScale.X), ndFloat32(uScale.Y), ndFloat32(uScale.Z), ndFloat32(0.0f)); - //const ndVector bakedScale(scale.Scale(UNREAL_INV_UNIT_SYSTEM)); + //const FVector uScale(GetComponentTransform().GetScale3D()); + //const ndVector scale(ndFloat32(uScale.X), ndFloat32(uScale.Y), ndFloat32(uScale.Z), ndFloat32(0.0f)); + //const ndVector bakedScale(scale.Scale(UNREAL_INV_UNIT_SYSTEM)); - const FStaticMeshLODResources& renderLOD = renderResource[0]; - const FStaticMeshVertexBuffers& staticMeshVertexBuffer = renderLOD.VertexBuffers;; - const FPositionVertexBuffer& positBuffer = staticMeshVertexBuffer.PositionVertexBuffer; - for (ndInt32 i = 0; i < ndInt32(positBuffer.GetNumVertices()); ++i) - { - const FVector3f p(positBuffer.VertexPosition(i)); - hash = ndCRC64(&p, sizeof(FVector3f), hash); - } - const FRawStaticIndexBuffer& indexBuffer = renderLOD.IndexBuffer; - for (ndInt32 i = 0; i < ndInt32(indexBuffer.GetNumIndices()); i += 3) - { - ndInt32 j = indexBuffer.GetIndex(i); - hash = ndCRC64(&j, sizeof(ndInt32), hash); + const FStaticMeshLODResources& renderLOD = renderResource[0]; + const FStaticMeshVertexBuffers& staticMeshVertexBuffer = renderLOD.VertexBuffers;; + const FPositionVertexBuffer& positBuffer = staticMeshVertexBuffer.PositionVertexBuffer; + for (ndInt32 i = 0; i < ndInt32(positBuffer.GetNumVertices()); ++i) + { + const FVector3f p(positBuffer.VertexPosition(i)); + hash = ndCRC64(&p, sizeof(FVector3f), hash); + } + const FRawStaticIndexBuffer& indexBuffer = renderLOD.IndexBuffer; + for (ndInt32 i = 0; i < ndInt32(indexBuffer.GetNumIndices()); i += 3) + { + ndInt32 j = indexBuffer.GetIndex(i); + hash = ndCRC64(&j, sizeof(ndInt32), hash); + } } } return hash; diff --git a/newton-4.00/sdk/dCollision/ndShapeCompound.cpp b/newton-4.00/sdk/dCollision/ndShapeCompound.cpp index 23ccdff15..3fedc8e95 100644 --- a/newton-4.00/sdk/dCollision/ndShapeCompound.cpp +++ b/newton-4.00/sdk/dCollision/ndShapeCompound.cpp @@ -455,8 +455,14 @@ void ndShapeCompound::DebugShape(const ndMatrix& matrix, ndShapeDebugNotify& deb ndFloat32 ndShapeCompound::GetVolume() const { - ndAssert(0); - return ndFloat32(0.0f); + ndFloat32 volume = ndFloat32(0.0f); + ndTreeArray::Iterator iter(m_array); + for (iter.Begin(); iter; iter++) + { + const ndShapeInstance* const collision = iter.GetNode()->GetInfo()->GetShape(); + volume += collision->GetVolume(); + } + return volume; } ndFloat32 ndShapeCompound::GetBoxMinRadius() const