Pure virtual function call runtime error

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Pure virtual function call runtime error

Postby rvangaal » Mon Jun 08, 2009 1:18 pm

Hi,

I'm new to Newton; checking it out (I'm currently using ODE).
I've tried v1.53 - I had to revise my compiling scheme to /MT to get it the link, but I'm getting crashes in the NewtonUpdate() call. I can't compile the demos since I'm lacking glaux.lib.

So, I'm now trying v2.01. I get that to compile under Release (Debug gives link errors such as:
msvcrt.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)
)

Under Release, if I run it, I get an error: R6025, pure virtual function call.

Is there some kind of error reporting function that can help? Currently, debugging an app using Newton is a bit cumbersome for me.

Thanks for any tips.
Ruud
rvangaal
 
Posts: 61
Joined: Mon Jun 08, 2009 1:11 pm

Re: Pure virtual function call runtime error

Postby Julio Jerez » Mon Jun 08, 2009 1:38 pm

please use 2.01
viewtopic.php?f=9&t=4922
it is simpler, fewer bugs, and it is the one we are supporting.

are these linking error hapenning when yopu build the demos, or are they happening when you try to link yort own project.

are you trying the DLL,
if you try the DLL you do no have to deall with mt or md mode.
could you trey the DLL and them when you have it working do to the static link liberies?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Pure virtual function call runtime error

Postby rvangaal » Tue Jun 09, 2009 7:49 am

I have it working, but I don't trust it, since I do this:

ntGeom=NewtonCreateBox(RMGR->ntWorld,1.0f,1.0f,1.0f,0);
ntBody=NewtonCreateBody(RMGR->ntWorld,ntGeom);
NewtonReleaseCollision(RMGR->ntWorld,ntGeom);
ntGeom=0; // If not done, gives 'Pure virtual function call R2065' error?!

// Link back to our object
NewtonBodySetUserData(ntBody,this);
NewtonBodySetForceAndTorqueCallback(ntBody,cbSetForce);

If I leave out the 'ntGeom=0' line, it gives the pure function call error. I checked, but ntGeom isn't used anywhere else, except at destruction time.
Anyway, with the DLL it works; I tried the static libs which now also work in Release mode. In Debug (with static lib) I still get a few linking errors, seemingly to do with RTTI, which I have turned off, I think. Perhaps Newton uses typeinfo checking?

Thanks for the help!
rvangaal
 
Posts: 61
Joined: Mon Jun 08, 2009 1:11 pm

Re: Pure virtual function call runtime error

Postby Julio Jerez » Tue Jun 09, 2009 8:19 am

rvangaal wrote:I have it working, but I don't trust it, since I do this:
ntGeom=NewtonCreateBox(RMGR->ntWorld,1.0f,1.0f,1.0f,0);
ntBody=NewtonCreateBody(RMGR->ntWorld,ntGeom);
NewtonReleaseCollision(RMGR->ntWorld,ntGeom);

//it does not make sense that this make it work
ntGeom=0; // If not done, gives 'Pure virtual function call R2065' error?!


It does not make sense setting that setting that variable to zero or not makes the engine crash, unless you are calling Release of destroying the body more than once somewhere else.

you can check the number of Refecence count on ntGeom by calling GetInfo on nrGeom. Maybe it is going out of scope somewhere. I never have anyone with similar problems.

Code: Select all
 ntGeom=NewtonCreateBox(RMGR->ntWorld,1.0f,1.0f,1.0f,0);
  // ref shoul be 2 (on for creation and one for the world)
  NewtonCollisionGetInfo (const NewtonCollision* collision, NewtonCollisionInfoRecord* collisionInfo);

  ntBody=NewtonCreateBody(RMGR->ntWorld,ntGeom);
  // ref should be 3 (one more fo rteh body)
  NewtonCollisionGetInfo (const NewtonCollision* collision, NewtonCollisionInfoRecord* collisionInfo);

  NewtonReleaseCollision(RMGR->ntWorld,ntGeom);
  // ref should be 2 ( remove the inatce reference and ref sould be 2)
  NewtonCollisionGetInfo (const NewtonCollision* collision, NewtonCollisionInfoRecord* collisionInfo);


From this point on ntGeom should not be released, and each time this geometry is use by a body, ref sould increase by one.

As for the second question, not Newton does not uses the project is compil;eres with RTTI and Exection handling set to No in all configurations.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Pure virtual function call runtime error

Postby rvangaal » Tue Jun 09, 2009 9:52 am

I'll use the DLL, which I can use in Release & Debug mode.

I create multiple bodies. If I print out the ntGeom (collision) pointer value and references, I get this:

ntGeom 07A0EAE0: ref 2
ref 3
ref 2
ntGeom 07A0EAE0: ref 3
ref 4
ref 3
ntGeom 07A0EAE0: ref 4
ref 5
ref 4

So even though I destroy the collision object, its reference count seems to increase. Are these collision boxes cached? The pointer is always the same.
Currently all my boxes are the same size, so I can imagine it being the same object being returned, which would explain the reference count increasing, as the box is used for all my physics objects.
rvangaal
 
Posts: 61
Joined: Mon Jun 08, 2009 1:11 pm

Re: Pure virtual function call runtime error

Postby Julio Jerez » Tue Jun 09, 2009 10:25 am

yes collision shape are cached.
you can uncache them if you want by calling make unique at any time.
basically the world won the shape, an deach toiem you use it i incre the ref.
CreateBox will return the same Box with and Increased Ref if and only if they is one with the same signature already made.

It should be quite trivial.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Pure virtual function call runtime error

Postby rvangaal » Wed Jun 10, 2009 6:13 am

Thanks, it's all beginning to work.

One thing (maybe a bug) is that I had trouble getting a cone to work. Turned out I did this:

- create cone at (130,0,0)
- load track
- set world size (-5000,-5000,-5000)-(5000,5000,5000)
- create car at (120,0,0)

The cone never seemed to turn on (come out of sleep) again; I had to set the world size before creating the cone to get it to move. I would think that setting the world size would turn the cone back on, but I guess you only set the world size once before creating any objects? (in other words, just can't just resize an already sized world).
rvangaal
 
Posts: 61
Joined: Mon Jun 08, 2009 1:11 pm

Re: Pure virtual function call runtime error

Postby JernejL » Wed Jun 10, 2009 10:49 am

Default world size is 100 * 100 * 100 units, you specified X of 130 so it got frozen. Bodies outside of world size are frozen automaticly, but are not automaticly un-frozen when the world size is big enough for them (i think, unless you apply some force on it in forcetorque callback? julio should know better than me).
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Pure virtual function call runtime error

Postby rvangaal » Wed Jun 10, 2009 10:53 am

I actually did apply forces, tried to set velocities (linear & angular) did a setMatrix(), all that. It still didn't become unfrozen, hence my question. :)
rvangaal
 
Posts: 61
Joined: Mon Jun 08, 2009 1:11 pm

Re: Pure virtual function call runtime error

Postby JernejL » Wed Jun 10, 2009 4:54 pm

rvangaal wrote:I actually did apply forces, tried to set velocities (linear & angular) did a setMatrix(), all that. It still didn't become unfrozen, hence my question. :)


You apply forces and set velocity in side forcetorque callback.. also you tried NewtonWorldUnfreezeBody?
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Pure virtual function call runtime error

Postby rvangaal » Thu Jun 18, 2009 7:58 am

I didn't try UnfreezeBody(), but with the initial world size it now works. I want to avoid having to loop all physics bodies myself when I modify the world, so I won't pursue that option right now.

Thanks for the help!
rvangaal
 
Posts: 61
Joined: Mon Jun 08, 2009 1:11 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 3 guests

cron