Portal

Inherits: Spatial < Node < Object

Portal nodes are used to enable visibility between Rooms.

Description

Portals are a special type of MeshInstance that allow the portal culling system to 'see' from one room to the next. They often correspond to doors and windows in level geometry. By only allowing Cameras to see through portals, this allows the system to cull out all the objects in rooms that cannot be seen through portals. This is a form of occlusion culling, and can greatly increase performance.

There are some limitations to the form of portals:

They must be single sided convex polygons, and usually you would orientate their front faces outward from the Room they are placed in. The vertices should be positioned on a single plane (although their positioning does not have to be perfect).

There is no need to place an opposite portal in an adjacent room, links are made two-way automatically.

Properties

NodePath

linked_room

NodePath("")

PoolVector2Array

points

PoolVector2Array( 1, -1, 1, 1, -1, 1, -1, -1 )

bool

portal_active

true

float

portal_margin

1.0

bool

two_way

true

bool

use_default_margin

true

Methods

void

set_point ( int index, Vector2 position )


Property Descriptions

NodePath linked_room = NodePath("")

This is a shortcut for setting the linked Room in the name of the Portal (the name is used during conversion).


PoolVector2Array points = PoolVector2Array( 1, -1, 1, 1, -1, 1, -1, -1 )

The points defining the shape of the Portal polygon (which should be convex).

These are defined in 2D, with 0,0 being the origin of the Portal node's Spatial.global_transform.

Note: These raw points are sanitized for winding order internally.


bool portal_active = true

  • void set_portal_active ( bool value )

  • bool get_portal_active ( )

Visibility through Portals can be turned on and off at runtime - this is useful for having closable doors.


float portal_margin = 1.0

  • void set_portal_margin ( float value )

  • float get_portal_margin ( )

Some objects are so big that they may be present in more than one Room ('sprawling'). As we often don't want objects that *just* breach the edges to be assigned to neighbouring rooms, you can assign an extra margin through the Portal to allow objects to breach without sprawling.


bool two_way = true

  • void set_two_way ( bool value )

  • bool is_two_way ( )

Portals default to being two way - see through in both directions, however you can make them one way, visible from the source room only.


bool use_default_margin = true

  • void set_use_default_margin ( bool value )

  • bool get_use_default_margin ( )

In most cases you will want to use the default Portal margin in your portals (this is set in the RoomManager).

If you want to override this default, set this value to false, and the local portal_margin will take effect.


Method Descriptions

void set_point ( int index, Vector2 position )

Sets individual points. Primarily for use by the editor.