Bullet: C++ error r6025 when calling world.stepSimulation()

SiWi

20-08-2008 14:46:50

Well the initalization(Partially taken from test01.py and corrected):

collisionConfiguration = bullet.btDefaultCollisionConfiguration()
dispatcher = bullet.btCollisionDispatcher (collisionConfiguration)

worldAabbMin = bullet.btVector3(-1000,-1000,-1000)
worldAabbMax = bullet.btVector3(1000,1000,1000)
maxProxies = 32766

broadphase = bullet.btAxisSweep3(worldAabbMin, worldAabbMax, maxProxies)

solver = bullet.btSequentialImpulseConstraintSolver()
self.world = bullet.btDiscreteDynamicsWorld(dispatcher, broadphase , solver, collisionConfiguration

Partially taken from test01.py and corrected

The error is happening here(called every frame):

self.world.stepSimulation(deltaTime)

That´s all code where I'm even using bullet as I'm just trying to start off.

Is there an error on my site, or is it an wrapping error.

I also searched the Bullet Forums, but didn´t find anything related.

andy

21-08-2008 00:02:08

I'm currently updating the wrapper for Bullet 2.70 so will take a look...

If possible can you post your test code (as there currently isn't any test code for the bullet modules).

Thanks

Andy

SiWi

21-08-2008 09:24:40

This is all bullet related code I got.
I just started with basic testing yesterday.
The first part is the initalization, which is working fine.
And the line where it crashes is called every frame.
But I´ll try to put a little pure bullet test together, which I´m going to post up here.
EDIT: Ok, now it´s getting interesting.
Just tried to put a basic junk of bullet code together.
The thing is: When the bullet gets imported as first and only module, I get an error, that boost_python-vc90-mt-1_35.dll couldn't get find.
When I import bullet in my application, I´m working on atm, together with a lot of other modules it imports just fine. Going to further investigate now.
EDIT2: Ok, importing ogre first fixes the problem. Is this intended from you?
EDIT3: So here is some working code and some not working code:
from ogre.renderer.OGRE import *
import ogre.physics.bullet as bullet

class OgreMotionState(bullet.btMotionState):
def __init__(self, initalPosition):
self.Pos=initalPosition
self.Position=Vector3()
self.Quaternion=Quaternion()
def getWorldTransform(self, WorldTrans):
worldTrans=self.Pos
def setWorldTransform(WorldTrans):
self.Position=Vector3(WorldTrans.getOrigin().x(),WorldTrans.getOrigin().y(),WorldTrans.getOrigin().z())
self.Quaternion=Quaternion(WorldTrans.getRoation().w(),WorldTrans.getRoation().x(),WorldTrans.getRoation().y(),WorldTrans.getRoation().z())

collisionConfiguration = bullet.btDefaultCollisionConfiguration()
dispatcher = bullet.btCollisionDispatcher (collisionConfiguration)

worldAabbMin = bullet.btVector3(-1000,-1000,-1000)
worldAabbMax = bullet.btVector3(1000,1000,1000)
maxProxies = 32766

broadphase = bullet.btAxisSweep3(worldAabbMin, worldAabbMax, maxProxies)

solver = bullet.btSequentialImpulseConstraintSolver()
world = bullet.btDiscreteDynamicsWorld(dispatcher, broadphase , solver, collisionConfiguration)

shape=bullet.btCapsuleShape(10, 20)
motionState=OgreMotionState(bullet.btTransform())
#Object=bullet.btRigidBody(10.0, motionState, shape) ...this should work in my eyes
#Object=bullet.btRigidBody(bullet.btRigidBodyConstructionInfo()) ...well obviously not in bullet 2.6.9


Well the first way to initalize btRigidBody gives me a C++ Signature not matching error thingy in btRigidBody.__init__.
What I identified as the problem(I could also be wrong here) is that __init__ passes a btRigidBody as first Parameter, the self Paramter obviously, but C++ expects a struct object for some reason.

For the second try to initalize, just forget it...

EDIT4: Ok, integrated the code I had originally problems with in some basic ogre demo application and now I don´t get an C++ error, but the application just crashes at the first frame. :o

andy

22-08-2008 09:37:41

OK -- first problem is that you need to change the __init__ in your OgreMontionState class to something like:
class OgreMotionState(bullet.btMotionState):
def __init__(self, initalPosition):
bullet.btMotionState.__init__(self)
....

Something I often forget is that the __init__ functions of 'parent' classes are not automatically called in Python. You have to do so manually otherwise boost/python-ogre/C++ doesn't recognise your OgreMontionState class as a bullet.btMotionState class and the calling signiture doesn't work..

I can't get stepSimulation to fail so could you post your complete code...

regards
And

SiWi

22-08-2008 11:33:44

Yeah, you're right first problem fixed.
My complete is ~1,2k atm, so... But as I said above I tried to recreate the problem above by implementing my bullet code in the Bezier demo.
I don´t get the C++ error now, but the app simply crashes.
Here is the code:

import sys
sys.path.insert(0,'..')
import PythonOgreConfig

import ogre.renderer.OGRE as ogre
import SampleFramework as sf
import ctypes, math
import ogre.physics.bullet as bullet

##patch = ogre.PatchMesh()
##Pass = ogre.Pass()

## Logging class
class MyLog(ogre.LogListener):
def __init__(self):
# Creates a C++ log that will try and write to console and file
ogre.LogListener.__init__(self)

def messageLogged(self, message, level, debug, logName):
# This should be called by Ogre instead of logging
pass
#print message


## Event handler to add ability to alter subdivision
class BezierListener(sf.FrameListener):
def __init__(self, renderWindow, camera ):
self.timeLapse = 0.0
self.factor = 0.0
self.wireframe = 0
self.renderWindow = renderWindow
sf.FrameListener.__init__(self, renderWindow, camera)

def frameStarted(self, frameEvent):
print 'framed'
self.world.stepSimulation(frameEvent.timeSinceLastFrame)
global patchPass, patch
if( sf.FrameListener.frameStarted(self, frameEvent) == False ):
return False
self.timeLapse += frameEvent.timeSinceLastFrame
## Prgressively grow the patch
if (self.timeLapse > 1.0):
self.factor += 0.2
if (self.factor > 1.0) :
self.wireframe = not self.wireframe
##self.camera.setPolygonMode(wireframe ? PM_WIREFRAME : PM_SOLID)
if self.wireframe:
patchPass.setPolygonMode(ogre.PolygonMode.PM_WIREFRAME )
else:
patchPass.setPolygonMode(ogre.PolygonMode.PM_SOLID)
self.factor = 0.0
patch.setSubdivision(self.factor)
sf.Application.debugText = "Bezier subdivision factor: " + str(self.factor)
self.timeLapse = 0.0

## Call default
return True

class OgreMotionState(bullet.btMotionState):
def __init__(self, initalPosition):
self.Pos=initalPosition
self.Position=Vector3()
self.Quaternion=Quaternion()
def getWorldTransform(self, WorldTrans):
worldTrans=self.Pos
def setWorldTransform(WorldTrans):
self.Position=Vector3(WorldTrans.getOrigin().x(),WorldTrans.getOrigin().y(),WorldTrans.getOrigin().z())
self.Quaternion=Quaternion(WorldTrans.getRoation().w(),WorldTrans.getRoation().x(),WorldTrans.getRoation().y(),WorldTrans.getRoation().z())

class BezierApplication(sf.Application):
def __init__(self):
sf.Application.__init__(self)
patchDecl = ogre.VertexDeclaration()
self.patchCtlPoints =0
# Create the global log manager instance
self.logMgr = ogre.LogManager()
# create the instance of our log listener
self.myLog = MyLog()
# create a "log"
self.currentLog = ogre.LogManager.getSingletonPtr().createLog("dummy.log"
, True # it's the default log
, False # I don't want it sent to the debug window
, True # it's a virtual log, so you need a listener :)
)
# register our listener
self.currentLog.addListener ( self.myLog )

collisionConfiguration = bullet.btDefaultCollisionConfiguration()
dispatcher = bullet.btCollisionDispatcher (collisionConfiguration)

worldAabbMin = bullet.btVector3(-1000,-1000,-1000)
worldAabbMax = bullet.btVector3(1000,1000,1000)
maxProxies = 32766

broadphase = bullet.btAxisSweep3(worldAabbMin, worldAabbMax, maxProxies)

solver = bullet.btSequentialImpulseConstraintSolver()
self.world = bullet.btDiscreteDynamicsWorld(dispatcher, broadphase , solver, collisionConfiguration)


def _createScene(self):
global patchPass, patch, pVert
sceneManager = self.sceneManager

## Set ambient light
sceneManager.setAmbientLight( (0.2, 0.2, 0.2) )
print "\n1"
## Create a point light
l = sceneManager.createLight("MainLight")
l.setType(ogre.Light.LT_DIRECTIONAL)
l.setDirection(-0.5, -0.5, 0)

## Create patch - here we are creating a memoryblock that is 8 floats (x,y,z,nx,ny,nz,u,v)
## Notice how we increment the offset for each new element
offset = 0

patchDecl = ogre.HardwareBufferManager.getSingleton().createVertexDeclaration()
patchDecl.addElement(0, 0, ogre.VertexElementType.VET_FLOAT3, ogre.VertexElementSemantic.VES_POSITION)
offset += ogre.VertexElement.getTypeSize(ogre.VertexElementType.VET_FLOAT3)

patchDecl.addElement(0, offset, ogre.VertexElementType.VET_FLOAT3, ogre.VertexElementSemantic.VES_NORMAL)
offset += ogre.VertexElement.getTypeSize(ogre.VertexElementType.VET_FLOAT3)

patchDecl.addElement(0, offset, ogre.VertexElementType.VET_FLOAT2, ogre.VertexElementSemantic.VES_TEXTURE_COORDINATES, 0)
offset += ogre.VertexElement.getTypeSize(ogre.VertexElementType.VET_FLOAT2)

## Make a patch for test - there are 9 'patches, each with 8 floats as above
storageclass = ctypes.c_float * (8*9)
pVert=storageclass(1.1)
ctypes.memset ( pVert, 0, 8*9 ) # just showing how this can be done

## Patch data
inc = 0
pVert[inc+0] = -500.0
pVert[inc+1] = 200.0
pVert[inc+2] = -500.0
pVert[inc+3] = -0.5
pVert[inc+4] = 0.5
pVert[inc+5] = 0.0
pVert[inc+6] = 0.0
pVert[inc+7] = 0.0
inc=8
pVert[inc+0] = 0.0
pVert[inc+1] = 500.0
pVert[inc+2] = -750.0
pVert[inc+3] = 0.0
pVert[inc+4] = 0.5
pVert[inc+5] = 0.0
pVert[inc+6] = 0.5
pVert[inc+7] = 0.0
inc = 16
pVert[inc+0] = 500.0
pVert[inc+1] = 1000.0
pVert[inc+2] = -500.0
pVert[inc+3] = 0.5
pVert[inc+4] = 0.5
pVert[inc+5] = 0.0
pVert[inc+6] = 1.0
pVert[inc+7] = 0.0
inc = 24
pVert[inc+0] = -500.0
pVert[inc+1] = 0.0
pVert[inc+2] = 0.0
pVert[inc+3] = -0.5
pVert[inc+4] = 0.5
pVert[inc+5] = 0.0
pVert[inc+6] = 0.0
pVert[inc+7] = 0.5
inc = 32
pVert[inc+0] = 0.0
pVert[inc+1] = 500.0
pVert[inc+2] = 0.0
pVert[inc+3] = 0.0
pVert[inc+4] = 0.5
pVert[inc+5] = 0.0
pVert[inc+6] = 0.5
pVert[inc+7] = 0.5
inc = 40
pVert[inc+0] = 500.0
pVert[inc+1] = -50.0
pVert[inc+2] = 0.0
pVert[inc+3] = 0.5
pVert[inc+4] = 0.5
pVert[inc+5] = 0.0
pVert[inc+6] = 1.0
pVert[inc+7] = 0.5
inc = 48
pVert[inc+0] = -500.0
pVert[inc+1] = 0.0
pVert[inc+2] = 500.0
pVert[inc+3] = -0.5
pVert[inc+4] = 0.5
pVert[inc+5] = 0.0
pVert[inc+6] = 0.0
pVert[inc+7] = 1.0
inc = 56
pVert[inc+0] = 0.0
pVert[inc+1] = 500.0
pVert[inc+2] = 500.0
pVert[inc+3] = 0.0
pVert[inc+4] = 0.5
pVert[inc+5] = 0.0
pVert[inc+6] = 0.5
pVert[inc+7] = 1.0
inc = 64
pVert[inc+0] = 500.0
pVert[inc+1] = 200.0
pVert[inc+2] = 800.0
pVert[inc+3] = 0.5
pVert[inc+4] = 0.5
pVert[inc+5] = 0.0
pVert[inc+6] = 1.0
pVert[inc+7] = 1.0
print "\n1"

##
## NOTE: Python-Ogre Special :)
## createBezierPatch requires the address of te buffer which we pass using the addressof method
## in ctypes..
##
patch = ogre.MeshManager.getSingleton().createBezierPatch(
"Bezier1", ogre.ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
ctypes.addressof(pVert), patchDecl, 3,3, 5, 5, visibleSide=ogre.PatchSurface.VS_BOTH )

## the rest of these are default settings - so you can use them or Python-Ogre will fill in the
## default values for you
## ,vbUsage=ogre.HardwareBuffer.HBU_STATIC_WRITE_ONLY, ibUsage=ogre.HardwareBuffer.HBU_DYNAMIC_WRITE_ONLY,
## vbUseShadow=True, ibUseShadow=True)

## Start patch at 0 detail
patch.setSubdivision(0.0)
## Create entity based on patch
patchEntity = sceneManager.createEntity("Entity1", "Bezier1")

pMat = ogre.MaterialManager.getSingleton().create("TextMat",
ogre.ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME)
pMat.getTechnique(0).getPass(0).createTextureUnitState( "BumpyMetal.jpg" )
patchEntity.setMaterialName("TextMat")
patchPass = pMat.getTechnique(0).getPass(0)


## Attach the entity to the root of the scene
sceneManager.getRootSceneNode().attachObject(patchEntity)

self.camera.setPosition(500,500, 1500)
self.camera.lookAt(0,200,-300)
sf.Application.debugText = "STARTED"


def _destroyScene(self):

## free up the pointer before we shut down OGRE
patch.setNull()

def _createFrameListener(self):
self.frameListener = BezierListener(self.renderWindow, self.camera)
self.root.addFrameListener(self.frameListener)
self.frameListener.showDebugOverlay( True )
self.frameListener.world=self.world


if __name__ == '__main__':
import exceptions,sys
try:
application = BezierApplication()
application.go()
except ogre.OgreException, e:
print e

andy

22-08-2008 11:51:56

Change your init code to:
...
self.collisionConfiguration = bullet.btDefaultCollisionConfiguration()
self.dispatcher = bullet.btCollisionDispatcher (self.collisionConfiguration)
...
self.broadphase = bullet.btAxisSweep3(worldAabbMin, worldAabbMax, maxProxies)
self.solver = bullet.btSequentialImpulseConstraintSolver()
self.world = bullet.btDiscreteDynamicsWorld(self.dispatcher, self.broadphase , self.solver, self.collisionConfiguration)


Classic issue where certain objects need to stay around but as you created them in the init function they are auto deleted which you don't want..

Andy

SiWi

22-08-2008 12:56:01

Working. :D
Seems like I have been coding too much PHP & Javascript in the last time.