class_csgshape3d.rst 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  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/4.0/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.0/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. \ **Note:** CSG nodes are intended to be used for level prototyping. Creating CSG nodes has a significant CPU cost compared to creating a :ref:`MeshInstance3D<class_MeshInstance3D>` with a :ref:`PrimitiveMesh<class_PrimitiveMesh>`. Moving a CSG node within another CSG node also has a significant CPU cost, so it should be avoided during gameplay.
  17. .. rst-class:: classref-introduction-group
  18. Tutorials
  19. ---------
  20. - :doc:`Prototyping levels with CSG <../tutorials/3d/csg_tools>`
  21. .. rst-class:: classref-reftable-group
  22. Properties
  23. ----------
  24. .. table::
  25. :widths: auto
  26. +---------------------------------------------+-------------------------------------------------------------------------+-----------+
  27. | :ref:`bool<class_bool>` | :ref:`calculate_tangents<class_CSGShape3D_property_calculate_tangents>` | ``true`` |
  28. +---------------------------------------------+-------------------------------------------------------------------------+-----------+
  29. | :ref:`int<class_int>` | :ref:`collision_layer<class_CSGShape3D_property_collision_layer>` | ``1`` |
  30. +---------------------------------------------+-------------------------------------------------------------------------+-----------+
  31. | :ref:`int<class_int>` | :ref:`collision_mask<class_CSGShape3D_property_collision_mask>` | ``1`` |
  32. +---------------------------------------------+-------------------------------------------------------------------------+-----------+
  33. | :ref:`float<class_float>` | :ref:`collision_priority<class_CSGShape3D_property_collision_priority>` | ``1.0`` |
  34. +---------------------------------------------+-------------------------------------------------------------------------+-----------+
  35. | :ref:`Operation<enum_CSGShape3D_Operation>` | :ref:`operation<class_CSGShape3D_property_operation>` | ``0`` |
  36. +---------------------------------------------+-------------------------------------------------------------------------+-----------+
  37. | :ref:`float<class_float>` | :ref:`snap<class_CSGShape3D_property_snap>` | ``0.001`` |
  38. +---------------------------------------------+-------------------------------------------------------------------------+-----------+
  39. | :ref:`bool<class_bool>` | :ref:`use_collision<class_CSGShape3D_property_use_collision>` | ``false`` |
  40. +---------------------------------------------+-------------------------------------------------------------------------+-----------+
  41. .. rst-class:: classref-reftable-group
  42. Methods
  43. -------
  44. .. table::
  45. :widths: auto
  46. +---------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`bool<class_bool>` | :ref:`get_collision_layer_value<class_CSGShape3D_method_get_collision_layer_value>` **(** :ref:`int<class_int>` layer_number **)** |const| |
  48. +---------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`bool<class_bool>` | :ref:`get_collision_mask_value<class_CSGShape3D_method_get_collision_mask_value>` **(** :ref:`int<class_int>` layer_number **)** |const| |
  50. +---------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`Array<class_Array>` | :ref:`get_meshes<class_CSGShape3D_method_get_meshes>` **(** **)** |const| |
  52. +---------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`bool<class_bool>` | :ref:`is_root_shape<class_CSGShape3D_method_is_root_shape>` **(** **)** |const| |
  54. +---------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | void | :ref:`set_collision_layer_value<class_CSGShape3D_method_set_collision_layer_value>` **(** :ref:`int<class_int>` layer_number, :ref:`bool<class_bool>` value **)** |
  56. +---------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | void | :ref:`set_collision_mask_value<class_CSGShape3D_method_set_collision_mask_value>` **(** :ref:`int<class_int>` layer_number, :ref:`bool<class_bool>` value **)** |
  58. +---------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. .. rst-class:: classref-section-separator
  60. ----
  61. .. rst-class:: classref-descriptions-group
  62. Enumerations
  63. ------------
  64. .. _enum_CSGShape3D_Operation:
  65. .. rst-class:: classref-enumeration
  66. enum **Operation**:
  67. .. _class_CSGShape3D_constant_OPERATION_UNION:
  68. .. rst-class:: classref-enumeration-constant
  69. :ref:`Operation<enum_CSGShape3D_Operation>` **OPERATION_UNION** = ``0``
  70. Geometry of both primitives is merged, intersecting geometry is removed.
  71. .. _class_CSGShape3D_constant_OPERATION_INTERSECTION:
  72. .. rst-class:: classref-enumeration-constant
  73. :ref:`Operation<enum_CSGShape3D_Operation>` **OPERATION_INTERSECTION** = ``1``
  74. Only intersecting geometry remains, the rest is removed.
  75. .. _class_CSGShape3D_constant_OPERATION_SUBTRACTION:
  76. .. rst-class:: classref-enumeration-constant
  77. :ref:`Operation<enum_CSGShape3D_Operation>` **OPERATION_SUBTRACTION** = ``2``
  78. The second shape is subtracted from the first, leaving a dent with its shape.
  79. .. rst-class:: classref-section-separator
  80. ----
  81. .. rst-class:: classref-descriptions-group
  82. Property Descriptions
  83. ---------------------
  84. .. _class_CSGShape3D_property_calculate_tangents:
  85. .. rst-class:: classref-property
  86. :ref:`bool<class_bool>` **calculate_tangents** = ``true``
  87. .. rst-class:: classref-property-setget
  88. - void **set_calculate_tangents** **(** :ref:`bool<class_bool>` value **)**
  89. - :ref:`bool<class_bool>` **is_calculating_tangents** **(** **)**
  90. Calculate tangents for the CSG shape which allows the use of normal maps. This is only applied on the root shape, this setting is ignored on any child.
  91. .. rst-class:: classref-item-separator
  92. ----
  93. .. _class_CSGShape3D_property_collision_layer:
  94. .. rst-class:: classref-property
  95. :ref:`int<class_int>` **collision_layer** = ``1``
  96. .. rst-class:: classref-property-setget
  97. - void **set_collision_layer** **(** :ref:`int<class_int>` value **)**
  98. - :ref:`int<class_int>` **get_collision_layer** **(** **)**
  99. The physics layers this area is in.
  100. 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.
  101. 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.
  102. .. rst-class:: classref-item-separator
  103. ----
  104. .. _class_CSGShape3D_property_collision_mask:
  105. .. rst-class:: classref-property
  106. :ref:`int<class_int>` **collision_mask** = ``1``
  107. .. rst-class:: classref-property-setget
  108. - void **set_collision_mask** **(** :ref:`int<class_int>` value **)**
  109. - :ref:`int<class_int>` **get_collision_mask** **(** **)**
  110. 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.
  111. .. rst-class:: classref-item-separator
  112. ----
  113. .. _class_CSGShape3D_property_collision_priority:
  114. .. rst-class:: classref-property
  115. :ref:`float<class_float>` **collision_priority** = ``1.0``
  116. .. rst-class:: classref-property-setget
  117. - void **set_collision_priority** **(** :ref:`float<class_float>` value **)**
  118. - :ref:`float<class_float>` **get_collision_priority** **(** **)**
  119. 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.
  120. .. rst-class:: classref-item-separator
  121. ----
  122. .. _class_CSGShape3D_property_operation:
  123. .. rst-class:: classref-property
  124. :ref:`Operation<enum_CSGShape3D_Operation>` **operation** = ``0``
  125. .. rst-class:: classref-property-setget
  126. - void **set_operation** **(** :ref:`Operation<enum_CSGShape3D_Operation>` value **)**
  127. - :ref:`Operation<enum_CSGShape3D_Operation>` **get_operation** **(** **)**
  128. 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.
  129. .. rst-class:: classref-item-separator
  130. ----
  131. .. _class_CSGShape3D_property_snap:
  132. .. rst-class:: classref-property
  133. :ref:`float<class_float>` **snap** = ``0.001``
  134. .. rst-class:: classref-property-setget
  135. - void **set_snap** **(** :ref:`float<class_float>` value **)**
  136. - :ref:`float<class_float>` **get_snap** **(** **)**
  137. Snap makes the mesh vertices snap to a given distance so that the faces of two meshes can be perfectly aligned. A lower value results in greater precision but may be harder to adjust.
  138. .. rst-class:: classref-item-separator
  139. ----
  140. .. _class_CSGShape3D_property_use_collision:
  141. .. rst-class:: classref-property
  142. :ref:`bool<class_bool>` **use_collision** = ``false``
  143. .. rst-class:: classref-property-setget
  144. - void **set_use_collision** **(** :ref:`bool<class_bool>` value **)**
  145. - :ref:`bool<class_bool>` **is_using_collision** **(** **)**
  146. 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>`.
  147. .. rst-class:: classref-section-separator
  148. ----
  149. .. rst-class:: classref-descriptions-group
  150. Method Descriptions
  151. -------------------
  152. .. _class_CSGShape3D_method_get_collision_layer_value:
  153. .. rst-class:: classref-method
  154. :ref:`bool<class_bool>` **get_collision_layer_value** **(** :ref:`int<class_int>` layer_number **)** |const|
  155. 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.
  156. .. rst-class:: classref-item-separator
  157. ----
  158. .. _class_CSGShape3D_method_get_collision_mask_value:
  159. .. rst-class:: classref-method
  160. :ref:`bool<class_bool>` **get_collision_mask_value** **(** :ref:`int<class_int>` layer_number **)** |const|
  161. 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.
  162. .. rst-class:: classref-item-separator
  163. ----
  164. .. _class_CSGShape3D_method_get_meshes:
  165. .. rst-class:: classref-method
  166. :ref:`Array<class_Array>` **get_meshes** **(** **)** |const|
  167. 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.
  168. .. rst-class:: classref-item-separator
  169. ----
  170. .. _class_CSGShape3D_method_is_root_shape:
  171. .. rst-class:: classref-method
  172. :ref:`bool<class_bool>` **is_root_shape** **(** **)** |const|
  173. Returns ``true`` if this is a root shape and is thus the object that is rendered.
  174. .. rst-class:: classref-item-separator
  175. ----
  176. .. _class_CSGShape3D_method_set_collision_layer_value:
  177. .. rst-class:: classref-method
  178. void **set_collision_layer_value** **(** :ref:`int<class_int>` layer_number, :ref:`bool<class_bool>` value **)**
  179. 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.
  180. .. rst-class:: classref-item-separator
  181. ----
  182. .. _class_CSGShape3D_method_set_collision_mask_value:
  183. .. rst-class:: classref-method
  184. void **set_collision_mask_value** **(** :ref:`int<class_int>` layer_number, :ref:`bool<class_bool>` value **)**
  185. 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.
  186. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  187. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  188. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  189. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  190. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  191. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`