portals and cells

I’m reading the documentation for PortalNode, which is not complete enough to really tell easily how to use portals in Panda. Here are my current presumptions and understanding. Could you tell me which points are correct or incorrect, and fill in any gaps for me?

Presumptions and Understanding:• Cells are standard PandaNodes and enable or disable rendering for anything within.
• Portals lead between cells, and may only use quads as their cull shapes.
• Portals are one-way, with counterclockwise winding.
• Two opposing portals must be used if the camera is allowed to look from either side.
• Portals know whether they are visible by the current camera transform.
• I must manually traverse my portals and turn cells on and off as necessary.

Questions:• Do cells understand their own bounding geometry, if I call a function like setBounds()?
• How do I use the portal’s setPortalMask(uint32) property? Does this bitmask limit me to 32 cells?
• Do I need to reparent models to cells, or is another relationship between them handled automatically?
• If I move a model or Actor in the world, do I need to do anything to update its visibility state?
• Once portals and cells are created, how do I set them up in the world?
• What else is necessary to use portals?

I believe all of your assumptions are correct, except for:

This might be a small misunderstanding. I believe the design is that you should detach or stash all of your cells (except for the one your avatar is standing within), so that they will not be visited by the normal traversal. The portals will then take care of rendering the cells that they are connected to, even though these cells are not otherwise within the scene graph.

You are, however, responsible for determining which cell your avatar is standing within, and parenting just that cell to render, and unparenting it (or stashing it) when the avatar leaves it for another cell.

If you call setBounds() you will change the bounding volume of the cell. I don’t know why you would want to do this, since (like any other node in Panda) the bounding volume is automatically computed already. Normally setBounds() is reserved for those cases in which Panda is unable to correctly compute the bounding volume, for instance when a node is moved by directly animating its vertices.

This is a meaningless method. Please ignore it.

You parent each model to the cell node that it corresponds to.

See my comment above: you need to keep track of the “current cell” (or cells) on your own, and ensure just the current cell(s) are parented to render. The other cells are taken care of automatically. Your models can be parented either to render, in which case they will always be drawn, or to one of the cells, in which case they will be drawn only if seen through the portal that views that cell. Note that portals should generally be parented to cells. (And by parenting to a cell, I mean attaching the node somewhere within the hierarchy that is rooted at the cell node.)

You do need to connect them together by telling each portal which cell it is looking out onto. Other than that, it’s just a matter of correctly managing the “current cell” reparenting.

Can’t think of anything else off the top of my head. :slight_smile: