MAV on ODE_dBodyAddForce()

Blitz3D Forums/Blitz3D Programming/MAV on ODE_dBodyAddForce()

bytecode77(Posted 2006) [#1]
hi!

i am developing a physic engine at the moment!
and on this function:
Function CreatePhysicExplosion(x#, y#, z#, range# = 5, intensity# = 10)
For pm.PhysicMesh = Each PhysicMesh
	ox# = x# - EntityX(pm\ent)
	oy# = y# - EntityY(pm\ent)
	oz# = z# - EntityZ(pm\ent)
	dis# = Sqr(ox# ^ 2 + oy# ^ 2 + oz# ^ 2)
	If dis# < range# Then ODE_dBodyAddForce pm\body, ox# * intensity#, oy# * intensity#, oz# * intensity#
Next
End Function


i allways get a MAV on ode_dbodyaddforce! do you know why?

thx :)


Stevie G(Posted 2006) [#2]
Never used ODE but it may a division by 0 issue. Adding an offset of 1 or less to dis# should prevent this. For explosions you should be using the inverse distance to calculate the effective intensity.

Function CreatePhysicExplosion(x#, y#, z#, range# = 5, intensity# = 10)

	For pm.PhysicMesh = Each PhysicMesh
		ox# = x# - EntityX(pm\ent)
		oy# = y# - EntityY(pm\ent)
		oz# = z# - EntityZ(pm\ent)
		dis# = Sqr(ox# * ox# + oy# * oy# + oz# * oz# ) + 1 
		Effect# = intensity / ( dis * dis )
		If dis# < range# Then ODE_dBodyAddForce pm\body, ox# * effect#, oy# * effect#, oz# * effect#
	Next
End Function


Not sure if this helps.
Stevie


bytecode77(Posted 2006) [#3]
still mav


Danny(Posted 2006) [#4]
either pm/body is 0 or an invalid handle, or you´re passing it illegal values. Check (print to debuglog) the results of the forces you try to add to the body. It could be possible you´re passing a NaN (not a number ie. a float out of range)

Hope that helps..


KuRiX(Posted 2006) [#5]
Sorry to be repetitive, but be shure that pm/body is a valid ODE body.