Skip to content

const entt::registry& produces edges in entt::organizer #1258

Open
@obfuscate

Description

@obfuscate

Hello there! I found a strange behavior. Let's consider the following example:

struct CompA {};
struct CompB {};
struct CompC {};

struct System0
{
	using View = entt::view<entt::get_t<const CompA>>;

	void tick(View view) {}
};
struct System1
{
	using View = entt::view<entt::get_t<const CompB>>;

	void tick(View view) {}
};
struct System2
{
	using View = entt::view<entt::get_t<const CompC>>;

	void tick(View view) {}
};

int main(int argc, char* argv[])
{
	System0 sys0;
	System1 sys1;
	System2 sys2;

	entt::organizer organizer;
	organizer.emplace<&System0::tick>(sys0, "sys0");
	organizer.emplace<&System1::tick>(sys1, "sys1");
	organizer.emplace<&System2::tick>(sys2, "sys2");

	auto graph = organizer.graph();
	for (auto&& node : graph)
	{
		auto tl = node.top_level(); //-- all nodes are top level and haven't got "in" edges.
	}

	return 0;
}

Now, let's add const entt::registry& to the methods, like this:

struct CompA {};
struct CompB {};
struct CompC {};

struct System0
{
	using View = entt::view<entt::get_t<const CompA>>;

	void tick(const entt::registry& reg, View view) {}
};
struct System1
{
	using View = entt::view<entt::get_t<const CompB>>;

	void tick(const entt::registry& reg, View view) {}
};
struct System2
{
	using View = entt::view<entt::get_t<const CompC>>;

	void tick(const entt::registry& reg, View view) {}
};

int main(int argc, char* argv[])
{
	System0 sys0;
	System1 sys1;
	System2 sys2;

	entt::organizer organizer;
	organizer.emplace<&System0::tick>(sys0, "sys0");
	organizer.emplace<&System1::tick>(sys1, "sys1");
	organizer.emplace<&System2::tick>(sys2, "sys2");

	auto graph = organizer.graph();
	for (auto&& node : graph)
	{
		auto tl = node.top_level(); //-- now, only the sys0 is top level, but sys1 and sys2 aren't + they have got an input edge.
	}
	return 0;
}

Metadata

Metadata

Assignees

Labels

bugaccepted bugssolvedavailable upstream or in a branch

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions