Skip to content

Commit

Permalink
more work on plugin (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
JulioJerez committed Oct 22, 2024
1 parent 545fbb5 commit 3293eeb
Show file tree
Hide file tree
Showing 12 changed files with 487 additions and 221 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

FnewtonModule* FnewtonModule::m_pluginSingleton;

int FnewtonModule::m_currentVersion = FnewtonModule::m_firstVersion;
int FnewtonModule::m_currentVersion = ndPluginVersion::m_firstVersion;
const FGuid FnewtonModule::m_guiID(0x2EabFDBD, 0x0105C4D10, 0x8876F38F, 0x2516A5DA);
FCustomVersionRegistration FnewtonModule::m_guidRegistration(FnewtonModule::m_guiID, FnewtonModule::m_currentVersion, TEXT("FnewtonModule"));

Expand Down Expand Up @@ -93,7 +93,7 @@ class FnewtonModule::ResourceCache
return m_visualMeshCache.Find(hash);
}

TSharedPtr<ndConvexHullPoints> FindConvexHull(long long hash) const
TSharedPtr<ndConvexHullSet> FindConvexHull(long long hash) const
{
return m_convexVhacdCache.Find(hash);
}
Expand All @@ -110,7 +110,7 @@ class FnewtonModule::ResourceCache
m_shapeCache.Insert(shape, hash);
}

void AddConvexHull(const TSharedPtr<ndConvexHullPoints>& hull, long long hash)
void AddConvexHull(const TSharedPtr<ndConvexHullSet>& hull, long long hash)
{
m_convexVhacdCache.Insert(hull, hash);
}
Expand All @@ -134,7 +134,7 @@ class FnewtonModule::ResourceCache
}

ndTree<ndShape*, long long> m_shapeCache;
Cache<ndConvexHullPoints> m_convexVhacdCache;
Cache<ndConvexHullSet> m_convexVhacdCache;
Cache<UE::Geometry::FDynamicMesh3> m_visualMeshCache;
};

Expand Down Expand Up @@ -258,12 +258,12 @@ void FnewtonModule::AddShape(ndShape* shape, long long hash)
m_resourceCache->AddShape(shape, hash);
}

TSharedPtr<ndConvexHullPoints> FnewtonModule::FindConvexHull(long long hash) const
TSharedPtr<ndConvexHullSet> FnewtonModule::FindConvexHull(long long hash) const
{
return m_resourceCache->FindConvexHull(hash);
}

void FnewtonModule::AddConvexHull(const TSharedPtr<ndConvexHullPoints>& hull, long long hash)
void FnewtonModule::AddConvexHull(const TSharedPtr<ndConvexHullSet>& hull, long long hash)
{
m_resourceCache->AddConvexHull(hull, hash);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class UNewtonCollision::PolygonizeMesh : public ndShapeDebugNotify

ndArray<ndInt32> triangles;
ndTriangulatePolygon(&m_points[baseIndex], vertexCount, triangles);
//check((vertexCount - 2) == ndInt32 (triangles.GetCount() / 3));
check((vertexCount - 2) == ndInt32 (triangles.GetCount() / 3));

for (ndInt32 i = 0; i < ndInt32(triangles.GetCount()); i += 3)
{
Expand Down Expand Up @@ -92,12 +92,13 @@ UNewtonCollision::UNewtonCollision()
m_visualMesh = TSharedPtr<UE::Geometry::FDynamicMesh3>(nullptr);

ConstructorHelpers::FObjectFinder<UMaterial> TexObj(TEXT("/newton/NewtonTransparentMaterial"));
TObjectPtr<UMaterial> debugMaterial(Cast<UMaterial>(TexObj.Object));
debugMaterial->OpacityMaskClipValue = 0.0f;
m_debugMaterial = Cast<UMaterial>(TexObj.Object);
m_debugMaterial->OpacityMaskClipValue = 0.0f;

UMaterialInstanceDynamic* const debugMaterialInstance = UMaterialInstanceDynamic::Create(debugMaterial, nullptr);
debugMaterialInstance->OpacityMaskClipValue = 0.1f;
SetMaterial(0, debugMaterialInstance);
//UMaterialInstanceDynamic* const debugMaterialInstance = UMaterialInstanceDynamic::Create(m_debugMaterial, nullptr);
//debugMaterialInstance->OpacityMaskClipValue = 0.0f;
//SetMaterial(0, debugMaterialInstance);
SetMaterial(0, m_debugMaterial);
}

void UNewtonCollision::OnRegister()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class UNewtonCollision : public UDynamicMeshComponent
//public:
long long m_hash;
ndShape* m_shape;
TObjectPtr<UMaterial> m_debugMaterial;
TSharedPtr<UE::Geometry::FDynamicMesh3> m_visualMesh;
bool m_propertyChanged;
bool m_showDebug;
Expand Down
Loading

0 comments on commit 3293eeb

Please sign in to comment.