Jump to content

Very small physic objects causing crash


bandrewk
 Share

Recommended Posts

Hi all,

 

I've recently implemented bullets and I noticed that when firing very small objects with a high velocity (such as bullets) my application tends to crash occasionally (Unhandled exception at 0x0137DD0A in Client.debug.exe: 0xC0000005: Access violation reading location 0x00000024.). Here is the callstack:

 

Client.debug.exe!dgConstraint::GetId(void) Unknown
Client.debug.exe!dgBroadPhase::AddPair(class dgBody * const,class dgBody * const,class dgVector const &,int) Unknown
Client.debug.exe!dgBroadPhase::FindCollidingPairsGeneric(class dgBroadphaseSyncDescriptor * const,int) Unknown
Client.debug.exe!dgBroadPhase::CollidingPairsKernel(void * const,void * const,int) Unknown
Client.debug.exe!dgThreadHive::dgThreadBee::RunNextJobInQueue(int) Unknown
Client.debug.exe!dgThreadHive::dgThreadBee::Execute(int) Unknown
Client.debug.exe!dgThread::dgThreadSystemCallback(void *) Unknown
Client.debug.exe!_ptw32_threadStart@4() Unknown
> Client.debug.exe!_callthreadstartex() Line 376 C
Client.debug.exe!_threadstartex(void * ptd) Line 359 C
kernel32.dll!75a4919f() Unknown
[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]
[External Code]

 

The bullet class (inherits from Leadwerks's object class) :

 

Bullet::Bullet(const Leadwerks::Vec3 position, const Leadwerks::Vec3 rotation, const Leadwerks::Vec3 velocity) : GameObject(Model::Box(0.05, 0.05, 0.05),
GameObject::BulletClass)
{
Shape* shape = Shape::Box(0, 0, 0, 0, 0, 0, 0.05, 0.05, 0.05);
entity->SetShape(shape);
shape->Release();

entity->SetMass(1);
entity->SetPosition(position, true);
entity->SetSweptCollisionMode(true);
entity->SetRotation(rotation, true);
entity->SetVelocity(velocity, true);

spawnTime = Time::GetCurrent();
}

Bullet::~Bullet()
{
}

void Bullet::Update()
{
if (Time::GetCurrent() - spawnTime > 5000)
{
delete this;
}
}

What am I doing wrong? Please help me smile.png

Link to comment
Share on other sites

I already used physic bullets , the worst that could happen was no collision and the bullet going throught level walls, but i didn't had any crash, sound more a bug because you use code and some stuff is missing.

 

You could try some prefab bullet model you would instanciate , just adjust it's collision properties in LE3 editor and save it as prefab, i think it should work better.

 

What are the values of velocity in X,Y,Z ?

Try these also :

- Set the collision mode of the bullet to "prop"

- Set Gravity to false

Stop toying and make games

Link to comment
Share on other sites

Sample X, Y, Z values:

 

68.155075, -22.210451, -69.725044

57.263618, -22.322567, -78.883339

22.882359, -27.069118, -93.507538

 

I tried your other suggestions but they did not help. What do you mean by "some stuff is missing" ?

Link to comment
Share on other sites

You would be better off using raycasts for bullets then setting a force based on the pickinfo's position and normal. Small and fast usually doesn't play well in most physics engines. Previous tests back in LE2 using an older version of newton showed there was a limit to how small before the physics got weird.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...