Offroad vehicle

Share your helpful Urho3D code snippets, samples and tutorials here.

Re: Offroad vehicle

PostPosted by Lumak » 24 Dec 2016, 22:35

Made changes in the repo to access and scale compound local AABB to allows changing the inertia bbox and reduce the chance of rolling when aabb.y is reduced.

About the video, the dust emitters are not properly placed and were corrected in the repo, but I kinda like how it looks in the video ;)

Merry Christmas :)

edit: keeping positive attitude toward the holidays
Lumak
Have many posts
Have many posts
 
Posts: 425
Joined: 08 Jun 2015, 15:38

Re: Offroad vehicle

PostPosted by Miegamicis » 29 Dec 2016, 15:36

Found a bug with the offroad vehicle code. The problem appears when vehicle node is destroyed, raycast vehicle is not removed from the physics world and in the next physics step update application crashes.

To fix this you need to change

Code: Select all
RaycastVehicle::~RaycastVehicle()
{
    if (sphShape_)
    {
        delete sphShape_;
        sphShape_ = NULL;
    }
    if (vehicleRaycaster_)
    {
        delete vehicleRaycaster_;
        vehicleRaycaster_ = NULL;
    }
    if (raycastVehicle_)
    {
        delete raycastVehicle_;
        raycastVehicle_ = NULL;
    }
}


to

Code: Select all
RaycastVehicle::~RaycastVehicle()
{
    if (sphShape_)
    {
        delete sphShape_;
        sphShape_ = NULL;
    }
    if (vehicleRaycaster_)
    {
        delete vehicleRaycaster_;
        vehicleRaycaster_ = NULL;
    }
    if (raycastVehicle_)
    {
        btDynamicsWorld *pbtDynWorld = (btDynamicsWorld*)GetPhysicsWorld()->GetWorld();
        pbtDynWorld->removeVehicle(raycastVehicle_);
        delete raycastVehicle_;
        raycastVehicle_ = NULL;
    }
}
User avatar
Miegamicis
New user
New user
 
Posts: 14
Joined: 19 Apr 2016, 10:19

Re: Offroad vehicle

PostPosted by Lumak » 29 Dec 2016, 17:46

Ok, thanks. This crash doesn't appear in Windows, which os?

edit: this makes sense if the game continues to run after a vehicle is removed. good find, thx.
Lumak
Have many posts
Have many posts
 
Posts: 425
Joined: 08 Jun 2015, 15:38

Re: Offroad vehicle

PostPosted by Miegamicis » 29 Dec 2016, 19:20

Lumak wrote:Ok, thanks. This crash doesn't appear in Windows, which os?

edit: this makes sense if the game continues to run after a vehicle is removed. good find, thx.


I used Windows. But anyway, great sample! Managed to get this to work without any problems! ;)
User avatar
Miegamicis
New user
New user
 
Posts: 14
Joined: 19 Apr 2016, 10:19

Previous

Return to Code Exchange

Who is online

Users browsing this forum: No registered users and 0 guests