dgMeshEffect1 Assert [SOLVED]

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

dgMeshEffect1 Assert [SOLVED]

Postby MeltingPlastic » Wed Aug 08, 2018 9:33 pm

With the latest code (8/8/2018) I am getting an Assert in dgMeshEffect::PackPoints (line 2075). I have attached a small application compiled in debug mode. In the demo I form 1 compound from convex hulls using NewtonCreateCompoundCollisionFromMesh.

Here is the application:
https://drive.google.com/open?id=1YayzYh8jqRT54G7vlSxd6EQVFUczCR47

It crashes right away

The mesh should look like this (sorry for the large picture) This was from a previous build with an earlier version of newton :
Image

In Release mode it does not crash but the convex hull does not seem to be created either. This used to work ok in a previous newton build but of course I could be doing something wrong..
Last edited by MeltingPlastic on Sat Aug 11, 2018 10:47 pm, edited 1 time in total.
MeltingPlastic
 
Posts: 237
Joined: Fri Feb 07, 2014 11:30 pm

Re: dgMeshEffect1 Assert

Postby MeltingPlastic » Thu Aug 09, 2018 3:26 pm

To form the newton mesh I am using the following pattern adding faces triangle by triangle. The same mesh works using NewtonCreateConvexHullFromMesh just having trouble with NewtonCreateCompoundCollisionFromMesh.

Code: Select all
            newtonMesh_ = physicsWorld_->GetCreateNewtonMesh(meshKey);
            NewtonMeshBeginBuild(newtonMesh_->mesh);

            for ( each triangle with vertices (v1,v2,v3) )
            {
                NewtonMeshBeginFace(newtonMesh_->mesh);
                NewtonMeshAddPoint(newtonMesh_->mesh, v1.x_, v1.y_, v1.z_);
                NewtonMeshAddPoint(newtonMesh_->mesh, v2.x_, v2.y_, v2.z_);
                NewtonMeshAddPoint(newtonMesh_->mesh, v3.x_, v3.y_, v3.z_);
                NewtonMeshEndFace(newtonMesh_->mesh);
            }

            NewtonMeshEndBuild(newtonMesh_->mesh);
MeltingPlastic
 
Posts: 237
Joined: Fri Feb 07, 2014 11:30 pm

Re: dgMeshEffect1 Assert

Postby Julio Jerez » Thu Aug 09, 2018 3:39 pm

Oh I forget that, I was debugging a dead lock that happen when the scene goes to rest, I think I fixed now,
I will check out this problem now.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: dgMeshEffect1 Assert

Postby Julio Jerez » Fri Aug 10, 2018 9:40 am

now that you can build the dll can you make the repro demo using dll, your demo link to a static library that I can't debug.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: dgMeshEffect1 Assert

Postby MeltingPlastic » Fri Aug 10, 2018 11:58 am

11_Physics.exe is only 444kb big - I didn't think it was statically linked to newton. I did make slight modifications to the newton cmake script - but nothing major - just changes on how the install portion of cmake works. I did a test and removed newton.dll from next to the program and then the program cant start as is expected with dlls.

https://github.com/TrevorCash/Urho3D/tree/master/Source/ThirdParty/newton-dynamics
MeltingPlastic
 
Posts: 237
Joined: Fri Feb 07, 2014 11:30 pm

Re: dgMeshEffect1 Assert

Postby Julio Jerez » Fri Aug 10, 2018 5:54 pm

maybe I missed it but I did not see any newton.dll, I only saw dNewton.dll
I check again tonight.

chances are that even if there is a newton.dll it will not work if some class has changed and there has been few changes, so to make sure it will work, just upload a new repro using the latest commit.
also tell me if you are building 32 or 64 bit
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: dgMeshEffect1 Assert

Postby MeltingPlastic » Fri Aug 10, 2018 7:06 pm

Sounds good - Thanks for your time. Here is a new build: https://drive.google.com/open?id=17x7xgz89iLAxe1sTBbUIaYHzzRKDa5ko.

It is built based off of this newton commit (Latest): https://github.com/MADEAPPS/newton-dynamics/commit/2ecd47f04360a271450543e16a663b6ee6672b18

It is 64bit Debug build.

It also has a demo for the ghosting bug I was seeing in the other thread.



The only changes to the newton repo are below (I have only changed cmake files and have not messed with build settings or source files) so all source should be the same in this fork I also have removed some other things like the premade projects folder etc:
https://github.com/MADEAPPS/newton-dynamics/compare/master...TrevorCash:Urho3D?diff=split&expand=1&name=Urho3D

specific commit on my fork: https://github.com/TrevorCash/newton-dynamics/commit/d96d09969a8ea3fdf507487001249d55fc826a58
MeltingPlastic
 
Posts: 237
Joined: Fri Feb 07, 2014 11:30 pm

Re: dgMeshEffect1 Assert

Postby Julio Jerez » Sat Aug 11, 2018 3:29 pm

ok I was looking at the first bug and I find some extrenge
in this sequence of calls, I see you are making a rigid body with a compound collision, is that right?

> newton.dll!dgCollisionCompound::dgCollisionCompound(dgWorld * const world) Line 474 C++
newton.dll!dgWorld::CreateCompound() Line 241 C++
newton.dll!NewtonCreateCompoundCollision(const NewtonWorld * const newtonWorld, int shapeID) Line 2441 C++
Urho3D.dll!Urho3D::NewtonRigidBody::reBuildBody() Line 197 C++
Urho3D.dll!Urho3D::NewtonRigidBody::reBuildBodyParent() Line 164 C++
Urho3D.dll!Urho3D::UrhoNewtonPhysicsWorld::HandleUpdate(Urho3D::StringHash eventType, Urho3D::HashMap<Urho3D::StringHash,Urho3D::Variant> & eventData) Line 208 C++
Urho3D.dll!Urho3D::EventHandlerImpl<Urho3D::UrhoNewtonPhysicsWorld>::Invoke(Urho3D::HashMap<Urho3D::StringHash,Urho3D::Variant> & eventData) Line 419 C++
Urho3D.dll!Urho3D::Object::OnEvent(Urho3D::Object * sender, Urho3D::StringHash eventType, Urho3D::HashMap<Urho3D::StringHash,Urho3D::Variant> & eventData) Line 126 C++
Urho3D.dll!Urho3D::Object::SendEvent(Urho3D::StringHash eventType, Urho3D::HashMap<Urho3D::StringHash,Urho3D::Variant> & eventData) Line 370 C++
Urho3D.dll!Urho3D::Engine::SendUpdateEvents() Line 738 C++
Urho3D.dll!Urho3D::Engine::Update() Line 725 C++
Urho3D.dll!Urho3D::Engine::FreeUpdate() Line 683 C++
Urho3D.dll!Urho3D::Application::Run() Line 94 C++
11_Physics.exe!RunApplication() Line 55 C++


if so, what I find weird is that you create the rigid body but you never add any child shape,
therefore when you set the mass of the body, the game crash because it never that a compound will have a zero inertia, whi si what the shape would be if does no have children

to take care fo that I add a check that is the collision shape does not has inertia value
the is set the mass to infinity, I added this check


Code: Select all
void dgBody::SetMassMatrix(dgFloat32 mass, const dgMatrix& inertia)
{
   dgFloat32 Ixx = inertia[0][0];
   dgFloat32 Iyy = inertia[1][1];
   dgFloat32 Izz = inertia[2][2];
   mass = dgAbs (mass);
   if (m_collision->IsType(dgCollision::dgCollisionMesh_RTTI) || m_collision->IsType(dgCollision::dgCollisionScene_RTTI)) {
      mass = DG_INFINITE_MASS * 2.0f;
   }

   if (m_collision->IsType(dgCollision::dgCollisionCompound_RTTI)) {
      const dgCollision* const childShape = m_collision->GetChildShape();
      if ((childShape->m_inertia.m_x < dgFloat32 (1.0e-5f)) || (childShape->m_inertia.m_y < dgFloat32 (1.0e-5f)) || (childShape->m_inertia.m_z < dgFloat32 (1.0e-5f))){
         mass = DG_INFINITE_MASS * 2.0f;
      }
   }



I change the assert to a Trace, and the game runs, but I am not sure hwo to see what is in the scene.
I saw the mushroom was suppose to be one of the two compound that I see.

Is there suppose to be a compound with no children shapes?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: dgMeshEffect1 Assert

Postby MeltingPlastic » Sat Aug 11, 2018 4:50 pm

The rigid body is supposed to have a collision shape added yes but the program has not reached that point yet before the crash. The first thing that happens is that a newton mesh is created and then finally a collision is formed afterward. The program literally crashes because this assert is thrown: https://drive.google.com/open?id=1fblZliOlGQi3SskERiOKhhdtsYOR0rm0

At the point where the crash is happening I have not actually created any rigid bodies or collisions yet. That comes next in the code. Here is the full stack:

    > newton.dll!dgMeshEffect::PackPoints(double tol) Line 2075 C++
    newton.dll!dgMeshEffect::EndBuild(double tol, bool fixTjoint) Line 2198 C++
    newton.dll!NewtonMeshEndBuild(const NewtonMesh * const mesh) Line 8024 C++
    Urho3D.dll!Urho3D::NewtonCollisionShape_Geometry::resolveOrCreateTriangleMesh() Line 491 C++
    Urho3D.dll!Urho3D::NewtonCollisionShape_ConvexHullCompound::createNewtonCollision() Line 555 C++
    Urho3D.dll!Urho3D::NewtonCollisionShape::reEvaluateCollision() Line 185 C++
    Urho3D.dll!Urho3D::NewtonRigidBody::reBuildBody() Line 210 C++
    Urho3D.dll!Urho3D::NewtonRigidBody::reBuildBodyParent() Line 164 C++
    Urho3D.dll!Urho3D::UrhoNewtonPhysicsWorld::HandleUpdate(Urho3D::StringHash eventType, Urho3D::HashMap<Urho3D::StringHash,Urho3D::Variant> & eventData) Line 208 C++
    Urho3D.dll!Urho3D::EventHandlerImpl<Urho3D::UrhoNewtonPhysicsWorld>::Invoke(Urho3D::HashMap<Urho3D::StringHash,Urho3D::Variant> & eventData) Line 419 C++
    Urho3D.dll!Urho3D::Object::OnEvent(Urho3D::Object * sender, Urho3D::StringHash eventType, Urho3D::HashMap<Urho3D::StringHash,Urho3D::Variant> & eventData) Line 126 C++
    Urho3D.dll!Urho3D::Object::SendEvent(Urho3D::StringHash eventType, Urho3D::HashMap<Urho3D::StringHash,Urho3D::Variant> & eventData) Line 370 C++
    Urho3D.dll!Urho3D::Engine::SendUpdateEvents() Line 738 C++
    Urho3D.dll!Urho3D::Engine::Update() Line 725 C++
    Urho3D.dll!Urho3D::Engine::FreeUpdate() Line 683 C++
    Urho3D.dll!Urho3D::Application::Run() Line 94 C++
    11_Physics.exe!RunApplication() Line 55 C++
    11_Physics.exe!main(int argc, char * * argv) Line 55 C++
    [External Code]

for some reason dgEdge* const face is null.

going a little deeper it returns null in dgPolyhedra lin 281:
https://drive.google.com/open?id=1t7sAnMNlLCm6OISoTuDZC0jnUE1xjwPj

I'm adding faces to the mesh manually face by face so I cant imagine how I would be feeding bad data or anything. (I have checked the data - that works fine)

If things are working you should be able to hold space and see what is in the first picture in this thread.

Posted new demo with the trace instead of the assert in the other thread.
MeltingPlastic
 
Posts: 237
Joined: Fri Feb 07, 2014 11:30 pm

Re: dgMeshEffect1 Assert

Postby Julio Jerez » Sat Aug 11, 2018 7:38 pm

It is not the assert that is making it crash, it is that after the assert you are creation a dynamics body with a compound collision that does not has faces or children shapes.
The assert is only saying that the shape has degenerated faces, that is triangles wit and area so small that that the normal will produce a dive by zero, of some oeth float error,
but that is not important for making convex hull since it only uses the mesh vertices.

you are making a proper compound but you are not using that compound as teh collsion shape when you create the body, you are using an empty one.
can you show me the source code you are using to create the scene?

this happen wit the the very first body you create.
Code: Select all
>   newton.dll!dgBody::SetMassMatrix(float mass, const dgMatrix & inertia) Line 470   C++
    newton.dll!dgWorld::InitBody(dgBody * const body, dgCollisionInstance * const collision, const dgMatrix & matrix) Line 453   C++
    newton.dll!dgWorld::CreateDynamicBody(dgCollisionInstance * const collision, const dgMatrix & matrix) Line 492   C++
    newton.dll!NewtonCreateDynamicBody(const NewtonWorld * const newtonWorld, const NewtonCollision * const collisionPtr, const float * const matrixPtr) Line 4318   C++
    Urho3D.dll!Urho3D::NewtonRigidBody::reBuildBody() Line 257   C++
    Urho3D.dll!Urho3D::NewtonRigidBody::reBuildBodyParent() Line 164   C++
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: dgMeshEffect1 Assert

Postby Julio Jerez » Sat Aug 11, 2018 7:43 pm

MeltingPlastic wrote:I'm adding faces to the mesh manually face by face so I cant imagine how I would be feeding bad data or anything. (I have checked the data - that works fine)
If things are working you should be able to hold space and see what is in the first picture in this thread.
Posted new demo with the trace instead of the assert in the other thread.


I do not see anythong because after the mesh is created, it seem you are using a diffrent collision to crate the rigid body.

can you show me the source that does this, there has to be a bug there?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: dgMeshEffect1 Assert

Postby Julio Jerez » Sat Aug 11, 2018 7:54 pm

you are definitely creating a rigid body that crate a compound collision andf use that as teh collsion shape. here is the code sequence

Code: Select all
>   newton.dll!dgCollisionCompound::dgCollisionCompound(dgWorld * const world) Line 474   C++
    newton.dll!dgWorld::CreateCompound() Line 241   C++
    newton.dll!NewtonCreateCompoundCollision(const NewtonWorld * const newtonWorld, int shapeID) Line 2441   C++
    Urho3D.dll!Urho3D::NewtonRigidBody::reBuildBody() Line 197   C++
    Urho3D.dll!Urho3D::NewtonRigidBody::reBuildBodyParent() Line 164   C++



the aft eteh bod is created you create a compound for mesh, but is not used, because the rigid body ready has a compound without children.

the bug is on the part of the code the create the bodies, some is not right there.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: dgMeshEffect1 Assert

Postby MeltingPlastic » Sat Aug 11, 2018 8:11 pm

Ah Yes Found it! It was a bug on my part due to over counting urho3d child components when forming the rigid body which in turn was making it so it would create a new instance of the collision and then add that as a sub collision to the compound. The demo is working now.

Although I am a little confused as to why it wasn't working. Here is a question, does NewtonCollisionCreateInstance create a new "deep copied" compound collision if it is given one?

I was previously calling NewtonCollisionCreateInstance to make a copy of the collision (which in this case was a compound) and then adding that compound as a sub collision of the final compound I was building using NewtonCompoundCollisionAddSubCollision.

Anyway it is happily falling to the ground now - there is some more work to be done until I'm really happy with how the system handles compounds in tandem with the scene hierarchy.
MeltingPlastic
 
Posts: 237
Joined: Fri Feb 07, 2014 11:30 pm

Re: dgMeshEffect1 Assert

Postby Julio Jerez » Sat Aug 11, 2018 8:22 pm

Oh nice, so you have is working now?

MeltingPlastic wrote:Although I am a little confused as to why it wasn't working. Here is a question, does NewtonCollisionCreateInstance create a new "deep copied" compound collision if it is given one?

yes is does, is will make a copy of every thing, the copy is only collsion instance data, the share date is ref counted.
but is simple that that, each time you crate a newton body, the collsion shape tha is assigned to the body is and a copy of the shape tha is passed in the argument.

anyway let me know if there are some other problems.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: dgMeshEffect1 Assert

Postby Julio Jerez » Sat Aug 11, 2018 8:27 pm

One more thing when you get that fixed, please test the ball demo,
this bug might be part of the reason for the malfunction.

Even if it does not fix it upload the demo, so that we do not deal with more than on bug at the same time.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Next

Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 8 guests

cron