Skip to content

Commit d4cc4f4

Browse files
committed
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
1 parent 7d86739 commit d4cc4f4

File tree

8 files changed

+27
-16
lines changed

8 files changed

+27
-16
lines changed

Core/Contents/Include/PolyBone.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ namespace Polycode {
4747
* Returns the name of the bone.
4848
* @return Name of the bone.
4949
*/
50-
const String& getName() const;
50+
String getName() const;
5151

5252
/**
5353
* Sets the parent bone of this bone.

Core/Contents/Include/PolyEntity.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,9 @@ namespace Polycode {
524524
*/
525525
Quaternion getRotationQuat() const;
526526

527+
528+
Quaternion getConcatenatedQuat() const;
529+
527530
/**
528531
* 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.
529532
* @param loc Location to look at.

Core/Contents/Source/PolyBone.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,6 @@ void Bone::setRestMatrix(const Matrix4& matrix) {
130130
restMatrix = matrix;
131131
}
132132

133-
const String& Bone::getName() const {
133+
String Bone::getName() const {
134134
return boneName;
135135
}

Core/Contents/Source/PolyEntity.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,14 @@ Quaternion Entity::getRotationQuat() const {
708708
return rotationQuat;
709709
}
710710

711+
Quaternion Entity::getConcatenatedQuat() const {
712+
if(parentEntity ) {
713+
return rotationQuat * parentEntity->getConcatenatedQuat();
714+
} else {
715+
return rotationQuat;
716+
}
717+
}
718+
711719
Vector3 Entity::getScale() const {
712720
return scale;
713721
}

Core/Contents/Source/PolyMesh.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,7 @@ void Mesh::subdivideToRadius(Number radius, int subdivisions)
753753
else {
754754
vmi01 = vertexPositionArray.data.size()/3;
755755
addVertex(vm01.x, vm01.y, vm01.z);
756+
addTexCoord(0.0, 0.0);
756757
dividedEdges[key01] = vmi01;
757758
}
758759
EdgeSet::iterator it12 = dividedEdges.find(key12);
@@ -763,6 +764,7 @@ void Mesh::subdivideToRadius(Number radius, int subdivisions)
763764
else {
764765
vmi12 = vertexPositionArray.data.size()/3;
765766
addVertex(vm12.x, vm12.y, vm12.z);
767+
addTexCoord(0.0, 0.0);
766768
dividedEdges[key12] = vmi12;
767769
}
768770
EdgeSet::iterator it20 = dividedEdges.find(key20);
@@ -773,6 +775,7 @@ void Mesh::subdivideToRadius(Number radius, int subdivisions)
773775
else {
774776
vmi20 = vertexPositionArray.data.size()/3;
775777
addVertex(vm20.x, vm20.y, vm20.z);
778+
addTexCoord(0.0, 0.0);
776779
dividedEdges[key20] = vmi20;
777780
}
778781

@@ -808,6 +811,7 @@ void Mesh::createOctosphere(Number radius, int subdivisions) {
808811
Vector3 v = n * radius;
809812
addVertex(v.x, v.y, v.z);
810813
addNormal(n.x, n.y, n.z);
814+
addTexCoord(0.0, 0.0);
811815
}
812816

813817
addIndexedFace(0, 4, 2);
@@ -854,6 +858,7 @@ void Mesh::createIcosphere(Number radius, int subdivisions) {
854858
Vector3 v = n * radius;
855859
addVertex(v.x, v.y, v.z);
856860
addNormal(n.x, n.y, n.z);
861+
addTexCoord(0.0, 0.0);
857862
}
858863

859864
addIndexedFace(0, 11, 5);

Modules/Contents/3DPhysics/Source/PolyCollisionSceneEntity.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ btCollisionShape *CollisionEntity::createCollisionShape(Entity *entity, int type
145145
break;
146146
}
147147

148-
// collisionShape->setLocalScaling(btVector3(scale.x, scale.y, scale.z));
148+
149+
//collisionShape->setLocalScaling(btVector3(scale.x, scale.y, scale.z));
149150

150151
return collisionShape;
151152
}

Modules/Contents/3DPhysics/Source/PolyPhysicsScene.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ void PhysicsScene::initPhysicsScene(Vector3 size) {
8686
broadphase = new btDbvtBroadphase();
8787
physicsWorld = new btDiscreteDynamicsWorld(dispatcher,broadphase,solver,collisionConfiguration);
8888

89+
8990
// physicsWorld->getSolverInfo().m_solverMode |= SOLVER_RANDMIZE_ORDER;
9091
physicsWorld->setGravity(btVector3(0,-10,0));
9192
axisSweep->getOverlappingPairCache()->setInternalGhostPairCallback(new btGhostPairCallback());

Modules/Contents/3DPhysics/Source/PolyPhysicsSceneEntity.cpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -185,22 +185,15 @@ PhysicsEntity::PhysicsEntity(Entity *entity, int type, Number mass, Number frict
185185
enabled = true;
186186
this->mass = mass;
187187
btVector3 localInertia(0,0,0);
188-
Vector3 pos = entity->getPosition();
189188
btTransform transform;
190-
transform.setIdentity();
191-
/*
189+
transform.setIdentity();
190+
191+
Matrix4 ent_mat = entity->getConcatenatedMatrix();
192+
Vector3 pos = ent_mat * Vector3(0.0, 0.0, 0.0);
192193
transform.setOrigin(btVector3(pos.x,pos.y,pos.z));
193-
Quaternion q = entity->getRotationQuat();
194+
195+
Quaternion q = entity->getConcatenatedQuat();
194196
transform.setRotation(btQuaternion(q.x,q.y,q.z,q.w));
195-
*/
196-
entity->rebuildTransformMatrix();
197-
Matrix4 ent_mat = entity->getConcatenatedMatrix();
198-
199-
btScalar mat[16];
200-
for(int i=0; i < 16; i++) {
201-
mat[i] = ent_mat.ml[i];
202-
}
203-
transform.setFromOpenGLMatrix(mat);
204197

205198
if(mass != 0.0f) {
206199
shape->calculateLocalInertia(mass,localInertia);

0 commit comments

Comments
 (0)