<?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/13406" />

	<title>Real-Time Physics Simulation Forum</title>
	
	<link href="https://pybullet.org/Bullet/phpBB3/index.php" />
	<updated>2022-03-22T06:11:42+00:00</updated>

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

		<entry>
		<author><name><![CDATA[kcjsend2]]></name></author>
		<updated>2022-03-22T06:11:42+00:00</updated>

		<published>2022-03-22T06:11:42+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43948#p43948</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43948#p43948"/>
		<title type="html"><![CDATA[Re: RaycastVehicle falls through the bvhTriangleMeshShape]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43948#p43948"><![CDATA[
this was stupid question, I just don't apply quaternion rotation.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=14021">kcjsend2</a> — Tue Mar 22, 2022 6:11 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[kcjsend2]]></name></author>
		<updated>2022-03-22T03:59:08+00:00</updated>

		<published>2022-03-22T03:59:08+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43947#p43947</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43947#p43947"/>
		<title type="html"><![CDATA[RaycastVehicle falls through the bvhTriangleMeshShape]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43947#p43947"><![CDATA[
I make Mesh Shape from Track meshes, and gather it by compound shape like this : <div class="codebox"><p>Code: </p><pre><code>void Mesh::CreateMeshShape(const std::vector&lt;Vertex&gt;&amp; targetVertices, const std::vector&lt;UINT&gt;&amp; targetIndices){mTriangleVertexArray = new btTriangleIndexVertexArray();btIndexedMesh tempMesh;mTriangleVertexArray-&gt;addIndexedMesh(tempMesh, PHY_FLOAT);btIndexedMesh&amp; mesh = mTriangleVertexArray-&gt;getIndexedMeshArray()[0];const int32_t VERTICES_PER_TRIANGLE = 3;size_t numIndices = targetIndices.size();mesh.m_numTriangles = numIndices / VERTICES_PER_TRIANGLE;if (numIndices &lt; std::numeric_limits&lt;int16_t&gt;::max()){mesh.m_triangleIndexBase = new unsigned char[sizeof(int16_t) * (size_t)numIndices];mesh.m_indexType = PHY_SHORT;mesh.m_triangleIndexStride = VERTICES_PER_TRIANGLE * sizeof(int16_t);}else{mesh.m_triangleIndexBase = new unsigned char[sizeof(int32_t) * (size_t)numIndices];mesh.m_indexType = PHY_INTEGER;mesh.m_triangleIndexStride = VERTICES_PER_TRIANGLE * sizeof(int32_t);}mesh.m_numVertices = targetVertices.size();mesh.m_vertexBase = new unsigned char[VERTICES_PER_TRIANGLE * sizeof(btScalar) * (size_t)mesh.m_numVertices];mesh.m_vertexStride = VERTICES_PER_TRIANGLE * sizeof(btScalar);btScalar* vertexData = static_cast&lt;btScalar*&gt;((void*)(mesh.m_vertexBase));for (int32_t i = 0; i &lt; mesh.m_numVertices; ++i){int32_t j = i * VERTICES_PER_TRIANGLE;const XMFLOAT3&amp; point = targetVertices[i].Position;vertexData[j] = point.x;vertexData[j + 1] = point.y;vertexData[j + 2] = point.z;}if (numIndices &lt; std::numeric_limits&lt;int16_t&gt;::max()){int16_t* indices = static_cast&lt;int16_t*&gt;((void*)(mesh.m_triangleIndexBase));for (int32_t i = 0; i &lt; numIndices; ++i) {indices[i] = (int16_t)targetIndices[i];}}else{int32_t* indices = static_cast&lt;int32_t*&gt;((void*)(mesh.m_triangleIndexBase));for (int32_t i = 0; i &lt; numIndices; ++i){indices[i] = targetIndices[i];}}const bool USE_QUANTIZED_AABB_COMPRESSION = true;mMeshShape = std::make_shared&lt;btBvhTriangleMeshShape&gt;(mTriangleVertexArray, USE_QUANTIZED_AABB_COMPRESSION);}//Create RigidBodywhile(*mesh read end*){for (int i = 0; i &lt; obj-&gt;GetMeshCount(); ++i){if (meshes[i]-&gt;GetMeshShape()){btTransform btLocalTransform;btLocalTransform.setIdentity();btLocalTransform.setOrigin(btVector3(pos.x, pos.y, pos.z));compound-&gt;addChildShape(btLocalTransform, meshes[i]-&gt;GetMeshShape().get());}}}btTransform btObjectTransform;btObjectTransform.setIdentity();btObjectTransform.setOrigin(btVector3(0, 0, 0));mTrackRigidBody = physics-&gt;CreateRigidBody(0.0f, btObjectTransform, compound);</code></pre></div>At first, it looks like it's working well, but when the vehicle moves few minute, it breaks through the track.<br><br>There seems to be no problem with the code, but is there anything wrong?<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=14021">kcjsend2</a> — Tue Mar 22, 2022 3:59 am</p><hr />
]]></content>
	</entry>
	</feed>
