SceneNode::getVisibility() / ::isVisible()

What it says on the tin: a place to discuss proposed new features.
Post Reply
User avatar
Beauty
OGRE Community Helper
OGRE Community Helper
Posts: 767
Joined: Wed Oct 10, 2007 2:36 pm
Location: Germany
Contact:

SceneNode::getVisibility() / ::isVisible()

Post by Beauty » Tue Oct 25, 2011 4:55 pm

For SceneNodes it's possible to set its visibility or to flip its state.

* SceneNode::setVisible (bool visible, bool cascade=true)
* SceneNode::flipVisibility (bool cascade=true)

On the other hand there seems to be no possibility to read the visibility state.
I think it could be usable to add a function to read the visibility flag of a SceneNode.

The ManualObject class still contains such functions:
* ManualObject::getVisible() - Gets this object whether to be visible or not, if it has a renderable component.
* ManualObject::isVisible() - Returns whether or not this object is supposed to be visible or not.

If you think my suggestion is usable, then it would be fine when you add it to Ogre before official release of 1.8.
0 x
Help to add information to the wiki. Also tiny edits will let it grow ... :idea:
Add your country to your profile ... it's interesting to know from where of the world you are.

CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
Contact:

Re: SceneNode::getVisibility() / ::isVisible()

Post by CABAListic » Tue Oct 25, 2011 4:59 pm

This is a shortcut to calling setVisible() on the objects attached to this node, and optionally to all objects attached to child nodes.
SceneNodes don't actually have any information about visibility, they just forward that call to the attached objects. As such, it's problematic to define a getter for visibility on a SceneNode.
0 x

User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
Contact:

Re: SceneNode::getVisibility() / ::isVisible()

Post by Klaim » Tue Oct 25, 2011 6:05 pm

Maybe this function should be named in another way... like setObjectsVisibility() ?

And then you can add a recursive function to check if : bool hasVisibleObjects() ?
If the hierarchy is not insanely deep it should be fast, don't you think?
0 x

User avatar
Beauty
OGRE Community Helper
OGRE Community Helper
Posts: 767
Joined: Wed Oct 10, 2007 2:36 pm
Location: Germany
Contact:

Re: SceneNode::getVisibility() / ::isVisible()

Post by Beauty » Tue Oct 25, 2011 10:38 pm

Thanks CABAListic, now I understand the sense, why there is no getVisibility() function.

I don't know where you did copy your quote, but it would be usable to add it to the official Ogre API description of SceneNode::setVisible().

Its current description is:
setVisible (bool visible, bool cascade=true)
-----> Makes all objects attached to this node become visible / invisible.
I suggest to extend the description and use this:
Makes all objects attached to this node become visible / invisible. It's a shortcut to calling setVisible() on the objects attached to this node, and optionally to all objects attached to child nodes.
If you agree to my suggestion:
Would you like to update the source code, please?
0 x
Help to add information to the wiki. Also tiny edits will let it grow ... :idea:
Add your country to your profile ... it's interesting to know from where of the world you are.

CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
Contact:

Re: SceneNode::getVisibility() / ::isVisible()

Post by CABAListic » Tue Oct 25, 2011 11:48 pm

? I took the quote from the API documentation, so... ;)

http://www.ogre3d.org/docs/api/html/cla ... 28d7c8195e
0 x

User avatar
Beauty
OGRE Community Helper
OGRE Community Helper
Posts: 767
Joined: Wed Oct 10, 2007 2:36 pm
Location: Germany
Contact:

Re: SceneNode::getVisibility() / ::isVisible()

Post by Beauty » Wed Oct 26, 2011 11:05 am

Oh, now I see my own mistake.
I just read the description in the "overview" at the top of the page (instead of the "Detailed Description" section). :lol:
0 x
Help to add information to the wiki. Also tiny edits will let it grow ... :idea:
Add your country to your profile ... it's interesting to know from where of the world you are.

def87
Halfling
Posts: 90
Joined: Wed Sep 19, 2012 1:41 pm

Re: SceneNode::getVisibility() / ::isVisible()

Post by def87 » Tue Jan 07, 2014 6:13 pm

Sorry to revive an old post but I have the same problem...

Why is there still not getVisible() function for SceneNodes?
There IS a flipVisibility() function which internally must do a get/setVisible() to attached objects.
0 x

User avatar
c6burns
Beholder
Posts: 1511
Joined: Fri Feb 22, 2013 4:44 am
Location: Deep behind enemy lines

Re: SceneNode::getVisibility() / ::isVisible()

Post by c6burns » Tue Jan 07, 2014 6:19 pm

Because, as explained above, SceneNodes aren't renderable ... it's the attached objects that are. Also I think just no one ever submitted a patch for this. You could be the one :)

EDIT: Nevermind I was wrong, the setVisible method made it into SceneNode. There's just no getVisible/isVisible but it would be trivial to do and submit a PR
0 x

User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7137
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 6

Re: SceneNode::getVisibility() / ::isVisible()

Post by Kojack » Wed Jan 08, 2014 7:10 am

Similar reason to why there's no getMaterialName on Entities or Meshes, because multiple child objects contain that data, not the one parent object.
If a scene node contains one attached object that's visible and another attached object that's invisible, what should getVisible() return?
0 x

User avatar
c6burns
Beholder
Posts: 1511
Joined: Fri Feb 22, 2013 4:44 am
Location: Deep behind enemy lines

Re: SceneNode::getVisibility() / ::isVisible()

Post by c6burns » Wed Jan 08, 2014 8:48 am

I assumed they want it to return true if any renderables are visible, but I don't rightly understand the use case of any of this myself. I keep hold of the pointers to my renderable stuff and control their visibility like that, which I assume everyone else does as well. While I don't see the harm in a patch, I don't see the use in it either.
0 x

def87
Halfling
Posts: 90
Joined: Wed Sep 19, 2012 1:41 pm

Re: SceneNode::getVisibility() / ::isVisible()

Post by def87 » Wed Jan 08, 2014 11:04 am

Ok, thanks to you guys I have to agree SceneNode::isVisible() makes no sense.

In my use-case there is only one renderable Object attached per node, so I will build my own utility function, something like:

Code: Select all

bool SceneNode::FirstAttachedObjectIsVisible( Ogre::String objecttype )
0 x

User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
Contact:

Re: SceneNode::getVisibility() / ::isVisible()

Post by Klaim » Wed Jan 08, 2014 2:24 pm

Instead of providing these functions in the scene node types, we should just provide algorithms to go through all the graphic objects attached to a node and it's childs and apply a provided callable on them. Provide depth and breadth variants of this algorithm.

That way it is easy to do almost anything with all the objects attached to a node and it's child node's attached objects without having to add functions to the node types each time we need a new function in the entities types.

Of course it's far easier to use if you can use a compiler providing lambdas, but at least you can do it with bind() or mem_fun() if you use a too old compiler.

I don't have enough time to do so but I could try something in the weekend if you don't already see how to do it.
0 x

simedj
Goblin
Posts: 262
Joined: Fri Nov 18, 2011 6:50 pm

Re: SceneNode::getVisibility() / ::isVisible()

Post by simedj » Thu Mar 06, 2014 11:09 am

Kojack wrote:Similar reason to why there's no getMaterialName on Entities or Meshes, because multiple child objects contain that data, not the one parent object.
If a scene node contains one attached object that's visible and another attached object that's invisible, what should getVisible() return?
sceneNode::hasAnyVisible() could be an option. I'm sure many of us have our own utilities with such things.
0 x
Looking to find experienced Ogre & shader developers/artists. PM me with a contact email address if interested.

Post Reply