Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Property wrongly updated after unlinking it #21

Closed
webermm opened this issue Jan 18, 2021 · 1 comment
Closed

Property wrongly updated after unlinking it #21

webermm opened this issue Jan 18, 2021 · 1 comment

Comments

@webermm
Copy link

webermm commented Jan 18, 2021

Node property is updated by LogicEngine::update() call even after it has been unlinked.

The last EXPECT_EQ in the test below fails.

std::vector<float> get_node_translation(ramses::Node* node) {
	float x, y, z;
	node->getTranslation(x, y, z);
	return {x, y, z};
}

TEST(ramses_logic, linkUnlink_nodeBinding_single) {
	rlogic::LogicEngine logicEngine;
	ramses::RamsesFramework ramsesFramework;
	ramses::RamsesClient& client = *ramsesFramework.createClient("example client");
	ramses::Scene* scene = client.createScene(ramses::sceneId_t(123u), ramses::SceneConfig(), "some scene");
	ramses::Node* node = scene->createNode("some node");

	auto* outScript = logicEngine.createLuaScriptFromSource(R"(
function interface()
	IN.in_float = FLOAT
    OUT.out_vec3f = VEC3F
end

function run()
	OUT.out_vec3f = { IN.in_float, 0.0, 0.0 }
end
)");

	auto* binding = logicEngine.createRamsesNodeBinding("some node binding");
	binding->setRamsesNode(node);

	const rlogic::Property* nodeTranslation{binding->getInputs()->getChild("translation")};
	ASSERT_TRUE(nodeTranslation != nullptr);
	const rlogic::Property* scriptOutVec3f{outScript->getOutputs()->getChild("out_vec3f")};
	ASSERT_TRUE(scriptOutVec3f != nullptr);

	ASSERT_TRUE(logicEngine.link(*scriptOutVec3f, *nodeTranslation));
	outScript->getInputs()->getChild("in_float")->set(1.0f);

	ASSERT_TRUE(logicEngine.update());
	EXPECT_EQ(get_node_translation(node), std::vector<float>({1.0, 0.0, 0.0}));

	ASSERT_TRUE(logicEngine.unlink(*scriptOutVec3f, *nodeTranslation));

	node->setTranslation(2.0, 3.0, 4.0);
	EXPECT_EQ(get_node_translation(node), std::vector<float>({2.0, 3.0, 4.0}));

	ASSERT_TRUE(logicEngine.update());
	EXPECT_EQ(get_node_translation(node), std::vector<float>({2.0, 3.0, 4.0}));
}
@violinyanev
Copy link
Member

Should be fixed since v0.4.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants