A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by FSA » Mon Aug 26, 2013 1:34 pm
Puuh I'm glad to see that this forum is back online
I've got a problem with NewtonTreeCollision. When I call NewtonTreeCollisionEndBuild with "1" as second paramter it seems that newton doesn't optimze anymore. A flat plane with many pointless vertices belongs like it is. No optimation at all.
-

FSA
-
- Posts: 322
- Joined: Wed Dec 21, 2011 9:47 am
by Julio Jerez » Mon Aug 26, 2013 1:47 pm
yes it does. I have no changed that
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by FSA » Mon Aug 26, 2013 2:04 pm
So you will make an update for that?
-

FSA
-
- Posts: 322
- Joined: Wed Dec 21, 2011 9:47 am
by Julio Jerez » Mon Aug 26, 2013 2:27 pm
what I said is that so far I know the tree colliosn does optimize the collsion mesh.
what kind of mesh are we talking about here?
In the furture mesh I will remove that funtionality form the tree, and us ethe NewtpMesh instead.
the newtonMesh has far better algorithm, that remove T joints, and degenerated faces, that generate better job on comples meshes
but for now Tree collision still have teh Base functionality, and should work.
can you serialized the collision and load it in the sanbox demos? ther you can check if it is doin the job or not.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Julio Jerez » Thu Aug 29, 2013 5:02 pm
can I have a sampple in some fiel format, for me to test?
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by FSA » Fri Aug 30, 2013 10:25 am
In the archieve you can find the max file and the model as 3ds. And of course the serialised World.
- Attachments
-
Desktop.zip
- (55.17 KiB) Downloaded 190 times
-

FSA
-
- Posts: 322
- Joined: Wed Dec 21, 2011 9:47 am
by JoeJ » Fri Aug 30, 2013 10:45 am
I was curious and enabled subdividion on the mesh.
There you can see that it is not closed and there are duplicate vertices at the same positions - that's what i've expected.
I don't know if newton requires closed meshes, or if it allows to define a fuse-vertices-radius parameter.
- Attachments
-

- mesh.JPG (14.46 KiB) Viewed 4393 times
-

JoeJ
-
- Posts: 1489
- Joined: Tue Dec 21, 2010 6:18 pm
by Julio Jerez » Fri Aug 30, 2013 11:24 am
it look lie the max file is corrupted, It fail to load with Max 12.
but I was able to open the 3ds file.
I see it is a regular box texalated to a 10 x 10 x 10 subdivisions.
I will try to export and load it and see why is fail. that should be simplify to a simple 1 x 1 x 1 quads box, provide that the subdivision fall on the same plane.
Give a day until IO complete the general scale that I am adding the collision primitive, for fix the bug with scaling compound. and then I will review this.
The one thing I want to do the to remove the optimize collision tree al together from the collision primitive. and replace with the more powerful NewtonMesh.
The only thon that stops me is that the NewtonMesh use a Fact vertex format, so in can run out of memory on medium size collision, but later I will make the NewtonMesh uses Vertex semantic for vertex format
rather that Fix vertex.
Any way I will chek what is wron and fix it.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Julio Jerez » Fri Aug 30, 2013 11:34 am
I quickly load it in the sandbox and this is what I see

- optimizeBug.png (329.71 KiB) Viewed 4387 times
is that what you see?
It optimize the top and bottom faces, by fail very bad on the side faces, I have to see what is wrong there.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by FSA » Fri Aug 30, 2013 11:48 am
Max file is created with version 2013. No I don't see it like in your picture. In yours it looks like it is optimized. Strange. This is my code to build a tree collision:
- Code: Select all
PhysicBody* RigidBodyHandler::CreateLevelRigidBody(Model* CollisionModel, Matrix mTranslation, bool bOptimize)
{
HRESULT hr = S_OK;
PhysicCollision* collision;
Vector3 vArray[3];
PhysicBody* m_levelBody;
Vector3* vVertexArray = (Vector3*)CollisionModel->GetVertices();
int vertcount = CollisionModel->GetNumVertices();
DWORD* vIndexArray = CollisionModel->GetIndicies();
int indexcount = CollisionModel->GetNumIndices();
collision = NewtonCreateTreeCollision(m_pPhysicWorld, 0);
NewtonTreeCollisionBeginBuild(collision);
for(int i = 0; i < indexcount; i += 3)
{
WORD d1 = (WORD)vIndexArray[i];
WORD d2 = (WORD)vIndexArray[i+1];
WORD d3 = (WORD)vIndexArray[i+2];
vArray[0] = vVertexArray[d1];
vArray[1] = vVertexArray[d2];
vArray[2] = vVertexArray[d3];
Vector3 e0 = vArray[1] - vArray[0];
Vector3 e1 = vArray[2] - vArray[0];
NewtonTreeCollisionAddFace(collision, 3, (float*)vArray[0], sizeof(Vector3), i+1);
}
NewtonTreeCollisionEndBuild(collision, 1);
m_levelBody = CreateRigidBody(collision, 0.0f, mTranslation);
DestroyCollision(collision);
return m_levelBody;
}
PhysicCollision ist a typedef of NewtonCollision.
-

FSA
-
- Posts: 322
- Joined: Wed Dec 21, 2011 9:47 am
by Julio Jerez » Fri Aug 30, 2013 11:56 am
no mine is not optimized the way I was expecting either.
after a quick fix by commenting out the suspecting function, now it looks perfect.

- optimizeBug.png (173.56 KiB) Viewed 4383 times
It looks like I have a bug in one of my mesh optimization function, after I fox that it should be fine
I have to leave for work now, I fix that tomorrow.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by FSA » Fri Aug 30, 2013 12:05 pm
This is waht I would expect. But my mesh looks like in my two pictures above. No optimization at all (Red lines are the collision wireframe). Smoething wrong with my code?
-

FSA
-
- Posts: 322
- Joined: Wed Dec 21, 2011 9:47 am
by Julio Jerez » Fri Aug 30, 2013 1:14 pm
It may be a scaling problem, when a Load the mesh is very small.
let me fix the error first in the optimized first. see fi if goes away.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Julio Jerez » Sat Aug 31, 2013 11:37 am
ok that bug is fixed now, it should be perfect now, please sync and try again.
this was an important bug that was bogging me for a while and I kept postponing fixing it
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 4 guests