<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://pybullet.org/Bullet/phpBB3/app.php/feed/topic/9777" />

	<title>Real-Time Physics Simulation Forum</title>
	
	<link href="https://pybullet.org/Bullet/phpBB3/index.php" />
	<updated>2014-02-18T13:08:00+00:00</updated>

	<author><name><![CDATA[Real-Time Physics Simulation Forum]]></name></author>
	<id>https://pybullet.org/Bullet/phpBB3/app.php/feed/topic/9777</id>

		<entry>
		<author><name><![CDATA[SoapyWet]]></name></author>
		<updated>2014-02-18T13:08:00+00:00</updated>

		<published>2014-02-18T13:08:00+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=32992#p32992</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=32992#p32992"/>
		<title type="html"><![CDATA[Weird bug in bullet]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=32992#p32992"><![CDATA[
Hello,<br>I'm currently working on a project which has implemented bullet (2.81-rev2613).<br><br>The bug that occurs is that bullet will completely break without reason; I lose complete control of the rigidbody and it does not rotate properly anymore.<br><br>The current setup is a map which is a rigidybody with a BvhTriMesh collision shape, the player is a capsule rigidbody (but  the same error occurs with a box aswell)<br><br>The world is setup as follows:<div class="codebox"><p>Code: </p><pre><code>this-&gt;m_broadphase = new btDbvtBroadphase();this-&gt;m_collisionConfig = new btDefaultCollisionConfiguration();this-&gt;m_collisionDispatcher = new btCollisionDispatcher(this-&gt;m_collisionConfig);this-&gt;m_solver = new btSequentialImpulseConstraintSolver;this-&gt;m_dynamicsWorld = new btDiscreteDynamicsWorld(this-&gt;m_collisionDispatcher, this-&gt;m_broadphase, this-&gt;m_solver, this-&gt;m_collisionConfig);this-&gt;m_dynamicsWorld-&gt;setGravity(btVector3(0,-9.8,0));this-&gt;m_GhostPairCallback = new btGhostPairCallback();this-&gt;m_dynamicsWorld-&gt;getBroadphase()-&gt;getOverlappingPairCache()-&gt;setInternalGhostPairCallback(this-&gt;m_GhostPairCallback);</code></pre></div>The map is loaded from a .obj and is created like so:<div class="codebox"><p>Code: </p><pre><code>btCollisionShape* collshp = collptr-&gt;m_BvhTriMesh;btTransform* tTrans;tTrans = new btTransform();tTrans-&gt;setIdentity();tTrans-&gt;setOrigin(btVector3(0,0,0));collshp-&gt;setLocalScaling(btVector3(1.0f, 1.0f, 1.0f));  /// NEED TO CHANGE THISbtDefaultMotionState* tMotion = new btDefaultMotionState(*tTrans);btRigidBody::btRigidBodyConstructionInfo cInfo(0.0f,tMotion,collshp,btVector3(0,0,0));btRigidBody* body = new btRigidBody(cInfo);body-&gt;getWorldTransform().setIdentity();this-&gt;m_LevelUserPtr = static_cast&lt;void*&gt;(new std::string("World"));body-&gt;setUserPointer(this-&gt;m_LevelUserPtr);this-&gt;m_dynamicsWorld-&gt;addRigidBody(body, SharedRsc::COL_RIGIDS, SharedRsc::COL_PLAYER | SharedRsc::COL_OWNGHOST | BIT(0));</code></pre></div>The player like so:<div class="codebox"><p>Code: </p><pre><code>this-&gt;m_State = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1), this-&gt;m_SpawnLocation));this-&gt;m_Inertia = btVector3(0,0,0);BulletCollisionShapeCollection::m_PlayerBox-&gt;calculateLocalInertia(this-&gt;m_Mass, this-&gt;m_Inertia);btRigidBody::btRigidBodyConstructionInfo ci(this-&gt;m_Mass, this-&gt;m_State, BulletCollisionShapeCollection::m_PlayerBox, this-&gt;m_Inertia);this-&gt;m_RigidBody = new btRigidBody(ci);this-&gt;m_RigidBody-&gt;getWorldTransform().setIdentity();this-&gt;m_RigidBody-&gt;setSleepingThresholds(0.0f, 0.0f);this-&gt;m_RigidBody-&gt;setActivationState(DISABLE_DEACTIVATION);this-&gt;m_RigidBody-&gt;setAngularFactor(btVector3(0,0,0));this-&gt;m_RigidBody-&gt;setRestitution(0);this-&gt;m_RigidBody-&gt;setFriction(2.0);this-&gt;m_RigidBody-&gt;setDamping(.5, 0.0);this-&gt;m_GhostObject = new btPairCachingGhostObject();this-&gt;m_GhostObject-&gt;getWorldTransform().setIdentity();this-&gt;m_GhostObject-&gt;setCollisionShape(this-&gt;m_RigidBody-&gt;getCollisionShape());</code></pre></div>And we move and rotate the player like so:<div class="codebox"><p>Code: </p><pre><code>Math3::NormaliseVector(totalMove);if(isG){if(walking)totalMove *= 0.5;this-&gt;m_RigidBody-&gt;applyCentralForce(btVector3(totalMove.x, totalMove.y, totalMove.z) * this-&gt;m_groundMove);} elsethis-&gt;m_RigidBody-&gt;applyCentralForce(btVector3(totalMove.x, totalMove.y, totalMove.z) * this-&gt;m_airMove);this-&gt;m_State-&gt;getWorldTransform(transf);transf.setRotation(transf.getRotation().slerp(btQuaternion(this-&gt;m_TargQuat.x, this-&gt;m_TargQuat.y, this-&gt;m_TargQuat.z, this-&gt;m_TargQuat.w), 0.2));this-&gt;m_RigidBody-&gt;setCenterOfMassTransform(transf);this-&gt;m_RigidBody-&gt;getMotionState()-&gt;setWorldTransform(transf);this-&gt;m_GhostObject-&gt;setWorldTransform(this-&gt;m_RigidBody-&gt;getWorldTransform());</code></pre></div>Thanks<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=10730">SoapyWet</a> — Tue Feb 18, 2014 1:08 pm</p><hr />
]]></content>
	</entry>
	</feed>
