Breaking changes after update

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Breaking changes after update

Postby JoeJ » Thu Mar 21, 2024 6:07 pm

I have just done an update, and there is one issue i can't figure out.
Code no longer compiles, MSVC error message is:
Code: Select all
Error   'Physics::PlayerController': cannot instantiate abstract class


Which makes no sense to me. I have all pure virtual functions implemented:

Code: Select all
class PlayerController : public ndModel
{
   public:
   
   ndSharedPtr<ndBody> playerBody = 0;
   ndSharedPtr<ndJointBilateralConstraint> upJoint = 0;

   ndVector frictionAlignment = ndVector::m_zero;
   ndVector playerAcc = ndVector::m_zero;
   ndFloat32 maxVelocity = 0.f;
   ndInt32 blockJumpTimer = 0;

   ndVector camFocus = ndVector::m_zero;

   PlayerController () : ndModel() {}

   ~PlayerController () {}

   void Create (ndWorld *world, const ndMatrix &xform) {...}
void OnAddToWorld (ndWorld* const world) {}
void OnRemoveFromToWorld (ndWorld* const world) {}
void Update (ndWorld* const world, ndFloat32 timestep) {...}
void PostUpdate (ndWorld* const world, ndFloat32 timestep) {...}
void PostTransformUpdate (ndWorld* const world, ndFloat32 timestep) {}
};



Seems my C++ skills are not enough. I'm stuck. Please help :lol:

Edit: Oh, i was just blind. ndWorld* is no longer a param of OnAddToWorld()
User avatar
JoeJ
 
Posts: 1453
Joined: Tue Dec 21, 2010 6:18 pm

Re: Breaking changes after update

Postby JoeJ » Thu Mar 21, 2024 9:01 pm

But now i have problems with ndModel lifecycle.
If i close my app, i get assert in ~ndModel() because m_deletedNode isn't null.

Or if i reset a model to it's initial state.
Example code, showing how i usually create and delete models:
Code: Select all
         if (*playerController)
         {
            ImGui::Begin("playerController");
            //playerController->GUI();
            if (ImGui::Button("Reset playerController"))
            {
               guiLog.Print("reset playerController...\n");
               //playerController->OnRemoveFromToWorld(/*&world*/);
               world.RemoveModel(*playerController);
               /*{
                  ndSharedPtr<PlayerController> temp;
                  playerController.Swap(temp);
               }*/
            
               playerController = new PlayerController();
               playerController->Create(&world, pcXF);
               world.AddModel((ndSharedPtr<ndModel>&)playerController);

            }
            ImGui::End();
         }


This trigger the asset here:
Code: Select all
void ndWorld::ThreadFunction()
{
   D_TRACKTIME();
   ndUnsigned64 timeAcc = ndGetTimeInMicroseconds();

   // clean up all batched deletd objects, before update
   while (m_deletedModels.GetCount())
   {
      ndAssert(0);


Found no example showing how to delete stuff in the demos.
User avatar
JoeJ
 
Posts: 1453
Joined: Tue Dec 21, 2010 6:18 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 40 guests