class_portal.rst 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/Portal.xml.
  6. .. _class_Portal:
  7. Portal
  8. ======
  9. **Inherits:** :ref:`Spatial<class_Spatial>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. Portal nodes are used to enable visibility between :ref:`Room<class_Room>`\ s.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. **Portal**\ s are a special type of :ref:`MeshInstance<class_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 :ref:`Camera<class_Camera>`\ s 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.
  15. There are some limitations to the form of portals:
  16. They must be single sided convex polygons, and usually you would orientate their front faces **outward** from the :ref:`Room<class_Room>` they are placed in. The vertices should be positioned on a single plane (although their positioning does not have to be perfect).
  17. There is no need to place an opposite portal in an adjacent room, links are made two-way automatically.
  18. .. rst-class:: classref-reftable-group
  19. Properties
  20. ----------
  21. .. table::
  22. :widths: auto
  23. +-------------------------------------------------+---------------------------------------------------------------------+----------------------------------------------------+
  24. | :ref:`bool<class_bool>` | :ref:`include_in_bound<class_Portal_property_include_in_bound>` | ``false`` |
  25. +-------------------------------------------------+---------------------------------------------------------------------+----------------------------------------------------+
  26. | :ref:`NodePath<class_NodePath>` | :ref:`linked_room<class_Portal_property_linked_room>` | ``NodePath("")`` |
  27. +-------------------------------------------------+---------------------------------------------------------------------+----------------------------------------------------+
  28. | :ref:`PoolVector2Array<class_PoolVector2Array>` | :ref:`points<class_Portal_property_points>` | ``PoolVector2Array( 1, -1, 1, 1, -1, 1, -1, -1 )`` |
  29. +-------------------------------------------------+---------------------------------------------------------------------+----------------------------------------------------+
  30. | :ref:`bool<class_bool>` | :ref:`portal_active<class_Portal_property_portal_active>` | ``true`` |
  31. +-------------------------------------------------+---------------------------------------------------------------------+----------------------------------------------------+
  32. | :ref:`float<class_float>` | :ref:`portal_margin<class_Portal_property_portal_margin>` | ``1.0`` |
  33. +-------------------------------------------------+---------------------------------------------------------------------+----------------------------------------------------+
  34. | :ref:`bool<class_bool>` | :ref:`two_way<class_Portal_property_two_way>` | ``true`` |
  35. +-------------------------------------------------+---------------------------------------------------------------------+----------------------------------------------------+
  36. | :ref:`bool<class_bool>` | :ref:`use_default_margin<class_Portal_property_use_default_margin>` | ``true`` |
  37. +-------------------------------------------------+---------------------------------------------------------------------+----------------------------------------------------+
  38. .. rst-class:: classref-reftable-group
  39. Methods
  40. -------
  41. .. table::
  42. :widths: auto
  43. +------+---------------------------------------------------------------------------------------------------------------------------------+
  44. | void | :ref:`set_point<class_Portal_method_set_point>` **(** :ref:`int<class_int>` index, :ref:`Vector2<class_Vector2>` position **)** |
  45. +------+---------------------------------------------------------------------------------------------------------------------------------+
  46. .. rst-class:: classref-section-separator
  47. ----
  48. .. rst-class:: classref-descriptions-group
  49. Property Descriptions
  50. ---------------------
  51. .. _class_Portal_property_include_in_bound:
  52. .. rst-class:: classref-property
  53. :ref:`bool<class_bool>` **include_in_bound** = ``false``
  54. .. rst-class:: classref-property-setget
  55. - void **set_include_in_bound** **(** :ref:`bool<class_bool>` value **)**
  56. - :ref:`bool<class_bool>` **get_include_in_bound** **(** **)**
  57. When a manual bound has not been explicitly specified for a :ref:`Room<class_Room>`, the convex hull bound will be estimated from the geometry of the objects within the room. This setting determines whether the portal geometry is included in this estimate of the room bound.
  58. .. rst-class:: classref-item-separator
  59. ----
  60. .. _class_Portal_property_linked_room:
  61. .. rst-class:: classref-property
  62. :ref:`NodePath<class_NodePath>` **linked_room** = ``NodePath("")``
  63. .. rst-class:: classref-property-setget
  64. - void **set_linked_room** **(** :ref:`NodePath<class_NodePath>` value **)**
  65. - :ref:`NodePath<class_NodePath>` **get_linked_room** **(** **)**
  66. This is a shortcut for setting the linked :ref:`Room<class_Room>` in the name of the **Portal** (the name is used during conversion).
  67. .. rst-class:: classref-item-separator
  68. ----
  69. .. _class_Portal_property_points:
  70. .. rst-class:: classref-property
  71. :ref:`PoolVector2Array<class_PoolVector2Array>` **points** = ``PoolVector2Array( 1, -1, 1, 1, -1, 1, -1, -1 )``
  72. .. rst-class:: classref-property-setget
  73. - void **set_points** **(** :ref:`PoolVector2Array<class_PoolVector2Array>` value **)**
  74. - :ref:`PoolVector2Array<class_PoolVector2Array>` **get_points** **(** **)**
  75. The points defining the shape of the **Portal** polygon (which should be convex).
  76. These are defined in 2D, with ``0,0`` being the origin of the **Portal** node's :ref:`Spatial.global_transform<class_Spatial_property_global_transform>`.
  77. \ **Note:** These raw points are sanitized for winding order internally.
  78. .. rst-class:: classref-item-separator
  79. ----
  80. .. _class_Portal_property_portal_active:
  81. .. rst-class:: classref-property
  82. :ref:`bool<class_bool>` **portal_active** = ``true``
  83. .. rst-class:: classref-property-setget
  84. - void **set_portal_active** **(** :ref:`bool<class_bool>` value **)**
  85. - :ref:`bool<class_bool>` **get_portal_active** **(** **)**
  86. Visibility through **Portal**\ s can be turned on and off at runtime - this is useful for having closable doors.
  87. .. rst-class:: classref-item-separator
  88. ----
  89. .. _class_Portal_property_portal_margin:
  90. .. rst-class:: classref-property
  91. :ref:`float<class_float>` **portal_margin** = ``1.0``
  92. .. rst-class:: classref-property-setget
  93. - void **set_portal_margin** **(** :ref:`float<class_float>` value **)**
  94. - :ref:`float<class_float>` **get_portal_margin** **(** **)**
  95. Some objects are so big that they may be present in more than one :ref:`Room<class_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.
  96. .. rst-class:: classref-item-separator
  97. ----
  98. .. _class_Portal_property_two_way:
  99. .. rst-class:: classref-property
  100. :ref:`bool<class_bool>` **two_way** = ``true``
  101. .. rst-class:: classref-property-setget
  102. - void **set_two_way** **(** :ref:`bool<class_bool>` value **)**
  103. - :ref:`bool<class_bool>` **is_two_way** **(** **)**
  104. Portals default to being two way - see through in both directions, however you can make them one way, visible from the source room only.
  105. .. rst-class:: classref-item-separator
  106. ----
  107. .. _class_Portal_property_use_default_margin:
  108. .. rst-class:: classref-property
  109. :ref:`bool<class_bool>` **use_default_margin** = ``true``
  110. .. rst-class:: classref-property-setget
  111. - void **set_use_default_margin** **(** :ref:`bool<class_bool>` value **)**
  112. - :ref:`bool<class_bool>` **get_use_default_margin** **(** **)**
  113. In most cases you will want to use the default **Portal** margin in your portals (this is set in the :ref:`RoomManager<class_RoomManager>`).
  114. If you want to override this default, set this value to ``false``, and the local :ref:`portal_margin<class_Portal_property_portal_margin>` will take effect.
  115. .. rst-class:: classref-section-separator
  116. ----
  117. .. rst-class:: classref-descriptions-group
  118. Method Descriptions
  119. -------------------
  120. .. _class_Portal_method_set_point:
  121. .. rst-class:: classref-method
  122. void **set_point** **(** :ref:`int<class_int>` index, :ref:`Vector2<class_Vector2>` position **)**
  123. Sets individual points. Primarily for use by the editor.
  124. \ **Note:** This function will not resize the point array. Set :ref:`points<class_Portal_property_points>` to set the number of points.
  125. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  126. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  127. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  128. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`