AxisAlignedBoxSceneQuery not work for Light? Topic is solved

Problems building or running the engine, queries about how to use features etc.
Post Reply
focai
Gnoblar
Posts: 8
Joined: Tue Jan 11, 2022 11:29 am

AxisAlignedBoxSceneQuery not work for Light?

Post by focai »

Ogre Version: 13.3.0 (Tsathoggua)
Operating System: Ubuntu 20.04
Render System: OpenGL Rendering Subsystem

I create a AxisAlignedBoxSceneQuery in my scenemanager, and place a light into it, but the query result is not contain the light :!: :|
How do i get Lights by a scene query :?:

Code: Select all

	Light *l = sm->createLight("main_light");
   	l->setType(Light::LT_POINT);
	light_node->setPosition(Vector3(50));
	light_node->attachObject(l);

	const unsigned int QM_LIGHT = 0x3232;
	l->setQueryFlags(QM_LIGHT);

	AxisAlignedBox aab(-Vector3(10), Vector3(100));
	AxisAlignedBoxSceneQuery *light_query = sm->createAABBQuery(aab, QM_LIGHT);
	SceneQueryResult &results = light_query->execute();

	if (results.movables.size()) {
		for (auto &m : results.movables) {
			if (m->getQueryFlags() != 0xffffffff) {
				if ((m->getQueryFlags() & QM_LIGHT) == QM_LIGHT) {
					printf("find! -- %s\n", m->getName().c_str());
				} else {
					puts("find unkown!");
				}
			}
		}
	} else {
		puts("empty!");
	}
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: AxisAlignedBoxSceneQuery not work for Light?

Post by paroj »

you additionally need to set the querytypemask to include lights
https://ogrecave.github.io/ogre/api/lat ... a2cac7ce42
focai
Gnoblar
Posts: 8
Joined: Tue Jan 11, 2022 11:29 am

Re: AxisAlignedBoxSceneQuery not work for Light?

Post by focai »

paroj wrote: Sat Jan 15, 2022 6:32 pm you additionally need to set the querytypemask to include lights
https://ogrecave.github.io/ogre/api/lat ... a2cac7ce42
Thanks :!: :!:
I add following code but it still not work, the query result is not contains light.

Code: Select all

	light_query->setQueryTypeMask(SceneManager::LIGHT_TYPE_MASK);
It seems that light.getWorldBoundingBox()(inherited from MovableObject) fuction returns AxisAlignedBox is NULL.
And the following assertion fails.

Code: Select all

assert(l->getWorldBoundingBox().isNull() == false);
That lead to the query failed.
https://github.com/OGRECave/ogre/blob/0 ... Box.h#L530

Is this a problem?
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: AxisAlignedBoxSceneQuery not work for Light?

Post by paroj »

it seems we never compute the extents for Light objects:
https://github.com/OGRECave/ogre/blob/f ... t.cpp#L275

can you open an issue for this on github specifying what you want to use the query for? This way we can plan how to add support for this.

The closest implemented function for this is:
https://ogrecave.github.io/ogre/api/lat ... 516ebd97ef

however, it cannot be used in queries
focai
Gnoblar
Posts: 8
Joined: Tue Jan 11, 2022 11:29 am

Re: AxisAlignedBoxSceneQuery not work for Light?

Post by focai »

paroj wrote: Sun Jan 16, 2022 3:19 pm it seems we never compute the extents for Light objects:
https://github.com/OGRECave/ogre/blob/f ... t.cpp#L275

can you open an issue for this on github specifying what you want to use the query for? This way we can plan how to add support for this.

The closest implemented function for this is:
https://ogrecave.github.io/ogre/api/lat ... 516ebd97ef

however, it cannot be used in queries
Thanks for your reply :!: :!:

I have opened the issues here:
https://github.com/OGRECave/ogre/issues/2355

It seems that scene query make no sense for directional light, because directional light has no position, but point and spot light has position.
So maybe point and spot light could be regarded as a point when is involved scene query, otherwise they should have a little AxisAlignedBox extent,
so that to participate in the scene query.
Post Reply