JV-ODE destroy geom bug?

Blitz3D Forums/Blitz3D Userlibs/JV-ODE destroy geom bug?

Craig H. Nisbet(Posted 2009) [#1]
Hey Guys, I'm finally attempting to use this JV-ODE system I bought a couple years ago. I have the latest version. I'm running into a wierd problem were after I tell the system to go ahead and destroy the body,geom, and the containing ODEGeom type, it looks like it leaves a geom behind, because I can still collide with it even though it should be destroyed. Perhaps it's not actually destroying it under the hood, I'm not sure.

Anyone experience this? I looked in some of the threads, but they say to use and array of ODE objects, and don't actually destroy them. I'm not a huge fan of that idea, but if that's the way it has to be done, I guess I have no choice. Is this a weakness in ODE, or am I missing something?

Does anyone have example code for how to deal with this?


VIP3R(Posted 2009) [#2]
There are no known problems with the destroy functions, but there's a procedure to follow...

Destroy objects in the opposite order of creation, for example you create the type first, body second, then the geom. To delete them, destroy the geom first, body second, then the type reference.

If you're using geom transforms, you have to destroy the geom transform objects before the parent geom.

If you're following this procedure and still have problems, I'll need to see some code showing the issue.


Craig H. Nisbet(Posted 2009) [#3]
Looks like that didn't fix it. Here's piece of my code.

;Here's the type, the non-ode stuff is game specific stuff
Type ODEGeom
	Field body
	Field geom
	Field mesh
	
	Field size#
	Field TurnSpeed#
	Field TurnDrag#
	Field TurnAcceleration#
	Field MoveDrag#
	Field dx#,dy#,dz#,turn#
End Type

;This first function makes the EDEGeom
Function AddODE.ODEGeom(ODESpace,x#,y#,Z#,p#,yaw#,r#,mesh,colRadius=5,TurnAcceleration# = 0.03,TurnDrag# = .9,MoveDrag# = .99)

	Local size = colRadius
	ode.ODEGeom=New ODEGeom
	ode\body=dBodyCreate(World)
	dBodySetPosition(ode\body,x,y,Z)
	dBodySetRotation(ode\body,p,yaw,r)
	ode\geom=dCreateSphere(ODESpace,size)
	dBodySetAutoDisableFlag(ode\body,1)
	dGeomSetBody(ode\geom,ode\body)
	ode\mesh = mesh
	ode\size = size

	
	;create rig
	For i = 1 To 360 Step 30
		rx# = Sin(i) * 3
		rZ# = Cos(i) * 3
		
		odeR.ODEGeom = New ODEGeom
		odeR\geom=dCreateSphere(ODESpace,2/2)
		dGeomSetBody(odeR\geom,ode\body)
		dGeomSetOffsetPosition(odeR\geom,rx,0,rz)
		odeR\mesh=CreateSphere()
		HideEntity odeR\mesh
		ScaleMesh odeR\mesh,size,size,size
		EntityColor odeR\mesh,255,255,255
		EntityShininess odeR\mesh,0.7
		
	Next
	
	ode\TurnSpeed# = 0
	ode\TurnAcceleration# = TurnAcceleration#
	ode\TurnDrag# = TurnDrag#
	ode\MoveDrag = MoveDrag
	Return ode
End Function

;Here's the function I use to destroy, or fail to destroy the ODE Geoms
Function freeODE(ODE.ODEGeom)
	dGeomDestroy ODE\geom
	dBodyDestroy ODE\body
	Delete ODE
End Function


I've also gone as far to check using the GeomID functions to check if the id was correct, and it was. Also try the space remove function "dspaceremove" or somthing like that.


Craig H. Nisbet(Posted 2009) [#4]
WHOOHOOO!! I found it! Boy was it stupid. It was the secondary rig of geoms I made around the primary one. Man I'm dumb. Thanks for the help though!


VIP3R(Posted 2009) [#5]
No problem :)