Removed separate controller class
This commit is contained in:
@@ -14,7 +14,8 @@ CharacterModule::CharacterModule(flecs::world &ecs)
|
||||
false });
|
||||
player.set<CharacterBase>(
|
||||
{ "normal-male.glb", nullptr, nullptr, nullptr });
|
||||
player.set<CharacterBody>({});
|
||||
player.set<CharacterBody>(
|
||||
{ nullptr, nullptr, nullptr, { 0, 0, 0 }, false, false });
|
||||
player.add<Character>();
|
||||
player.add<Player>();
|
||||
ecs.system<Input, Camera>("HandleInput")
|
||||
@@ -418,6 +419,47 @@ CharacterModule::CharacterModule(flecs::world &ecs)
|
||||
ch.mBodyNode->yaw(Ogre::Degree(yawToGoal));
|
||||
}
|
||||
});
|
||||
class ClosestNotMeRayResultCallback
|
||||
: public btCollisionWorld::ClosestRayResultCallback {
|
||||
btCollisionObject *mMe;
|
||||
|
||||
public:
|
||||
ClosestNotMeRayResultCallback(btCollisionObject *me,
|
||||
const btVector3 &from,
|
||||
const btVector3 &to)
|
||||
: btCollisionWorld::ClosestRayResultCallback(from, to)
|
||||
{
|
||||
mMe = me;
|
||||
}
|
||||
virtual btScalar
|
||||
addSingleResult(btCollisionWorld::LocalRayResult &rayResult,
|
||||
bool normalInWorldSpace)
|
||||
{
|
||||
if (rayResult.m_collisionObject == mMe)
|
||||
return 1.0f;
|
||||
return ClosestRayResultCallback::addSingleResult(
|
||||
rayResult, normalInWorldSpace);
|
||||
}
|
||||
};
|
||||
ecs.system<const EngineData, CharacterBody>("CheckGround")
|
||||
.kind(flecs::OnUpdate)
|
||||
.with<Character>()
|
||||
.each([](const EngineData &eng, CharacterBody &body) {
|
||||
if (body.checkGround) {
|
||||
btVector3 from =
|
||||
body.mGhostObject->getWorldTransform()
|
||||
.getOrigin() +
|
||||
btVector3(0, 0.2f, 0);
|
||||
btVector3 to = from + btVector3(0, -3000.0f, 0);
|
||||
ClosestNotMeRayResultCallback resultCallback(
|
||||
body.mGhostObject, from, to);
|
||||
body.mGhostObject->rayTest(from, to,
|
||||
resultCallback);
|
||||
body.checkGroundResult =
|
||||
resultCallback.hasHit();
|
||||
body.checkGround = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void CharacterModule::setAnimation(AnimationControl &anim)
|
||||
|
||||
Reference in New Issue
Block a user