Skip to content

Commit

Permalink
crash fix; animation controller - correct return type in compare node
Browse files Browse the repository at this point in the history
  • Loading branch information
nem0 committed Sep 8, 2023
1 parent c84138c commit 0256bec
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/animation/editor/controller_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ struct ControllerEditorImpl : ControllerEditor, AssetBrowser::IPlugin, AssetComp
ImGui::Columns();
if (ImGuiEx::IconButton(ICON_FA_PLUS_CIRCLE, "Add animation")) {
Controller::AnimationEntry& entry = m_controller.m_animation_entries.emplace();
entry.animation = nullptr;
entry.animation = Path();
entry.set = set_idx;
entry.slot = 0;
saveUndo(true);
Expand Down
15 changes: 15 additions & 0 deletions src/animation/editor/editor_nodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,8 +644,23 @@ anim::Node* MathNode::compile(anim::Controller& controller) {
}
}

static bool isCompare(anim::NodeType type) {
switch (type) {
case anim::NodeType::CMP_EQ:
case anim::NodeType::CMP_GT:
case anim::NodeType::CMP_GTE:
case anim::NodeType::CMP_LT:
case anim::NodeType::CMP_LTE:
case anim::NodeType::CMP_NEQ:
return true;
default:
return false;
}
}

anim::Value::Type MathNode::getReturnType() {
ValueNode* input0 = castToValueNode(getInput(0));
if (isCompare(m_type)) return anim::Value::BOOL;
if (!input0) return anim::Value::NUMBER;
return input0->getReturnType();
}
Expand Down
4 changes: 2 additions & 2 deletions src/engine/path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ bool Path::operator!=(const char* rhs) const {
}

bool Path::operator==(const Path& rhs) const {
ASSERT(equalIStrings(m_path, rhs.m_path) == (m_hash == rhs.m_hash));
ASSERT(equalStrings(m_path, rhs.m_path) == (m_hash == rhs.m_hash));
return m_hash == rhs.m_hash;
}

bool Path::operator!=(const Path& rhs) const {
ASSERT(equalIStrings(m_path, rhs.m_path) == (m_hash == rhs.m_hash));
ASSERT(equalStrings(m_path, rhs.m_path) == (m_hash == rhs.m_hash));
return m_hash != rhs.m_hash;
}

Expand Down
2 changes: 1 addition & 1 deletion src/engine/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ LUMIX_ENGINE_API int stringLength(const char* str);

struct StringView {
StringView() {}
StringView(const char* str) : begin(str), end(str + stringLength(str)) {}
StringView(const char* str) : begin(str), end(str ? str + stringLength(str) : 0) {}
StringView(const char* str, u32 len) : begin(str), end(str + len) {}
StringView(const char* begin, const char* end) : begin(begin), end(end) {}
template <int N> StringView(const StaticString<N>& str);
Expand Down
6 changes: 6 additions & 0 deletions src/physics/physics_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,12 @@ struct PhysicsModuleImpl final : PhysicsModule
}
m_joints.clear();

// we have to reset mesh of rigid actor before calling m_actors.clear
// because ~RigidActor accesses m_actors, which might already contain invalid values in m_actors.clear()
for (RigidActor& a : m_actors) {
a.setMesh(nullptr);
}

m_actors.clear();
m_dynamic_actors.clear();

Expand Down

0 comments on commit 0256bec

Please sign in to comment.