Shaky Crabs

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Re: Shaky Crabs

Postby Julio Jerez » Sun Nov 20, 2022 11:12 pm

ok I added a debug function to class ndShapeInstance
you can use like this:

Code: Select all
ndShapeInstance shape(new ndShapeCylinder(blockBoxSize.m_x, blockBoxSize.m_y, blockBoxSize.m_z));
shape.SavePLY("myPathName.ply");


them you can check how the mesh looks like.
if you can't load ply in yout app, you can download it for free.
https://www.meshlab.net/

I like that tool for debug because, it can handle many kinds of polygons.
for use the polygon are convex, so it is easy, but they are still convex faces not just tringle,
so the tool shows the exact topology of the collision shape.

let us see what is the engine producing, to determine of it is what is causing that crackling.

I just test with a cylinder, because I know they generate generic polygons and the mesh should look like this.
Untitled.png
Untitled.png (27.69 KiB) Viewed 19998 times
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Shaky Crabs

Postby Julio Jerez » Sun Nov 20, 2022 11:25 pm

in this video.
https://www.youtube.com/watch?v=RfHeTWn_S6c

in the first mesh the one coming from the collision shapes?
if so, I like to see the PLY, just to make sure that the face are not triangulated.

there is one parameter that can simply the mesh, in thsi function
ndShapeConvexHull(ndInt32 count, ndInt32 strideInBytes, ndFloat32 tolerance, const ndFloat32* const vertexArray);

are you setting tolerance 0?
if you set it so a no zero positive value. is will cut all the tine faces.
In fact the low level convex hull routing has a constroctor that you can set the max hull vertex, which generate a greatly simply shape and still quite accuarate.

I believe I exposed in 3.14 but neve di in 4.00
I will add that secund constructor, which I think is probably more intuitive

but let use do the first thing first, let us see how the mesh polygons like in polygons.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Shaky Crabs

Postby Bird » Mon Nov 21, 2022 8:02 am

Here's the crab convex hull saved using shapeInst.SavePLY ("E:/scratch/test.ply");

https://youtu.be/oo4CfbGnHvg

in the first mesh the one coming from the collision shapes?
if so, I like to see the PLY, just to make sure that the face are not triangulated.

No, the first mesh is the one I ran through the Retopology software and that made it triangulated.

I have the tolerance set to 1.0e-5
Code: Select all
 case CollisionShape::ConvexHull:
        shape = new ndShapeConvexHull (m->V.cols(), 3 * sizeof (float), 1.0e-5, m->V.data());
Bird
 
Posts: 623
Joined: Tue Nov 22, 2011 1:27 am

Re: Shaky Crabs

Postby Julio Jerez » Mon Nov 21, 2022 8:49 am

https://youtu.be/oo4CfbGnHvg

Oh yes that shape could be problematic with so many ill shape triangles.

You are passing 1e-5 fitolerance
The meaning of tge tolerance is the max distance that the furnace of tge hull will by from the sources of tha ideal hull of the point cloud.

If you units are meters the 1e-5 come out to be about 0.01 of a millimiter.
For all practical popuse that will be an ideal hull.

For most shapes that will be not problem, some shape with very smooth curvature it can generate too many sliver triangles.

Try passing 1e-3 fir tolerance a show the ply again, let us see if that reduces the mesh topology complexity.

Mean time I will add the secund contructor that will take a max vertex output.
That way it can be more intuitive to control.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Shaky Crabs

Postby Julio Jerez » Mon Nov 21, 2022 9:58 am

oh please ignore my above comment about tolerance.

I just added the Max Vertex output parameter to the convexhull shape.
this allow the app to control the complexity of the shape.
as an example I draw the different between a high-density barrel, and a reduced vertex count to 64 one. this is how the look like.

Untitled.png
Untitled.png (35.32 KiB) Viewed 19977 times


please sync and try to make the convex shape for that mesh setting the last parameters
Code: Select all
ndShapeConvexHull(ndInt32 count, ndInt32 strideInBytes, ndFloat32 tolerance, const ndFloat32* const vertexArray, ndInt32 maxPointsOut = 0x7fffffff);


try something like half 128 or 64, you can just experiment and see the visual result.
let us see how this works.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Shaky Crabs

Postby Bird » Mon Nov 21, 2022 12:15 pm

Here's the crab convex hull at different max vertices.

With max vertices set to 32, I still had to crank up solver passes to 16 and substeps to 8 to get this result

https://youtu.be/FHSRRpoDorM

max_vertices.jpg
max_vertices.jpg (85.73 KiB) Viewed 19969 times
Bird
 
Posts: 623
Joined: Tue Nov 22, 2011 1:27 am

Re: Shaky Crabs

Postby Julio Jerez » Mon Nov 21, 2022 2:48 pm

ok there seems to be some more fundamental problem
I suspect that the contact discriminator is responsible.

let use take a step back.

in the engine there are these tow functions.
Code: Select all
   
bool LoadScene(const char* const path);
void SaveScene(const char* const path);


they tend to break as the engine gets develops.
I just when over to make sure they can save and load a scene with collision like yours.

if in you application you insert a lone like
world->LoadScene("somePathName.nd");

there you can run the sandbox, and go to the file menu, click

-new
-load

them find the scene and load it this is to see if it works as you set it up..

them if it loads in the sandbox, please place in you google drive to that I can check it out.
this seem a deeper bug with contact generation discrimination.

try the dense convex hull,
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Shaky Crabs

Postby Bird » Mon Nov 21, 2022 8:47 pm

Okay, here's the link on my google drive. I might have to give you permissions again.
https://drive.google.com/file/d/1vjKw6v ... sp=sharing

In my scene I have the static ground mesh scaled by 2.0. But it looks like that the scale wasn't applied when the scene was saved
Bird
 
Posts: 623
Joined: Tue Nov 22, 2011 1:27 am

Re: Shaky Crabs

Postby Bird » Mon Nov 21, 2022 8:56 pm

crab_assert.jpg
crab_assert.jpg (211.31 KiB) Viewed 19954 times


I let it run for a while in debug mode and it eventually hit this assert
Bird
 
Posts: 623
Joined: Tue Nov 22, 2011 1:27 am

Re: Shaky Crabs

Postby Julio Jerez » Mon Nov 21, 2022 11:00 pm

sent request access.
also, you forgot to post the line of the assert
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Shaky Crabs

Postby Bird » Tue Nov 22, 2022 3:35 am

okay, I gave permission. The assert info is in the screen grab on the far right side
Bird
 
Posts: 623
Joined: Tue Nov 22, 2011 1:27 am

Re: Shaky Crabs

Postby Julio Jerez » Tue Nov 22, 2022 7:53 am

ok, I have it. and I see few problems.

first the scale is there, but somehow the scene looks very small. That could be a different bug.

this is how the scene looks like
Untitled.png
Untitled.png (655.93 KiB) Viewed 19931 times


it is only generating few patches of and the dynamic bodies are falling through the Crasks.
That's what the assert is showing.
I have to add a test dem showing how to capture run away objects.
I will add that this weekend.

there could be problems on the save/load routine, so let usnot o worry about that for now.

for what I can see the problem seems to be with the static mesh. I it is a hight resolution one.
And maybe it is exposing a problem we had not had before.
That test scene could be used as a test case for dealing with that kind of cituations.
On top you are using scale which show just work. But there are few point to check.
But, for that, we are going to have to make a more direct approach by recreating the scene in the sandbox.
there seem to more than one spot where something can go wrong. And with the scene it is easier to set reproducible error for debugging.

can you export the two meshes as a fbx file (the ground and the crab)
the post the script you use to make the scene.

I can modify for the demo static mesh, to recreate the scene and see what is going on.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Shaky Crabs

Postby Julio Jerez » Tue Nov 22, 2022 1:35 pm

ah, ok I believe I think now know what the bug is.
I am going to call inflation generated by legacy code.

it is this function, which is a legacy form almot 25 years.
Code: Select all
ndInt32 ndContactSolver::ConvexToStaticMeshContactsDiscrete()
{
...
...
   ndInt32 count = 0;
   ndPolygonMeshDesc data(*this, false);
   ndShapeStaticMesh* const polysoup = m_instance1.GetShape()->GetAsShapeStaticMesh();
   polysoup->GetCollidingFaces(&data);
   if (data.m_faceCount)
   {
      count = CalculatePolySoupToHullContactsDescrete(data);
   }



basically, in the old days, collision mesh where low res.
so i made sense to just collect the faces in a buffer and process them afterward.

in the very early days the buffer was about 64 vertex and faces, and over the year I have been increasing it. these day it is set to

    #define D_MAX_COLLIDING_FACES 512
    #define D_MAX_COLLIDING_INDICES (D_MAX_COLLIDING_FACES * (4 * 2 + 3))

but that can not scale indefintilly.
so what is happening is the when ether the vertex or the index counter reach the limit, the function just return with that sub set of faces.

in you test case, that set ins probably very small, and increasing the size is not an option.

It is time to fix that for good.
so what I have to do is to change the method so that the face are process as they are been generated.

this will take probably a day for work, and I will start tonight.

but it will be good if you can provide the tow sample of those meshes in FBX or any other format for testing.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Shaky Crabs

Postby Bird » Tue Nov 22, 2022 2:34 pm

Both the crab and the landscape mesh are in GLTF format and don't have a FBX version to download. I have LightWave and it can export FBX so I might be able to make a LW plugin that imports the GLTF geometry and then save it out as FBX. Might be a day or 2 though
Bird
 
Posts: 623
Joined: Tue Nov 22, 2011 1:27 am

Re: Shaky Crabs

Postby Julio Jerez » Tue Nov 22, 2022 2:55 pm

Do not make plugin, you can try loading it 3dpaint.

Them 3d paint can export fbx files.
3d paint is thev3d version of paint in windows.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

PreviousNext

Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 18 guests