Просмотр исходного кода

Fixed Bone::getName not parsing properly into bindings, fixed scaled 3d objects not being tracked properly by the 3d physics module, fixed some mesh generation stuff broken by mesh rewrite

Ivan Safrin 11 лет назад
Родитель
Сommit
d4cc4f457f

+ 1 - 1
Core/Contents/Include/PolyBone.h

@@ -47,7 +47,7 @@ namespace Polycode {
 			* Returns the name of the bone.
 			* @return Name of the bone.
 			*/
-			const String& getName() const;
+			String getName() const;
 
 			/**
 			* Sets the parent bone of this bone.

+ 3 - 0
Core/Contents/Include/PolyEntity.h

@@ -524,6 +524,9 @@ namespace Polycode {
 			*/
 			Quaternion getRotationQuat() const;
 			
+        
+            Quaternion getConcatenatedQuat() const;
+        
 			/**
 			* Orients the entity towards the specified location with the provided up vector. The up vector determines which side of the entity will be pointing in that direction.
 			* @param loc Location to look at.

+ 1 - 1
Core/Contents/Source/PolyBone.cpp

@@ -130,6 +130,6 @@ void Bone::setRestMatrix(const Matrix4& matrix) {
 	restMatrix = matrix;
 }
 
-const String& Bone::getName() const {
+String Bone::getName() const {
 	return boneName;
 }

+ 8 - 0
Core/Contents/Source/PolyEntity.cpp

@@ -708,6 +708,14 @@ Quaternion Entity::getRotationQuat() const {
 	return rotationQuat;
 }
 
+Quaternion Entity::getConcatenatedQuat() const {
+    if(parentEntity ) {
+        return rotationQuat * parentEntity->getConcatenatedQuat();
+    } else {
+        return rotationQuat;
+    }
+}
+
 Vector3 Entity::getScale() const {
 	return scale;
 }

+ 5 - 0
Core/Contents/Source/PolyMesh.cpp

@@ -753,6 +753,7 @@ void Mesh::subdivideToRadius(Number radius, int subdivisions)
 			else {
 				vmi01 = vertexPositionArray.data.size()/3;
 				addVertex(vm01.x, vm01.y, vm01.z);
+                addTexCoord(0.0, 0.0);
 				dividedEdges[key01] = vmi01;
 			}
 			EdgeSet::iterator it12 = dividedEdges.find(key12);
@@ -763,6 +764,7 @@ void Mesh::subdivideToRadius(Number radius, int subdivisions)
 			else {
 				vmi12 = vertexPositionArray.data.size()/3;
 				addVertex(vm12.x, vm12.y, vm12.z);
+                addTexCoord(0.0, 0.0);
 				dividedEdges[key12] = vmi12;
 			}
 			EdgeSet::iterator it20 = dividedEdges.find(key20);
@@ -773,6 +775,7 @@ void Mesh::subdivideToRadius(Number radius, int subdivisions)
 			else {
 				vmi20 = vertexPositionArray.data.size()/3;
 				addVertex(vm20.x, vm20.y, vm20.z);
+                addTexCoord(0.0, 0.0);                
 				dividedEdges[key20] = vmi20;
 			}
 
@@ -808,6 +811,7 @@ void Mesh::createOctosphere(Number radius, int subdivisions) {
 		Vector3 v = n * radius;
 		addVertex(v.x, v.y, v.z);
         addNormal(n.x, n.y, n.z);
+        addTexCoord(0.0, 0.0);
 	}
 
 	addIndexedFace(0, 4, 2);
@@ -854,6 +858,7 @@ void Mesh::createIcosphere(Number radius, int subdivisions) {
 		Vector3 v = n * radius;
 		addVertex(v.x, v.y, v.z);
         addNormal(n.x, n.y, n.z);
+        addTexCoord(0.0, 0.0);
 	}
 
 	addIndexedFace(0, 11, 5);

+ 2 - 1
Modules/Contents/3DPhysics/Source/PolyCollisionSceneEntity.cpp

@@ -145,7 +145,8 @@ btCollisionShape *CollisionEntity::createCollisionShape(Entity *entity, int type
 		break;
 	}
     
-   // collisionShape->setLocalScaling(btVector3(scale.x, scale.y, scale.z));
+    
+    //collisionShape->setLocalScaling(btVector3(scale.x, scale.y, scale.z));
     
 	return collisionShape; 
 }

+ 1 - 0
Modules/Contents/3DPhysics/Source/PolyPhysicsScene.cpp

@@ -86,6 +86,7 @@ void PhysicsScene::initPhysicsScene(Vector3 size) {
 	broadphase = new btDbvtBroadphase();	
 	physicsWorld = new btDiscreteDynamicsWorld(dispatcher,broadphase,solver,collisionConfiguration);
 	
+    
 //	physicsWorld->getSolverInfo().m_solverMode |= SOLVER_RANDMIZE_ORDER;
 	physicsWorld->setGravity(btVector3(0,-10,0));
 	axisSweep->getOverlappingPairCache()->setInternalGhostPairCallback(new btGhostPairCallback());

+ 6 - 13
Modules/Contents/3DPhysics/Source/PolyPhysicsSceneEntity.cpp

@@ -185,22 +185,15 @@ PhysicsEntity::PhysicsEntity(Entity *entity, int type, Number mass, Number frict
     enabled = true;
 	this->mass = mass;
 	btVector3 localInertia(0,0,0);
-	Vector3 pos = entity->getPosition();	
 	btTransform transform;
-	transform.setIdentity();		
-	/*
+	transform.setIdentity();
+    
+	Matrix4 ent_mat = entity->getConcatenatedMatrix();
+    Vector3 pos = ent_mat * Vector3(0.0, 0.0, 0.0);
 	transform.setOrigin(btVector3(pos.x,pos.y,pos.z));
-	Quaternion q = entity->getRotationQuat();
+    
+	Quaternion q = entity->getConcatenatedQuat();
 	transform.setRotation(btQuaternion(q.x,q.y,q.z,q.w));
-	*/
-	entity->rebuildTransformMatrix();
-	Matrix4 ent_mat = entity->getConcatenatedMatrix();
-	
-	btScalar mat[16];
-	for(int i=0; i < 16; i++) {
-		mat[i] = ent_mat.ml[i];
-	}	
-	transform.setFromOpenGLMatrix(mat);	
 	
 	if(mass != 0.0f) {
 		shape->calculateLocalInertia(mass,localInertia);