Jump to content

Recommended Posts

Posted

Hello,

 

I'm removing an object out of a collisioncallback function.

Therefore a body and a mesh must be freed (the mesh is parented to the body).

If I call the remove method normally the body is freed and the mesh is freed; works fine.

If I call it out of the collisioncallback function, the Freeentity(body) does

magically removes the mesh too, so I get an error at Freeentity(mesh).

Is there an explanation for this behaviour?

 

Function MineCollided(entity0:TEntity, entity1:TEntity, Position:Byte Ptr, Normal:Byte Ptr, force:Byte Ptr, speed:Float)
If TMineTracer(entity0.userdata) <> Null
	 TMineTracer(entity0.userdata).remove()
End If
End Function

 

Type TMineTracer
Method Remove()
	FreeEntity(Self.body)
	FreeEntity(Self.mesh)  ' throws an error, BUT only if called from MineCollided() '
	link.Remove()
End Method
end type

Core2DuoE6570 / Windows7 64bit / 4 Gb RAM / Geforce GTX 260 896Mb / LE 2.3

Dell Inspiron 1720 / Vista SP2 / C2D 2.4 / 8600 GM

Posted

If you remove a parent then children are removed automatically I believe. So just calling FreeEntity(Self.body) should do the trick. If you want to be sure, check to ensure Self.mesh isn't already null/nil/whatever the BM equivalent and don't try and remove it if it is.

Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX

ZBrush - Blender

Posted

The funny things is, that this only happens when called out of the Collisioncallback function, else not.

For testing I've set a field "destroyme" to true out of the callback function and then

removed the object from the update method. Works perfect.

 

And of course I did a NULL test for the mesh. Mesh was not NULL.

Tried to remove the mesh only if Entityexist(mesh)=true. Fails too.

 

There is a lot of trouble with Collisioncallbacks for me at the moment.

For ex. I can cast an entity1 to a body, but getbodyveloctiy() then crashes the engine.

Did a NULL test too.

 

There must be going on something beyond the curtain. :blink:

Core2DuoE6570 / Windows7 64bit / 4 Gb RAM / Geforce GTX 260 896Mb / LE 2.3

Dell Inspiron 1720 / Vista SP2 / C2D 2.4 / 8600 GM

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.

×
×
  • Create New...