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

Tested fix

Just a quick update. My code been tested, and now works.
Note: I have not tested Doomlaser's
Paul Smith 13 лет назад
Родитель
Сommit
94b37ae225

+ 3 - 0
Modules/Contents/2DPhysics/Include/PolyPhysicsScreenEntity.h

@@ -99,6 +99,9 @@ namespace Polycode {
             void setCollisionMask(int maskBits);
         
             void setCollisionGroupIndex(int group);
+			
+			b2Fixture* getFixture();			// Gets the last fixture selected (automatically set on creation)			
+			b2Fixture* getFixture(unsigned short index);	// Gets a specific fixture if there is more than one
             
 			/**
 			* Rectangular physics entity

+ 3 - 2
Modules/Contents/2DPhysics/Source/PolyPhysicsScreenEntity.cpp

@@ -35,16 +35,17 @@ PhysicsScreenEntity::PhysicsScreenEntity(ScreenEntity *entity, b2World *world, N
 	
 	screenEntity = entity;
 
+	Vector3 entityScale = entity->getCompoundScale();
+	Matrix4 compoundMatrix = screenEntity->getConcatenatedMatrix();
 	entity->ignoreParentMatrix = true;
 	entity->scale = entityScale;
-	Vector3 entityScale = entity->getCompoundScale();
 	this->worldScale = worldScale;
 	collisionOnly = false;
 
 	
 	// Create body definition---------------------------------------
 	b2BodyDef bodyDef;
-	bodyDef.position.Set(screenEntity->getPosition2D().x/worldScale, screenEntity->getPosition2D().y/worldScale);
+	bodyDef.position.Set(compoundMatrix.getPosition().x/worldScale, compoundMatrix.getPosition().y/worldScale);
 	bodyDef.angle = screenEntity->getRotation()*(PI/180.0f);	
 	bodyDef.bullet = isSensor;	
 	bodyDef.fixedRotation = fixedRotation;