Skip to content

Commit

Permalink
Release v1.1.2.
Browse files Browse the repository at this point in the history
  • Loading branch information
webermm committed Aug 12, 2022
1 parent 030751c commit 6f21455
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 31 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ If a copy of the MPL was not distributed with this file, You can obtain one at h
-->

## [1.1.2] Lua Interface Naming Bugfix

### Fixes
* Change names of LuaInterface objects in the LogicEngine to match the conventions used for LuaScripts. In particular
* LuaInterface objects outside any PrefabInstance use the LuaInterface name in the LogicEngine.
* LuaInterfaces which are direct children of a non-nested PrefabInstance are named `<PrefabInstance name>.<LuaInterface name>`
* All other LuaInterfaces have the object ID of the LuaInterface object appended `<LuaInterface name>-<LuaInterface object ID>`.


## [1.1.1] Lua Interface, Timer, and Animation Bugfixes

### Fixes
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ cmake_minimum_required(VERSION 3.19)

SET(CMAKE_CONFIGURATION_TYPES "Debug;RelWithDebInfo")

project(RaCoOS VERSION 1.1.1)
project(RaCoOS VERSION 1.1.2)

SET(RACO_RELEASE_DIRECTORY ${CMAKE_BINARY_DIR}/release)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,16 @@ class LuaInterfaceAdaptor : public UserTypeObjectAdaptor<user_types::LuaInterfac
bool sync(core::Errors* errors) override;

private:
void setupParentSubscription();
std::string generateRamsesObjectName() const;

ramses_base::RamsesLuaInterface ramsesInterface_;

components::Subscription subscription_;
components::Subscription nameSubscription_;
components::Subscription inputSubscription_;
components::Subscription childrenSubscription_;
components::Subscription parentNameSubscription_;
components::Subscription linksLifecycleSubscription_;
components::Subscription linkValidityChangeSubscription_;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
#include "ramses_adaptor/LuaInterfaceAdaptor.h"

#include "utils/FileUtils.h"
#include "core/PrefabOperations.h"
#include "core/Queries.h"
#include "user_types/PrefabInstance.h"

namespace raco::ramses_adaptor {

Expand All @@ -28,6 +30,13 @@ LuaInterfaceAdaptor::LuaInterfaceAdaptor(SceneAdaptor* sceneAdaptor, std::shared
tagDirty();
recreateStatus_ = true;
})},
childrenSubscription_(sceneAdaptor_->dispatcher()->registerOnPropertyChange("children", [this](core::ValueHandle handle) {
if (parent_ != editorObject_->getParent()) {
setupParentSubscription();
tagDirty();
recreateStatus_ = true;
}
})),
linksLifecycleSubscription_{sceneAdaptor_->dispatcher()->registerOnLinksLifeCycle(
[this](const core::LinkDescriptor& link) {
if (sceneAdaptor_->optimizeForExport() && (link.start.object() == editorObject_ || link.end.object() == editorObject_)) {
Expand All @@ -47,6 +56,20 @@ LuaInterfaceAdaptor::LuaInterfaceAdaptor(SceneAdaptor* sceneAdaptor, std::shared
recreateStatus_ = true;
}
})} {
setupParentSubscription();
}

void LuaInterfaceAdaptor::setupParentSubscription() {
parent_ = editorObject_->getParent();

if (parent_ && parent_->as<user_types::PrefabInstance>()) {
parentNameSubscription_ = sceneAdaptor_->dispatcher()->registerOn({parent_, &user_types::LuaScript::objectName_}, [this]() {
tagDirty();
recreateStatus_ = true;
});
} else {
parentNameSubscription_ = components::Subscription{};
}
}

void LuaInterfaceAdaptor::getLogicNodes(std::vector<rlogic::LogicNode*>& logicNodes) const {
Expand All @@ -72,7 +95,15 @@ void LuaInterfaceAdaptor::onRuntimeError(core::Errors& errors, std::string const


std::string LuaInterfaceAdaptor::generateRamsesObjectName() const {
return editorObject_->objectName() + "-" + editorObject_->objectID();
auto prefabInstOuter = raco::core::PrefabOperations::findOuterContainingPrefabInstance(editorObject_);
if (prefabInstOuter) {
if (prefabInstOuter == parent_) {
return parent_->objectName() + "." + editorObject_->objectName();
} else {
return editorObject_->objectName() + "-" + editorObject_->objectID();
}
}
return editorObject_->objectName();
}

bool LuaInterfaceAdaptor::sync(core::Errors* errors) {
Expand Down
28 changes: 14 additions & 14 deletions components/libRamsesBase/tests/LinkOptimization_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ TEST_F(LuaLinkOptimizationFixture, link_opt_level_up) {
commandInterface.set({ start, {"inputs", "string"} }, std::string("asdf"));

dispatch();
auto startEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("start-" + start->objectID()).c_str());
auto midEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("mid-" + mid->objectID()).c_str());
auto startEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("start").c_str());
auto midEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("mid").c_str());
auto endEngineObject = select<rlogic::LuaScript>(sceneContext.logicEngine(), std::string("end").c_str());
ASSERT_TRUE(startEngineObject == nullptr);
ASSERT_TRUE(midEngineObject == nullptr);
Expand Down Expand Up @@ -135,8 +135,8 @@ TEST_F(LuaLinkOptimizationFixture, link_opt_level_up) {

dispatch();

startEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("start-" + start->objectID()).c_str());
midEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("mid-" + mid->objectID()).c_str());
startEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("start").c_str());
midEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("mid").c_str());
endEngineObject = select<rlogic::LuaScript>(sceneContext.logicEngine(), std::string("end").c_str());
ASSERT_TRUE(startEngineObject != nullptr);
ASSERT_TRUE(midEngineObject == nullptr);
Expand Down Expand Up @@ -178,8 +178,8 @@ TEST_F(LuaLinkOptimizationFixture, link_opt_level_same) {
commandInterface.set({ start, {"inputs", "string"} }, std::string("asdf"));

dispatch();
auto startEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("start-" + start->objectID()).c_str());
auto midEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("mid-" + mid->objectID()).c_str());
auto startEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("start").c_str());
auto midEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("mid").c_str());
auto endEngineObject = select<rlogic::LuaScript>(sceneContext.logicEngine(), std::string("end").c_str());
ASSERT_TRUE(startEngineObject == nullptr);
ASSERT_TRUE(midEngineObject == nullptr);
Expand Down Expand Up @@ -207,8 +207,8 @@ TEST_F(LuaLinkOptimizationFixture, link_opt_level_same) {

dispatch();

startEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("start-" + start->objectID()).c_str());
midEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("mid-" + mid->objectID()).c_str());
startEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("start").c_str());
midEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("mid").c_str());
endEngineObject = select<rlogic::LuaScript>(sceneContext.logicEngine(), std::string("end").c_str());

ASSERT_TRUE(startEngineObject != nullptr);
Expand Down Expand Up @@ -243,9 +243,9 @@ TEST_F(LuaLinkOptimizationFixture, link_opt_level_down) {
commandInterface.set({ start_b, {"inputs", "float"} }, 2.0);

dispatch();
auto startAEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("start_a-" + start_a->objectID()).c_str());
auto startBEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("start_b-" + start_b->objectID()).c_str());
auto midEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("mid-" + mid->objectID()).c_str());
auto startAEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("start_a").c_str());
auto startBEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("start_b").c_str());
auto midEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("mid").c_str());
auto endEngineObject = select<rlogic::LuaScript>(sceneContext.logicEngine(), std::string("end").c_str());
ASSERT_TRUE(startAEngineObject == nullptr);
ASSERT_TRUE(startBEngineObject == nullptr);
Expand All @@ -258,9 +258,9 @@ TEST_F(LuaLinkOptimizationFixture, link_opt_level_down) {

dispatch();

startAEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("start_a-" + start_a->objectID()).c_str());
startBEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("start_b-" + start_b->objectID()).c_str());
midEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("mid-" + mid->objectID()).c_str());
startAEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("start_a").c_str());
startBEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("start_b").c_str());
midEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("mid").c_str());
endEngineObject = select<rlogic::LuaScript>(sceneContext.logicEngine(), std::string("end").c_str());
ASSERT_TRUE(startAEngineObject != nullptr);
ASSERT_TRUE(startBEngineObject != nullptr);
Expand Down
83 changes: 68 additions & 15 deletions components/libRamsesBase/tests/LuaInterfaceAdaptor_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

#include "RamsesBaseFixture.h"

#include "user_types/Node.h"
#include "user_types/Prefab.h"
#include "user_types/PrefabInstance.h"

#include "ramses_adaptor/LuaInterfaceAdaptor.h"

using namespace raco::user_types;
Expand Down Expand Up @@ -84,28 +88,77 @@ TEST_F(LuaInterfaceAdaptorFixture, valid_text) {
dispatch();
ASSERT_EQ(sceneContext.logicEngine().getCollection<rlogic::LuaInterface>().size(), 1);

auto engineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("interface-" + interface->objectID()).c_str());
auto engineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("interface").c_str());
ASSERT_TRUE(engineObject != nullptr);
ASSERT_EQ(engineObject->getUserId(), interface->objectIDAsRamsesLogicID());
}

TEST_F(LuaInterfaceAdaptorFixture, name_prefab_inst) {
auto interfaceFile = defaultFile();

auto prefab = create<Prefab>("prefab");
auto interface = create_lua_interface("interface", interfaceFile, prefab);

auto inst = create_prefabInstance("inst", prefab);

dispatch();

auto engineObj = select<rlogic::LuaInterface>(sceneContext.logicEngine(), "inst.interface");
ASSERT_TRUE(engineObj != nullptr);

commandInterface.set({inst, &PrefabInstance::objectName_}, std::string("asdf"));
dispatch();

engineObj = select<rlogic::LuaInterface>(sceneContext.logicEngine(), "inst.interface");
ASSERT_TRUE(engineObj == nullptr);
engineObj = select<rlogic::LuaInterface>(sceneContext.logicEngine(), "asdf.interface");
ASSERT_TRUE(engineObj != nullptr);
}

TEST_F(LuaInterfaceAdaptorFixture, name_prefab_inst_nested) {
auto interfaceFile = defaultFile();

auto prefab = create<Prefab>("prefab");
auto interface = create_lua_interface("interface", interfaceFile, prefab);

auto prefab_outer = create<Prefab>("prefab_outer");
auto inst_inner = create_prefabInstance("inst_inner", prefab, prefab_outer);

auto inst = create_prefabInstance("inst", prefab_outer);
auto inst_nested = inst->children_->asVector<SEditorObject>()[0]->as<PrefabInstance>();
auto intf_nested = inst_nested->children_->asVector<SEditorObject>()[0];

dispatch();

auto engineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("interface-" + intf_nested->objectID()).c_str());
ASSERT_TRUE(engineObject != nullptr);

//commandInterface.set({inst, &PrefabInstance::template_}, prefab);
//dispatch();

//engineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("interface-" + intf_nested->objectID()).c_str());
//ASSERT_TRUE(engineObject == nullptr);
//engineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), "inst.interface");
//ASSERT_TRUE(engineObject != nullptr);
}

TEST_F(LuaInterfaceAdaptorFixture, change_name) {
auto interfaceFile = defaultFile();
auto interface = create_lua_interface("interface", interfaceFile);

dispatch();

ASSERT_EQ(sceneContext.logicEngine().getCollection<rlogic::LuaInterface>().size(), 1);
auto engineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("interface-" + interface->objectID()).c_str());
auto engineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("interface").c_str());
ASSERT_TRUE(engineObject != nullptr);
ASSERT_EQ(engineObject->getUserId(), interface->objectIDAsRamsesLogicID());

commandInterface.set({interface, &LuaInterface::objectName_}, std::string("newName"));
dispatch();

ASSERT_EQ(sceneContext.logicEngine().getCollection<rlogic::LuaInterface>().size(), 1);
ASSERT_EQ(select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("interface-" + interface->objectID()).c_str()), nullptr);
engineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("newName-" + interface->objectID()).c_str());
ASSERT_EQ(select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("interface").c_str()), nullptr);
engineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("newName").c_str());
ASSERT_TRUE(engineObject != nullptr);
ASSERT_EQ(engineObject->getUserId(), interface->objectIDAsRamsesLogicID());
}
Expand All @@ -115,7 +168,7 @@ TEST_F(LuaInterfaceAdaptorFixture, change_property_value) {
auto interface = create_lua_interface("interface", interfaceFile);
dispatch();

auto engineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("interface-" + interface->objectID()).c_str());
auto engineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("interface").c_str());

ASSERT_EQ(engineObject->getInputs()->getChild("float")->get<float>(), 0.0);
ASSERT_EQ(engineObject->getInputs()->getChild("vector2f")->get<rlogic::vec2f>().value()[1], 0.0);
Expand Down Expand Up @@ -185,7 +238,7 @@ TEST_F(LuaInterfaceAdaptorFixture, link_invalid_interface_to_invalid_script) {
// test shouldn't crash here
dispatch();

auto ramsesStart = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("start-" + start->objectID()).c_str());
auto ramsesStart = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("start").c_str());
auto ramsesEnd = select<rlogic::LuaScript>(sceneContext.logicEngine(), "end");
EXPECT_EQ(ramsesStart, nullptr);
EXPECT_EQ(ramsesEnd, nullptr);
Expand All @@ -204,8 +257,8 @@ TEST_F(LuaInterfaceAdaptorFixture, link_invalid_interface_to_invalid_interface)
// test shouldn't crash here
dispatch();

auto ramsesStart = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("start-" + start->objectID()).c_str());
auto ramsesEnd = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("end-" + end->objectID()).c_str());
auto ramsesStart = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("start").c_str());
auto ramsesEnd = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("end").c_str());
EXPECT_EQ(ramsesStart, nullptr);
EXPECT_EQ(ramsesEnd, nullptr);

Expand All @@ -225,7 +278,7 @@ TEST_F(LuaInterfaceAdaptorFixture, link_empty_interface_to_empty_script) {
// test shouldn't crash here
dispatch();

auto ramsesStart = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("start-" + start->objectID()).c_str());
auto ramsesStart = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("start").c_str());
auto ramsesEnd = select<rlogic::LuaScript>(sceneContext.logicEngine(), "end");
EXPECT_NE(ramsesStart, nullptr);
EXPECT_NE(ramsesEnd, nullptr);
Expand All @@ -245,8 +298,8 @@ TEST_F(LuaInterfaceAdaptorFixture, link_empty_interface_to_empty_interface) {
// test shouldn't crash here
dispatch();

auto ramsesStart = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("start-" + start->objectID()).c_str());
auto ramsesEnd = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("end-" + end->objectID()).c_str());
auto ramsesStart = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("start").c_str());
auto ramsesEnd = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("end").c_str());
EXPECT_NE(ramsesStart, nullptr);
EXPECT_NE(ramsesEnd, nullptr);

Expand All @@ -272,8 +325,8 @@ TEST_F(LuaInterfaceAdaptorFixture, link_individual_propagate_values) {
commandInterface.set({start, {"inputs", "string"}}, std::string("asdf"));

dispatch();
auto startEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("start-" + start->objectID()).c_str());
auto endEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("end-" + end->objectID()).c_str());
auto startEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("start").c_str());
auto endEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("end").c_str());
ASSERT_TRUE(startEngineObject != nullptr);
ASSERT_TRUE(endEngineObject != nullptr);

Expand Down Expand Up @@ -346,8 +399,8 @@ TEST_F(LuaInterfaceAdaptorFixture, link_container_propagate_values) {
commandInterface.set({start, {"inputs", "string"}}, std::string("asdf"));

dispatch();
auto startEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("start-" + start->objectID()).c_str());
auto endEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("end-" + end->objectID()).c_str());
auto startEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("start").c_str());
auto endEngineObject = select<rlogic::LuaInterface>(sceneContext.logicEngine(), std::string("end").c_str());
ASSERT_TRUE(startEngineObject != nullptr);
ASSERT_TRUE(endEngineObject != nullptr);

Expand Down

0 comments on commit 6f21455

Please sign in to comment.