Panda Bullet

Hmm, there is a reason why the manual pages are not yet linked to the table of contents - they are not finished yet. None of them.

All known bugs in the btKindematicCharacterContrller have been fixed at least two month ago. So maybe “buggy” has not been the right word. “Generic” or “fundamental” would be better words. It is a good foundation for building own character controllers, with customised and/or extended behavious. Bullet is open source, and it’s possible to adapt the Bullet source code, or derive your own classes from btKindematicCharacterController. Even better would be to contribute the improvements to Bullet itself. That’s the idea of open source.

I would not mind rolling a extended character controller for the Panda3D Bullet module. But first we would have to define exactly what the behaviour should be, and how this should be implemented.

“canJump” is the method intended for this purpose. But it will return the same value as “onGround”, since this is the way Bullet implements this method

bool btKinematicCharacterController::canJump () const
{
	return onGround();
}

And this is the source code for “onGround”:

bool btKinematicCharacterController::onGround () const
{
	return m_verticalVelocity == 0.0 && m_verticalOffset == 0.0;
}

The two members checked here onGround get reset to zero upon collision with something (within void btKinematicCharacterController::stepDown). This explain the behaviour you observe. So, looking at the Bullet source code, what ideas do you guys have?

Just wanted to point out that PhysX has a debug renderer, the PhysxDebugGeomNode. And as far as I know coppertop has implemented a debug view in pure python for ODE.

I feel obligated to make it clear that I’ve used FenrirWolf’s code from the forum, so I only take credit for integrating that with my framework.

If I remember correctly, in Unity the standard character controller checks whether the character stays on a walkable/jumpable surface using the following condition:

on_ground = (contact_point.pos.Z < (character.pos.Z - height_threshold)) and (contact_point.normal.Z > slope_threshold)

where Z corresponds to “up” vertical direction.

If the condition is true for any contact point, then character stays on a walkable/jumpable surface.

Ok, sounds god. Thank you very much for this information. I didn’t have time to check if this fits inside the btKinematicCharacterController, but will do so soon. Soon as in “two or three weekes”, since I currently really busy at my job, which is not related to Panda3D in any way.

How can i constraint sphere to always be on plane?
i am making pong type game, and i dont want my ball to jump around. And ball needs to be rotated while it moves (like in a ball in a maze panda3d sample).

So basically, friction 1 and damping 0 make it roll infintely, now i just need to prevent it from jumping when it hits something.

I tried generic and distance constraints, but cant really figure them…

I think what you are looking for is a way to restict movement in certain directions. Have a look at this page, the second snippet: http://bulletphysics.org/mediawiki-1.5.8/index.php/Code_Snippets

I just added the two methods setLinearFactor and setAngularFactor to the Panda3D CVS, so you will to fetch the NEXT snapshot build.

Thanks, i will try it soon :slight_smile:

Hi,

After a couple of month out of Panda C++ programming, I just upgraded my environment Panda1.7 to Panda1.8.

As per Bullet, this is what I get when compiling my c++ app

1>jctut.obj : error LNK2019: unresolved external symbol "void __cdecl btAlignedFreeInternal(void *)" (?btAlignedFreeInternal@@YAXPAX@Z) referenced in function "public: __thiscall btSoftBodyWorldInfo::~btSoftBodyWorldInfo(void)" (??1btSoftBodyWorldInfo@@QAE@XZ)
1>jctut.obj : error LNK2019: unresolved external symbol "public: void __thiscall btRigidBody::setDamping(float,float)" (?setDamping@btRigidBody@@QAEXMM@Z) referenced in function "void __cdecl init_simulBullet(void)" (?init_simulBullet@@YAXXZ)

I included libpandabullet.lib (libpandabullet.dll is 1680kb)

Trying again and adding

#pragma comment(lib,"BulletCollision.lib");
#pragma comment(lib,"BulletDynamics.lib");
#pragma comment(lib,"BulletMultiThreaded.lib");
#pragma comment(lib,"BulletSoftBody.lib");
#pragma comment(lib,"LinearMath.lib");

In this case I then get a bunch of:

1>C:\Users\jc\Desktop\WORK\Panda\Release\jctut.exe : fatal error LNK1169: one or more multiply defined symbols found

...
1>libcmt.lib(typname.obj) : error LNK2005: ___clean_type_info_names_internal already defined in MSVCRT.lib(MSVCR90.dll)
1>      Found __NMSG_WRITE
1>        Referenced in libcmt.lib(crt0dat.obj)
1>        Referenced in libcmt.lib(mlock.obj)
1>        Loaded libcmt.lib(crt0msg.obj)"

This smells a mixture of run time libs, which are puzzling. Tried /NODEFAULTLIB:“libc.lib libcmt.lib msvcrt.lib”… no change!

So to summarize:

> I did generate Bullet libs with /MD option
> I included this in panda3d\thirdparty\win-libs-vc9\bullet\lib
> I recompiled Panda to get Panda1.8
> then I tried to regenerate my app (an exe)...

What’s wrong? Should Bullet libs be compiled with /MT??

No, compiling the Bullet libraries (.lib) with /MD is what you should do on windows. I use the default settings which come with Bullet. I guess this is what rdb also does for the Panda3D SDKs.

Have you removed the /built directory when upgrading/recompiling Panda3D?

Maybe you could post a small sample project which reproduces your problem?

I just checked, and the last snapshot build of Panda3D has libpandabullet.dll with 1876 KB.

Hi ennOx, thanks.

I do confirm that the right way is thru /MD.

I found my issue: some of my compiler optimization options weirdly strapped some symbols.

Actually I regenerate both Bullet and Panda3D using Intel Parallel Compiler Suite, so that explains to the difference in size of the lib.

regards
Jean-Claude

Ok, this would explain your problems. I have been assuming you use standard MSVC 2008. Did you manage to compile and run your project by now? And just because I’m curious: do you make use of parallelisation features when compiling Panda3D?

Hello,

while testing BulletGhostNode i faced the following issue: if there is a BulletPlaneShape in the scene, the ghost object always reports that it’s overlapping with the plane even though they are far apart. is this the default behavior?

any help is appreciated,
best regards,

Here is the code i’m using:

int main(int argc, char *argv[])
{
	// Open a new window framework and set the title
	framework.open_framework(argc, argv);
	framework.set_window_title("My Panda3D Window");

	// Open the window
	WindowFramework *window = framework.open_window();
	NodePath camera = window->get_camera_group();
	camera.set_pos(0, 40, 20);
	camera.look_at(0, 0, 0);
	Thread *current_thread = Thread::get_current_thread();

	//=============
	// bullet world
	PT(BulletWorld) world = new BulletWorld;
	world->set_gravity(LVector3f(0, 0, -9.81));

	//=============
	//plane
	PT(BulletPlaneShape) plane_shape = new BulletPlaneShape(LVector3f(0, 0, 1), 0);
	PT(BulletRigidBodyNode) plane_node = new BulletRigidBodyNode("plane1");
	plane_node->add_shape(plane_shape);
	NodePath plane_nodepath = window->get_render().attach_new_node(plane_node);
	plane_nodepath.set_pos(0, 0, -2);
	world->attach_rigid_body(plane_node);
	plane_node->set_into_collide_mask(CollideMask::all_on());

	//=============
	// bullet debug
	PT(BulletDebugNode) debug_node = new BulletDebugNode("debug");
	debug_node->set_verbose(false);
	NodePath debug_nodepath = window->get_render().attach_new_node(debug_node);
	debug_nodepath.show();
	world->set_debug_node(debug_node);

	//============
	// ghost node for collision testing
	PT(BulletBoxShape) ghost_box_shape = new BulletBoxShape(LVector3f(1, 1, 1));
	PT(BulletGhostNode) ghost_box_node = new BulletGhostNode("ghost_box");
	ghost_box_node->add_shape(ghost_box_shape);
	NodePath ghost_box_nodepath = window->get_render().attach_new_node(ghost_box_node);
	ghost_box_nodepath.set_pos(-3, 3, 10);
	ghost_box_nodepath.set_collide_mask(3);
	world->attach_ghost(ghost_box_node);

	while(framework.do_frame(current_thread))
	{
		world->do_physics(globalClock->get_dt());
		
		int n = ghost_box_node->get_num_overlapping_nodes();
		if( n > 0)
		{
			for(int z = 0; z < n; z++)
				cout << ghost_box_node->get_overlapping_node(z)->get_name() << "\n";
		}
	}

	framework.close_framework();
	return (0);
}

I did not try your code, basically, i think that plane has two sides, one is solid and other is not.

So if your entity is on solid side, it will always get reported as active collision, move it to other side of plane, it is not pushed automagically by bullet because its ghost node.
Not sure if this is true in bullet, i knwo its true for almost any physics/collision system.

Right, which is why a “plane” in collision/physics parlance is more accurately called a “half-space”. Try flipping the plane around, or moving it to the other side of the colliding object.

Thank you GrizzLyCRO and rdb for your responses.
I tested flipping the plane by flipping it’s normal:
PT(BulletPlaneShape) plane_shape = new BulletPlaneShape(LVector3f(0, 0, -1), 0);

still the same result. the ghost object keeps reporting that it’s overlapping with the plane. I also tested moving the object to both sides of the plane, the same result. am i still missing something? maybe my code has something wrong?

//===================== EDIT =========================
[size=150]i have found the answer after some debugging and i started a new thread with the answer posted so others can find it easily
panda3d.org/forums/viewtopic … 3967#73967

I believe that eventually everyone will come to the point they will decide to use ghost objects and so they will face this issue. so i suggest that the example in Panda Bullet tutorial use a box as a ground instead of a plane.
[/size]

Hi enn0x,
Well compiled under Intel parallel studio!

I did compile Bullet_Physics using SSE4 instruction set, and letting the compiler optimize (unroll loops, vectorize the code,…). This worked ok for most of the lib modules except BulletMultiThreaded and LinearMat that I compiled with Msvc (options /arch:SSE2 & use intrinsics)
Don’t know why these two are not working properly when compiled under Intel…

Then I recompiled Panda_1.8 aas mentionned in my post
[url]Build Panda3D with optimized Intel C++ Compiler]

And I’m using the same approach when compiling my C++ panda app code.

Cheers
Jean-Claude

Hi,
I’d like to report a weird behaviour of the bullet debug interface.

Depending on the camera position, the debug bounding boxes switch from visible to invisible.

Here is an example where the camera has just slightly moved:

https://rapidshare.com/files/1347343817/Capture1.JPG
https://rapidshare.com/files/1932046541/Capture2.JPG

the setup was done this way

DebugNode = new BulletDebugNode("Debug");
DebugNode->set_verbose(true);
NodePath debugNP = render.attach_new_node(DebugNode);

mgr = new BulletWorld();
mgr->set_debug_node(DebugNode);
debugNP.show();    // show debug nodes

Any explanation?

What places would you guys suggest to learn Bullet?
bulletphysics.com/ftp/pub/te … Manual.pdf
Is there a list of things not supported? And maybe some list of things the Panda implementation does differently? Or are the example snippets in here enough to learn that?