私は現在、私の世界で物理をシミュレートするためにBullet Physicsを使用しています。今、私はApplyForceで動くことができる制御可能なプレーヤーを持っていますが、回転する能力はまだありません。Bullet物理学 - 角度係数が適用されません
しかし、私はY軸(ピッチ)に角運動をロックし、動作していないよう:
初期化時:
また// Player.cpp
m_physicsBodyComp->LockRotation({0.f, 1.f, 0.f});
// PhysicsBodyComponent.cpp
void tse::PhysicsBodyComponent::LockRotation(const TSVector3 & a_axis) {
if(m_rigidBody)
m_rigidBody->setAngularFactor(btVector3(a_axis.GetX(), a_axis.GetY(), a_axis.GetZ()));
}
、あまりにも問題を引き起こすかもしれないもの:物理シミュレーションの前に私は剛体の変換を私の変換コンポーネントの変換に設定し、物理シミュレーション後に変換コンポーネントの変換を剛体変換に設定しました。
// Before physics simulation
void tse::PhysicsBodyComponent::UpdateTransformComponent() {
if(m_rigidBody) {
if(m_transformComponent->m_wasDirty && m_transformComponent->IsValid()) {
btQuaternion _quat;
_quat.setEuler(m_transformComponent->m_rotation.GetY(), m_transformComponent->m_rotation.GetX(), m_transformComponent->m_rotation.GetZ());
btTransform _trans;
_trans.setRotation(_quat);
_trans.setOrigin(m_transformComponent->m_position.GetVecBt());
m_rigidBody->setWorldTransform(_trans);
m_transformComponent->m_wasDirty = false;
Activate();
}
}
}
// After physics simulation
void tse::PhysicsBodyComponent::Update(float a_deltaTime) {
if(m_rigidBody) {
if(m_bodyType == PhysicsBodyType::DYNAMIC) {
btTransform & _trans = m_rigidBody->getWorldTransform();
DirectX::XMVECTOR _rotation;
btQuaternion _quat = _trans.getRotation();
_rotation.m128_f32[0] = _quat.getX();
_rotation.m128_f32[1] = _quat.getY();
_rotation.m128_f32[2] = _quat.getZ();
m_transformComponent->SetPosition(TSVector3(_trans.getOrigin()));
m_transformComponent->SetRotation(_rotation);
}
}
}
そこで、問題は、私はx及びz軸の回転をロックすることであるが、それでも(問題のGIFを下記に示す)は、x及びz軸の回転を変化させます。私が以前に言ったように、私はまだプレーヤーの回転ではない。以下のGIFで見られる回転は全て、Bullet Physicsによって完全に行われます。私はAddForceでプレイヤーを移動するだけです。
私は何か完全に間違っているのですか?これはBullet物理学の既知のバグですか?前もって感謝します..!