That is very valuable advice bstone

To remember that programming and designing software is not about the most elegant or clever solution but the solution that works and is easy to gasp. Software is complex on its own, no need to add to that.
I rewrote parts of the entity system. Here's on example:
Code: Select all
class _PolyExport PhysicsDynamicComponent : public PhysicsComponent {
public:
physx::PxRigidDynamic* rigidDynamic;
PhysicsDynamicComponent();
virtual void initialize(Entity entity, const StringVariantMap& values);
void setKinetic(bool val);
bool isKinematic() const;
POLY_COMPONENT_INFO;
protected:
bool mKinematic;
};
Code: Select all
POLY_COMPONENT_INFO_IMPL(PhysicsDynamicComponent, "PhysicsDynamic", "Physics");
PhysicsDynamicComponent::PhysicsDynamicComponent()
: mKinematic(false) {
mProperties.addProperty("PhysicsDynamic/Kinematic", &mKinematic, true);
}
void PhysicsDynamicComponent::initialize(Entity entity, const StringVariantMap& values) {
PhysicsComponent::initialize(entity, values);
rigidActor = rigidDynamic = gEnv.physics->createDynamicRigidBody(Vector3::ZERO, Quaternion::IDENTITY, entity);
rigidDynamic->setRigidDynamicFlag(physx::PxRigidDynamicFlag::eKINEMATIC, mKinematic);
parseAndCreateShapes(rigidDynamic, mShapeDescription);
gEnv.physics->addRigidBodyToScene(mEntity.getScene(), rigidDynamic);
}
Code: Select all
class PhysicsEntityLogic : public EntityLogic {
public:
PhysicsEntityLogic();
virtual void getComponentTypesOfInterest(ComponentNameSet& typeNames) const;
virtual void updateEntitiesOfInterest(const String& typeName, const EntityList& entities);
protected:
ComponentNameSet mTypeNameOfInterest;
};
Code: Select all
void PhysicsEntityLogic::updateEntitiesOfInterest(const String& typeName, const EntityList& entities) {
BOOST_FOREACH(Entity entity, entities) {
TransformComponent* transformC = entity.getComponent<TransformComponent>();
PhysicsDynamicComponent* physicsC = entity.getComponent<PhysicsDynamicComponent>();
if(transformC && physicsC) {
if(!physicsC->isKinematic()) {
Vector3 position = physicsC->getPosition();
Quaternion orientation = physicsC->getOrientation();
SceneNode* sn = transformC->getSceneNode();
sn->setPosition(position);
sn->setOrientation(orientation);
}
else {
SceneNode* sn = transformC->getSceneNode();
Vector3 position = sn->getPosition();
Quaternion orientation = sn->getOrientation();
physicsC->setPosition(position);
physicsC->setOrientation(orientation);
}
}
}
}
Actually I like the seperation of data (Component) and logic (EntityLogic) much more than the combined model in Unity. In addition to that the model should be faster too. What's missing are bucket updates (tank, then turret) and child/parent relationships, but I don't need either right now.
Please note here that I finally got how I want the engine to behave. It sets up all the stuff needed to get PhysX to run. Creates the scene for you and the dynamic/static actors. Sets up the userdata member to raycast can return the hit Entity to you. But not anything more. You are free to use the original PhysX, no wrapping. In addition to that parts of the code where different people will use different 3rd party libs (scripting, audio, especially gui, ...) are either abstract factories or not included in the engine code. You are free to add them later in the game using the provided architecture.
Would you rewrite the operating system for your project? Ogre is your operating system thing of it like that.
I would love to do that, but ain't nobody got time fo dat.
And if your "C++ scripting" gives up the static type checking - screw it.
That's my biggest problem with scripting these days. Static type checking is just such a great thing, I don't want to live without it. I'm experimenting with AngleScript and Squirrel, but there won't be an implementation in the engine. Scripting is just one of these things where everybody has a different opinion. Maybe I can write an automated wrapper or provide SWIG files.