fixed ragdoll gizmo - fixes #1107
This commit is contained in:
parent
0ead4dd116
commit
7c0eb70b95
7 changed files with 40 additions and 14 deletions
|
@ -1429,19 +1429,24 @@ public:
|
|||
}
|
||||
|
||||
|
||||
void inputFrame() override
|
||||
{
|
||||
m_mouse_rel_x = m_mouse_rel_y = 0;
|
||||
for (auto& i : m_is_mouse_click) i = false;
|
||||
}
|
||||
|
||||
|
||||
void update() override
|
||||
{
|
||||
PROFILE_FUNCTION();
|
||||
updateGoTo();
|
||||
|
||||
m_mouse_rel_x = m_mouse_rel_y = 0;
|
||||
if (!m_selected_entities.empty())
|
||||
{
|
||||
m_gizmo->add(m_selected_entities[0]);
|
||||
}
|
||||
|
||||
createEditorLines();
|
||||
for (auto& i : m_is_mouse_click) i = false;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -136,6 +136,7 @@ public:
|
|||
virtual void removeArrayPropertyItem(const ComponentUID& cmp, int index, IArrayDescriptor& property) = 0;
|
||||
virtual bool isMouseDown(MouseButton::Value button) const = 0;
|
||||
virtual bool isMouseClick(MouseButton::Value button) const = 0;
|
||||
virtual void inputFrame() = 0;
|
||||
virtual void onMouseDown(int x, int y, MouseButton::Value button) = 0;
|
||||
virtual void onMouseMove(int x, int y, int relx, int rely) = 0;
|
||||
virtual void onMouseUp(int x, int y, MouseButton::Value button) = 0;
|
||||
|
|
|
@ -810,6 +810,11 @@ struct StudioAppPlugin LUMIX_FINAL : public StudioApp::IPlugin
|
|||
ImGui::SameLine();
|
||||
auto* root = phy_scene->getRagdollRootBone(cmp);
|
||||
if (ImGui::Button("All kinematic")) phy_scene->setRagdollBoneKinematicRecursive(root, true);
|
||||
PhysicsScene::BoneOrientation new_bone_orientation = phy_scene->getNewBoneOrientation();
|
||||
if (ImGui::Combo("New bone orientation", (int*)&new_bone_orientation, "X\0Y\0"))
|
||||
{
|
||||
phy_scene->setNewBoneOrientation(new_bone_orientation);
|
||||
}
|
||||
|
||||
if (ImGui::BeginChild("bones", ImVec2(ImGui::GetContentRegionAvailWidth() * 0.5f, 0)))
|
||||
{
|
||||
|
|
|
@ -1693,7 +1693,7 @@ struct PhysicsSceneImpl LUMIX_FINAL : public PhysicsScene
|
|||
Transform getRagdollBoneTransform(RagdollBone* bone) override
|
||||
{
|
||||
auto px_pose = bone->actor->getGlobalPose();
|
||||
return {fromPhysx(px_pose.p), fromPhysx(px_pose.q)};
|
||||
return fromPhysx(px_pose);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2009,14 +2009,23 @@ struct PhysicsSceneImpl LUMIX_FINAL : public PhysicsScene
|
|||
}
|
||||
|
||||
Matrix mtx = bone.transform.toMatrix();
|
||||
Vec3 x = mtx.getXVector();
|
||||
mtx.setXVector(-mtx.getYVector());
|
||||
mtx.setYVector(x);
|
||||
mtx.setTranslation(mtx.getTranslation() - mtx.getXVector() * length * 0.5f);
|
||||
if (m_new_bone_orientation == BoneOrientation::X)
|
||||
{
|
||||
Vec3 x = mtx.getXVector();
|
||||
mtx.setXVector(-mtx.getYVector());
|
||||
mtx.setYVector(x);
|
||||
mtx.setTranslation(mtx.getTranslation() - mtx.getXVector() * length * 0.5f);
|
||||
return mtx.toTransform();
|
||||
}
|
||||
mtx.setTranslation(mtx.getTranslation() + mtx.getXVector() * length * 0.5f);
|
||||
return mtx.toTransform();
|
||||
}
|
||||
|
||||
|
||||
BoneOrientation getNewBoneOrientation() const override { return m_new_bone_orientation; }
|
||||
void setNewBoneOrientation(BoneOrientation orientation) override { m_new_bone_orientation = orientation; }
|
||||
|
||||
|
||||
RagdollBone* createRagdollBone(ComponentHandle cmp, u32 bone_name_hash) override
|
||||
{
|
||||
auto* render_scene = static_cast<RenderScene*>(m_universe.getScene(RENDERER_HASH));
|
||||
|
@ -4294,6 +4303,7 @@ struct PhysicsSceneImpl LUMIX_FINAL : public PhysicsScene
|
|||
Universe& m_universe;
|
||||
Engine* m_engine;
|
||||
ContactCallback m_contact_callback;
|
||||
BoneOrientation m_new_bone_orientation = BoneOrientation::X;
|
||||
PxScene* m_scene;
|
||||
LuaScriptScene* m_script_scene;
|
||||
PhysicsSystem* m_system;
|
||||
|
|
|
@ -62,6 +62,11 @@ public:
|
|||
CAPSULE,
|
||||
SPHERE
|
||||
};
|
||||
enum class BoneOrientation : int
|
||||
{
|
||||
X,
|
||||
Y
|
||||
};
|
||||
|
||||
static PhysicsScene* create(PhysicsSystem& system, Universe& context, Engine& engine, IAllocator& allocator);
|
||||
static void destroy(PhysicsScene* scene);
|
||||
|
@ -175,6 +180,8 @@ public:
|
|||
virtual bool isControllerTouchingDown(ComponentHandle cmp) = 0;
|
||||
virtual void resizeController(ComponentHandle cmp, float height) = 0;
|
||||
|
||||
virtual BoneOrientation getNewBoneOrientation() const = 0;
|
||||
virtual void setNewBoneOrientation(BoneOrientation orientation) = 0;
|
||||
virtual RagdollBone* createRagdollBone(ComponentHandle cmp, u32 bone_name_hash) = 0;
|
||||
virtual void destroyRagdollBone(ComponentHandle cmp, RagdollBone* bone) = 0;
|
||||
virtual physx::PxJoint* getRagdollBoneJoint(RagdollBone* bone) const = 0;
|
||||
|
|
|
@ -328,6 +328,8 @@ void SceneView::onGUI()
|
|||
title = "Scene View | errors in log###Scene View";
|
||||
}
|
||||
|
||||
m_editor->inputFrame();
|
||||
|
||||
if (ImGui::BeginDock(title, nullptr, ImGuiWindowFlags_NoScrollWithMouse))
|
||||
{
|
||||
m_is_opened = true;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "engine/array.h"
|
||||
#include "engine/blob.h"
|
||||
#include "engine/crc32.h"
|
||||
#include "engine/engine.h"
|
||||
#include "engine/fs/file_system.h"
|
||||
#include "engine/geometry.h"
|
||||
#include "engine/json_serializer.h"
|
||||
|
@ -21,11 +22,8 @@
|
|||
#include "engine/resource_manager_base.h"
|
||||
#include "engine/serializer.h"
|
||||
#include "engine/timer.h"
|
||||
|
||||
#include "engine/engine.h"
|
||||
|
||||
#include "engine/universe/universe.h"
|
||||
#include "lua_script/lua_script_system.h"
|
||||
|
||||
#include "renderer/culling_system.h"
|
||||
#include "renderer/frame_buffer.h"
|
||||
#include "renderer/material.h"
|
||||
|
@ -39,10 +37,8 @@
|
|||
#include "renderer/terrain.h"
|
||||
#include "renderer/texture.h"
|
||||
#include "renderer/texture_manager.h"
|
||||
|
||||
#include "engine/universe/universe.h"
|
||||
#include <cmath>
|
||||
#include <cfloat>
|
||||
#include <cmath>
|
||||
|
||||
|
||||
namespace Lumix
|
||||
|
|
Loading…
Reference in a new issue