BulletSharp icon indicating copy to clipboard operation
BulletSharp copied to clipboard

TypeInitialisationException was unhandled at new BulletSharp.RaycastVehicle();

Open mifwarior opened this issue 9 years ago • 6 comments

Having TypeInitialisationException was unhandled at new BulletSharp.RaycastVehicle();

public void SetupVechine(DynamicsWorld world, CollisionShape shape, Matrix vehicleTr, DefaultVehicleRaycaster raycaster) { RigidBody carChassis = LocalCreateRigidBody(800, vehicleTr, shape);

        carChassis.UserObject = "Chassis";
        carChassis.SetDamping(0.2f, 0.2f);

        world.AddRigidBody(carChassis);

        RaycastVehicle.VehicleTuning tuning = new RaycastVehicle.VehicleTuning();
        vehicle = new BulletSharp.RaycastVehicle(tuning, carChassis, raycaster);

}

reproduce at newest version, with old version it's all okey

mifwarior avatar Oct 24 '15 18:10 mifwarior

This can happen if you update the BulletSharp reference in one project, but not another. The runtime expects the newer type, but sees the old type or vice versa. Try rebuilding the entire solution and check that only the newest BulletSharp is referenced everywhere.

You can also check if the VehicleDemo (in demos/Generic) works. I couldn't reproduce the exception.

AndresTraks avatar Oct 25 '15 11:10 AndresTraks

Ok, in visual studio it works ok, but when i run builded file alone - have exception Perhaps it's my fault, I was wrong to build "BulletSharp.dll". I build it for "generic". I traced the error. It is called from RigidBody_GetUnmanagedConstructionInfo in RigidBodyConstructionInfo::RigidBodyConstructionInfo(btScalar mass, BulletSharp::MotionState^ motionState, BulletSharp::CollisionShape^ collisionShape)

mifwarior avatar Oct 25 '15 16:10 mifwarior

I make a test. Build BulletSharp.dll release and debug mode. Debug mode - work clearly, Release - don't work with exception

mifwarior avatar Oct 25 '15 18:10 mifwarior

I found a solution: Since running a separate (without studio) application displays more information about the error, I got an error AccessViolation.

Google helped: https://code.google.com/p/bulletsharp/issues/detail?id=52 http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=8180

i change BulletSharp in RaycastVehicle.cpp (line 85), at static RaycastVehicle::RaycastVehicle() original: RigidBodyConstructionInfo^ info = gcnew RigidBodyConstructionInfo(0, nullptr, nullptr); by: RigidBodyConstructionInfo^ info = gcnew RigidBodyConstructionInfo(0, nullptr, nullptr,Vector3_Zero); and all works!

mifwarior avatar Nov 01 '15 16:11 mifwarior

I added tests for the RigidBodyConstructionInfo constructor, but couldn't get the access violation. I do remember this issue popping up every now and then.

Can you tell me what your CPU model is? I'm wondering if it could be because of missing SSE support.

AndresTraks avatar Nov 03 '15 17:11 AndresTraks

https://gist.github.com/mifwarior/6591954f8a48b128e2cf

I'm certainly not the master of C ++, but I have a suspicion that it was not related to the SSE, but it is my guess. I have 2 computers, one is new, the other one is old and was obtained on both the error. The problem occurs every start.

mifwarior avatar Nov 04 '15 15:11 mifwarior