maintain the upper triangle of A, external particle/force creation/destruction, particle force abstraction, testbed update
This commit is contained in:
		| @@ -22,32 +22,27 @@ | ||||
| class PinnedCloth : public ClothTest | ||||
| { | ||||
| public: | ||||
| 	PinnedCloth() | ||||
| 	PinnedCloth() : m_rectangleGarment(5.0f, 5.0f) | ||||
| 	{ | ||||
| 		m_gridClothMesh.vertexCount = m_gridMesh.vertexCount; | ||||
| 		m_gridClothMesh.vertices = m_gridMesh.vertices; | ||||
| 		// Generate 2D mesh | ||||
| 		m_rectangleGarmentMesh.Set(&m_rectangleGarment, 1.0f); | ||||
|  | ||||
| 		m_gridClothMesh.triangleCount = m_gridMesh.triangleCount; | ||||
| 		m_gridClothMesh.triangles = (b3ClothMeshTriangle*)m_gridMesh.triangles; | ||||
|  | ||||
| 		m_gridClothMeshMesh.vertexCount = m_gridClothMesh.vertexCount; | ||||
| 		m_gridClothMeshMesh.startVertex = 0; | ||||
|  | ||||
| 		m_gridClothMeshMesh.triangleCount = m_gridClothMesh.triangleCount; | ||||
| 		m_gridClothMeshMesh.startTriangle = 0; | ||||
|  | ||||
| 		m_gridClothMesh.meshCount = 1; | ||||
| 		m_gridClothMesh.meshes = &m_gridClothMeshMesh; | ||||
|  | ||||
| 		m_gridClothMesh.sewingLineCount = 0; | ||||
| 		m_gridClothMesh.sewingLines = nullptr; | ||||
| 		// Create 3D mesh | ||||
| 		m_rectangleClothMesh.Set(&m_rectangleGarmentMesh); | ||||
| 		 | ||||
| 		//   | ||||
| 		b3Mat33 dq = b3Mat33RotationX(0.5f * B3_PI); | ||||
| 		for (u32 i = 0; i < m_rectangleClothMesh.vertexCount; ++i) | ||||
| 		{ | ||||
| 			m_rectangleClothMesh.vertices[i] = dq * m_rectangleClothMesh.vertices[i]; | ||||
| 		} | ||||
|  | ||||
| 		b3ClothDef def; | ||||
| 		def.mesh = &m_gridClothMesh; | ||||
| 		def.mesh = &m_rectangleClothMesh; | ||||
| 		def.radius = 0.05f; | ||||
| 		def.density = 0.2f; | ||||
| 		def.ks = 10000.0f; | ||||
| 		def.kd = 0.0f; | ||||
| 		def.r = 0.05f; | ||||
| 		def.structural = 10000.0f; | ||||
| 		def.damping = 0.0f; | ||||
|  | ||||
| 		m_cloth = m_world.CreateCloth(def); | ||||
|  | ||||
| @@ -55,12 +50,11 @@ public: | ||||
| 		aabb.m_lower.Set(-5.0f, -1.0f, -6.0f); | ||||
| 		aabb.m_upper.Set(5.0f, 1.0f, -4.0f); | ||||
|  | ||||
| 		for (u32 i = 0; i < m_cloth->GetParticleCount(); ++i) | ||||
| 		for (b3Particle* p = m_cloth->GetParticleList().m_head; p; p = p->GetNext()) | ||||
| 		{ | ||||
| 			b3Particle* p = m_cloth->GetParticle(i); | ||||
| 			if (aabb.Contains(p->position)) | ||||
| 			if (aabb.Contains(p->GetPosition())) | ||||
| 			{ | ||||
| 				m_cloth->SetType(p, e_staticParticle); | ||||
| 				p->SetType(e_staticParticle); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| @@ -69,10 +63,10 @@ public: | ||||
| 	{ | ||||
| 		return new PinnedCloth(); | ||||
| 	} | ||||
| 	 | ||||
| 	b3GridMesh<10, 10> m_gridMesh; | ||||
| 	b3ClothMeshMesh m_gridClothMeshMesh; | ||||
| 	b3ClothMesh m_gridClothMesh; | ||||
|  | ||||
| 	b3RectangleGarment m_rectangleGarment; | ||||
| 	b3GarmentMesh m_rectangleGarmentMesh; | ||||
| 	b3GarmentClothMesh m_rectangleClothMesh; | ||||
| }; | ||||
|  | ||||
| #endif | ||||
		Reference in New Issue
	
	Block a user