physics: rigid body drive API (force/impulse/torque/velocity)
PhysicsWorld facade methods addressed by entity bits via body records: AddForce/AddImpulse/AddTorque (dynamic bodies only, auto-wake), Set/ GetLinearVelocity/SetAngularVelocity (dynamic + kinematic). Inspector RigidBody block gains impulse debug controls for manual response tests. Transient by design — nothing serialized.
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include "InspectorPanel.h"
|
||||
#include "Engine/ECS/Components.h"
|
||||
#include "Engine/Renderer/Model.h"
|
||||
#include "Engine/Physics/PhysicsWorld.h" // Apply Impulse 调试(GetPhysics 门面)
|
||||
|
||||
#include <imgui.h>
|
||||
|
||||
@@ -263,6 +264,16 @@ void InspectorPanel::Draw(const EditorContext& ctx, entt::entity selected)
|
||||
{
|
||||
ImGui::Text("vel: %.2f, %.2f, %.2f m/s",
|
||||
rb->velocity.x, rb->velocity.y, rb->velocity.z);
|
||||
|
||||
// 驱动调试(冲量瞬态不序列化):直接推一把看响应
|
||||
static glm::vec3 s_debugImpulse{0.0f, 5.0f, 0.0f};
|
||||
ImGui::DragFloat3("impulse", &s_debugImpulse.x, 0.1f);
|
||||
if (ImGui::Button("Apply Impulse"))
|
||||
{
|
||||
ctx.app->GetPhysics().AddImpulse(
|
||||
static_cast<uint32_t>(entt::to_integral(selected)),
|
||||
s_debugImpulse);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user