class_csgshape3d.rst 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  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/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/modules/csg/doc_classes/CSGShape3D.xml.
  6. .. _class_CSGShape3D:
  7. CSGShape3D
  8. ==========
  9. **Inherits:** :ref:`GeometryInstance3D<class_GeometryInstance3D>` **<** :ref:`VisualInstance3D<class_VisualInstance3D>` **<** :ref:`Node3D<class_Node3D>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. **Inherited By:** :ref:`CSGCombiner3D<class_CSGCombiner3D>`, :ref:`CSGPrimitive3D<class_CSGPrimitive3D>`
  11. The CSG base class.
  12. .. rst-class:: classref-introduction-group
  13. Description
  14. -----------
  15. This is the CSG base class that provides CSG operation support to the various CSG nodes in Godot.
  16. \ **Performance:** CSG nodes are only intended for prototyping as they have a significant CPU performance cost. Consider baking final CSG operation results into static geometry that replaces the CSG nodes.
  17. Individual CSG root node results can be baked to nodes with static resources with the editor menu that appears when a CSG root node is selected.
  18. Individual CSG root nodes can also be baked to static resources with scripts by calling :ref:`bake_static_mesh()<class_CSGShape3D_method_bake_static_mesh>` for the visual mesh or :ref:`bake_collision_shape()<class_CSGShape3D_method_bake_collision_shape>` for the physics collision.
  19. Entire scenes of CSG nodes can be baked to static geometry and exported with the editor glTF scene exporter: **Scene > Export As... > glTF 2.0 Scene...**
  20. .. rst-class:: classref-introduction-group
  21. Tutorials
  22. ---------
  23. - :doc:`Prototyping levels with CSG <../tutorials/3d/csg_tools>`
  24. .. rst-class:: classref-reftable-group
  25. Properties
  26. ----------
  27. .. table::
  28. :widths: auto
  29. +---------------------------------------------+-------------------------------------------------------------------------+-----------+
  30. | :ref:`bool<class_bool>` | :ref:`calculate_tangents<class_CSGShape3D_property_calculate_tangents>` | ``true`` |
  31. +---------------------------------------------+-------------------------------------------------------------------------+-----------+
  32. | :ref:`int<class_int>` | :ref:`collision_layer<class_CSGShape3D_property_collision_layer>` | ``1`` |
  33. +---------------------------------------------+-------------------------------------------------------------------------+-----------+
  34. | :ref:`int<class_int>` | :ref:`collision_mask<class_CSGShape3D_property_collision_mask>` | ``1`` |
  35. +---------------------------------------------+-------------------------------------------------------------------------+-----------+
  36. | :ref:`float<class_float>` | :ref:`collision_priority<class_CSGShape3D_property_collision_priority>` | ``1.0`` |
  37. +---------------------------------------------+-------------------------------------------------------------------------+-----------+
  38. | :ref:`Operation<enum_CSGShape3D_Operation>` | :ref:`operation<class_CSGShape3D_property_operation>` | ``0`` |
  39. +---------------------------------------------+-------------------------------------------------------------------------+-----------+
  40. | :ref:`float<class_float>` | :ref:`snap<class_CSGShape3D_property_snap>` | |
  41. +---------------------------------------------+-------------------------------------------------------------------------+-----------+
  42. | :ref:`bool<class_bool>` | :ref:`use_collision<class_CSGShape3D_property_use_collision>` | ``false`` |
  43. +---------------------------------------------+-------------------------------------------------------------------------+-----------+
  44. .. rst-class:: classref-reftable-group
  45. Methods
  46. -------
  47. .. table::
  48. :widths: auto
  49. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`ConcavePolygonShape3D<class_ConcavePolygonShape3D>` | :ref:`bake_collision_shape<class_CSGShape3D_method_bake_collision_shape>`\ (\ ) |
  51. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`ArrayMesh<class_ArrayMesh>` | :ref:`bake_static_mesh<class_CSGShape3D_method_bake_static_mesh>`\ (\ ) |
  53. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | :ref:`bool<class_bool>` | :ref:`get_collision_layer_value<class_CSGShape3D_method_get_collision_layer_value>`\ (\ layer_number\: :ref:`int<class_int>`\ ) |const| |
  55. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`bool<class_bool>` | :ref:`get_collision_mask_value<class_CSGShape3D_method_get_collision_mask_value>`\ (\ layer_number\: :ref:`int<class_int>`\ ) |const| |
  57. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`Array<class_Array>` | :ref:`get_meshes<class_CSGShape3D_method_get_meshes>`\ (\ ) |const| |
  59. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`bool<class_bool>` | :ref:`is_root_shape<class_CSGShape3D_method_is_root_shape>`\ (\ ) |const| |
  61. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | |void| | :ref:`set_collision_layer_value<class_CSGShape3D_method_set_collision_layer_value>`\ (\ layer_number\: :ref:`int<class_int>`, value\: :ref:`bool<class_bool>`\ ) |
  63. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | |void| | :ref:`set_collision_mask_value<class_CSGShape3D_method_set_collision_mask_value>`\ (\ layer_number\: :ref:`int<class_int>`, value\: :ref:`bool<class_bool>`\ ) |
  65. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. .. rst-class:: classref-section-separator
  67. ----
  68. .. rst-class:: classref-descriptions-group
  69. Enumerations
  70. ------------
  71. .. _enum_CSGShape3D_Operation:
  72. .. rst-class:: classref-enumeration
  73. enum **Operation**: :ref:`🔗<enum_CSGShape3D_Operation>`
  74. .. _class_CSGShape3D_constant_OPERATION_UNION:
  75. .. rst-class:: classref-enumeration-constant
  76. :ref:`Operation<enum_CSGShape3D_Operation>` **OPERATION_UNION** = ``0``
  77. Geometry of both primitives is merged, intersecting geometry is removed.
  78. .. _class_CSGShape3D_constant_OPERATION_INTERSECTION:
  79. .. rst-class:: classref-enumeration-constant
  80. :ref:`Operation<enum_CSGShape3D_Operation>` **OPERATION_INTERSECTION** = ``1``
  81. Only intersecting geometry remains, the rest is removed.
  82. .. _class_CSGShape3D_constant_OPERATION_SUBTRACTION:
  83. .. rst-class:: classref-enumeration-constant
  84. :ref:`Operation<enum_CSGShape3D_Operation>` **OPERATION_SUBTRACTION** = ``2``
  85. The second shape is subtracted from the first, leaving a dent with its shape.
  86. .. rst-class:: classref-section-separator
  87. ----
  88. .. rst-class:: classref-descriptions-group
  89. Property Descriptions
  90. ---------------------
  91. .. _class_CSGShape3D_property_calculate_tangents:
  92. .. rst-class:: classref-property
  93. :ref:`bool<class_bool>` **calculate_tangents** = ``true`` :ref:`🔗<class_CSGShape3D_property_calculate_tangents>`
  94. .. rst-class:: classref-property-setget
  95. - |void| **set_calculate_tangents**\ (\ value\: :ref:`bool<class_bool>`\ )
  96. - :ref:`bool<class_bool>` **is_calculating_tangents**\ (\ )
  97. Calculate tangents for the CSG shape which allows the use of normal and height maps. This is only applied on the root shape, this setting is ignored on any child. Setting this to ``false`` can speed up shape generation slightly.
  98. .. rst-class:: classref-item-separator
  99. ----
  100. .. _class_CSGShape3D_property_collision_layer:
  101. .. rst-class:: classref-property
  102. :ref:`int<class_int>` **collision_layer** = ``1`` :ref:`🔗<class_CSGShape3D_property_collision_layer>`
  103. .. rst-class:: classref-property-setget
  104. - |void| **set_collision_layer**\ (\ value\: :ref:`int<class_int>`\ )
  105. - :ref:`int<class_int>` **get_collision_layer**\ (\ )
  106. The physics layers this area is in.
  107. Collidable objects can exist in any of 32 different layers. These layers work like a tagging system, and are not visual. A collidable can use these layers to select with which objects it can collide, using the collision_mask property.
  108. A contact is detected if object A is in any of the layers that object B scans, or object B is in any layer scanned by object A. See `Collision layers and masks <../tutorials/physics/physics_introduction.html#collision-layers-and-masks>`__ in the documentation for more information.
  109. .. rst-class:: classref-item-separator
  110. ----
  111. .. _class_CSGShape3D_property_collision_mask:
  112. .. rst-class:: classref-property
  113. :ref:`int<class_int>` **collision_mask** = ``1`` :ref:`🔗<class_CSGShape3D_property_collision_mask>`
  114. .. rst-class:: classref-property-setget
  115. - |void| **set_collision_mask**\ (\ value\: :ref:`int<class_int>`\ )
  116. - :ref:`int<class_int>` **get_collision_mask**\ (\ )
  117. The physics layers this CSG shape scans for collisions. Only effective if :ref:`use_collision<class_CSGShape3D_property_use_collision>` is ``true``. See `Collision layers and masks <../tutorials/physics/physics_introduction.html#collision-layers-and-masks>`__ in the documentation for more information.
  118. .. rst-class:: classref-item-separator
  119. ----
  120. .. _class_CSGShape3D_property_collision_priority:
  121. .. rst-class:: classref-property
  122. :ref:`float<class_float>` **collision_priority** = ``1.0`` :ref:`🔗<class_CSGShape3D_property_collision_priority>`
  123. .. rst-class:: classref-property-setget
  124. - |void| **set_collision_priority**\ (\ value\: :ref:`float<class_float>`\ )
  125. - :ref:`float<class_float>` **get_collision_priority**\ (\ )
  126. The priority used to solve colliding when occurring penetration. Only effective if :ref:`use_collision<class_CSGShape3D_property_use_collision>` is ``true``. The higher the priority is, the lower the penetration into the object will be. This can for example be used to prevent the player from breaking through the boundaries of a level.
  127. .. rst-class:: classref-item-separator
  128. ----
  129. .. _class_CSGShape3D_property_operation:
  130. .. rst-class:: classref-property
  131. :ref:`Operation<enum_CSGShape3D_Operation>` **operation** = ``0`` :ref:`🔗<class_CSGShape3D_property_operation>`
  132. .. rst-class:: classref-property-setget
  133. - |void| **set_operation**\ (\ value\: :ref:`Operation<enum_CSGShape3D_Operation>`\ )
  134. - :ref:`Operation<enum_CSGShape3D_Operation>` **get_operation**\ (\ )
  135. The operation that is performed on this shape. This is ignored for the first CSG child node as the operation is between this node and the previous child of this nodes parent.
  136. .. rst-class:: classref-item-separator
  137. ----
  138. .. _class_CSGShape3D_property_snap:
  139. .. rst-class:: classref-property
  140. :ref:`float<class_float>` **snap** :ref:`🔗<class_CSGShape3D_property_snap>`
  141. .. rst-class:: classref-property-setget
  142. - |void| **set_snap**\ (\ value\: :ref:`float<class_float>`\ )
  143. - :ref:`float<class_float>` **get_snap**\ (\ )
  144. **Deprecated:** The CSG library no longer uses snapping.
  145. This property does nothing.
  146. .. rst-class:: classref-item-separator
  147. ----
  148. .. _class_CSGShape3D_property_use_collision:
  149. .. rst-class:: classref-property
  150. :ref:`bool<class_bool>` **use_collision** = ``false`` :ref:`🔗<class_CSGShape3D_property_use_collision>`
  151. .. rst-class:: classref-property-setget
  152. - |void| **set_use_collision**\ (\ value\: :ref:`bool<class_bool>`\ )
  153. - :ref:`bool<class_bool>` **is_using_collision**\ (\ )
  154. Adds a collision shape to the physics engine for our CSG shape. This will always act like a static body. Note that the collision shape is still active even if the CSG shape itself is hidden. See also :ref:`collision_mask<class_CSGShape3D_property_collision_mask>` and :ref:`collision_priority<class_CSGShape3D_property_collision_priority>`.
  155. .. rst-class:: classref-section-separator
  156. ----
  157. .. rst-class:: classref-descriptions-group
  158. Method Descriptions
  159. -------------------
  160. .. _class_CSGShape3D_method_bake_collision_shape:
  161. .. rst-class:: classref-method
  162. :ref:`ConcavePolygonShape3D<class_ConcavePolygonShape3D>` **bake_collision_shape**\ (\ ) :ref:`🔗<class_CSGShape3D_method_bake_collision_shape>`
  163. Returns a baked physics :ref:`ConcavePolygonShape3D<class_ConcavePolygonShape3D>` of this node's CSG operation result. Returns an empty shape if the node is not a CSG root node or has no valid geometry.
  164. \ **Performance:** If the CSG operation results in a very detailed geometry with many faces physics performance will be very slow. Concave shapes should in general only be used for static level geometry and not with dynamic objects that are moving.
  165. \ **Note:** CSG mesh data updates are deferred, which means they are updated with a delay of one rendered frame. To avoid getting an empty shape or outdated mesh data, make sure to call ``await get_tree().process_frame`` before using :ref:`bake_collision_shape()<class_CSGShape3D_method_bake_collision_shape>` in :ref:`Node._ready()<class_Node_private_method__ready>` or after changing properties on the **CSGShape3D**.
  166. .. rst-class:: classref-item-separator
  167. ----
  168. .. _class_CSGShape3D_method_bake_static_mesh:
  169. .. rst-class:: classref-method
  170. :ref:`ArrayMesh<class_ArrayMesh>` **bake_static_mesh**\ (\ ) :ref:`🔗<class_CSGShape3D_method_bake_static_mesh>`
  171. Returns a baked static :ref:`ArrayMesh<class_ArrayMesh>` of this node's CSG operation result. Materials from involved CSG nodes are added as extra mesh surfaces. Returns an empty mesh if the node is not a CSG root node or has no valid geometry.
  172. \ **Note:** CSG mesh data updates are deferred, which means they are updated with a delay of one rendered frame. To avoid getting an empty mesh or outdated mesh data, make sure to call ``await get_tree().process_frame`` before using :ref:`bake_static_mesh()<class_CSGShape3D_method_bake_static_mesh>` in :ref:`Node._ready()<class_Node_private_method__ready>` or after changing properties on the **CSGShape3D**.
  173. .. rst-class:: classref-item-separator
  174. ----
  175. .. _class_CSGShape3D_method_get_collision_layer_value:
  176. .. rst-class:: classref-method
  177. :ref:`bool<class_bool>` **get_collision_layer_value**\ (\ layer_number\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_CSGShape3D_method_get_collision_layer_value>`
  178. Returns whether or not the specified layer of the :ref:`collision_layer<class_CSGShape3D_property_collision_layer>` is enabled, given a ``layer_number`` between 1 and 32.
  179. .. rst-class:: classref-item-separator
  180. ----
  181. .. _class_CSGShape3D_method_get_collision_mask_value:
  182. .. rst-class:: classref-method
  183. :ref:`bool<class_bool>` **get_collision_mask_value**\ (\ layer_number\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_CSGShape3D_method_get_collision_mask_value>`
  184. Returns whether or not the specified layer of the :ref:`collision_mask<class_CSGShape3D_property_collision_mask>` is enabled, given a ``layer_number`` between 1 and 32.
  185. .. rst-class:: classref-item-separator
  186. ----
  187. .. _class_CSGShape3D_method_get_meshes:
  188. .. rst-class:: classref-method
  189. :ref:`Array<class_Array>` **get_meshes**\ (\ ) |const| :ref:`🔗<class_CSGShape3D_method_get_meshes>`
  190. Returns an :ref:`Array<class_Array>` with two elements, the first is the :ref:`Transform3D<class_Transform3D>` of this node and the second is the root :ref:`Mesh<class_Mesh>` of this node. Only works when this node is the root shape.
  191. \ **Note:** CSG mesh data updates are deferred, which means they are updated with a delay of one rendered frame. To avoid getting an empty shape or outdated mesh data, make sure to call ``await get_tree().process_frame`` before using :ref:`get_meshes()<class_CSGShape3D_method_get_meshes>` in :ref:`Node._ready()<class_Node_private_method__ready>` or after changing properties on the **CSGShape3D**.
  192. .. rst-class:: classref-item-separator
  193. ----
  194. .. _class_CSGShape3D_method_is_root_shape:
  195. .. rst-class:: classref-method
  196. :ref:`bool<class_bool>` **is_root_shape**\ (\ ) |const| :ref:`🔗<class_CSGShape3D_method_is_root_shape>`
  197. Returns ``true`` if this is a root shape and is thus the object that is rendered.
  198. .. rst-class:: classref-item-separator
  199. ----
  200. .. _class_CSGShape3D_method_set_collision_layer_value:
  201. .. rst-class:: classref-method
  202. |void| **set_collision_layer_value**\ (\ layer_number\: :ref:`int<class_int>`, value\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_CSGShape3D_method_set_collision_layer_value>`
  203. Based on ``value``, enables or disables the specified layer in the :ref:`collision_layer<class_CSGShape3D_property_collision_layer>`, given a ``layer_number`` between 1 and 32.
  204. .. rst-class:: classref-item-separator
  205. ----
  206. .. _class_CSGShape3D_method_set_collision_mask_value:
  207. .. rst-class:: classref-method
  208. |void| **set_collision_mask_value**\ (\ layer_number\: :ref:`int<class_int>`, value\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_CSGShape3D_method_set_collision_mask_value>`
  209. Based on ``value``, enables or disables the specified layer in the :ref:`collision_mask<class_CSGShape3D_property_collision_mask>`, given a ``layer_number`` between 1 and 32.
  210. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  211. .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
  212. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  213. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  214. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  215. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  216. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  217. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  218. .. |void| replace:: :abbr:`void (No return value.)`