class_csgshape.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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/modules/csg/doc_classes/CSGShape.xml.
  6. .. _class_CSGShape:
  7. CSGShape
  8. ========
  9. **Inherits:** :ref:`GeometryInstance<class_GeometryInstance>` **<** :ref:`VisualInstance<class_VisualInstance>` **<** :ref:`CullInstance<class_CullInstance>` **<** :ref:`Spatial<class_Spatial>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. **Inherited By:** :ref:`CSGCombiner<class_CSGCombiner>`, :ref:`CSGPrimitive<class_CSGPrimitive>`
  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:`MeshInstance<class_MeshInstance>` 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_CSGShape_property_calculate_tangents>` | ``true`` |
  28. +-------------------------------------------+-----------------------------------------------------------------------+-----------+
  29. | :ref:`int<class_int>` | :ref:`collision_layer<class_CSGShape_property_collision_layer>` | ``1`` |
  30. +-------------------------------------------+-----------------------------------------------------------------------+-----------+
  31. | :ref:`int<class_int>` | :ref:`collision_mask<class_CSGShape_property_collision_mask>` | ``1`` |
  32. +-------------------------------------------+-----------------------------------------------------------------------+-----------+
  33. | :ref:`Operation<enum_CSGShape_Operation>` | :ref:`operation<class_CSGShape_property_operation>` | ``0`` |
  34. +-------------------------------------------+-----------------------------------------------------------------------+-----------+
  35. | :ref:`float<class_float>` | :ref:`snap<class_CSGShape_property_snap>` | ``0.001`` |
  36. +-------------------------------------------+-----------------------------------------------------------------------+-----------+
  37. | :ref:`bool<class_bool>` | :ref:`use_collision<class_CSGShape_property_use_collision>` | ``false`` |
  38. +-------------------------------------------+-----------------------------------------------------------------------+-----------+
  39. .. rst-class:: classref-reftable-group
  40. Methods
  41. -------
  42. .. table::
  43. :widths: auto
  44. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`bool<class_bool>` | :ref:`get_collision_layer_bit<class_CSGShape_method_get_collision_layer_bit>` **(** :ref:`int<class_int>` bit **)** |const| |
  46. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`bool<class_bool>` | :ref:`get_collision_mask_bit<class_CSGShape_method_get_collision_mask_bit>` **(** :ref:`int<class_int>` bit **)** |const| |
  48. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`Array<class_Array>` | :ref:`get_meshes<class_CSGShape_method_get_meshes>` **(** **)** |const| |
  50. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`bool<class_bool>` | :ref:`is_root_shape<class_CSGShape_method_is_root_shape>` **(** **)** |const| |
  52. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | void | :ref:`set_collision_layer_bit<class_CSGShape_method_set_collision_layer_bit>` **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)** |
  54. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | void | :ref:`set_collision_mask_bit<class_CSGShape_method_set_collision_mask_bit>` **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)** |
  56. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
  57. .. rst-class:: classref-section-separator
  58. ----
  59. .. rst-class:: classref-descriptions-group
  60. Enumerations
  61. ------------
  62. .. _enum_CSGShape_Operation:
  63. .. rst-class:: classref-enumeration
  64. enum **Operation**:
  65. .. _class_CSGShape_constant_OPERATION_UNION:
  66. .. rst-class:: classref-enumeration-constant
  67. :ref:`Operation<enum_CSGShape_Operation>` **OPERATION_UNION** = ``0``
  68. Geometry of both primitives is merged, intersecting geometry is removed.
  69. .. _class_CSGShape_constant_OPERATION_INTERSECTION:
  70. .. rst-class:: classref-enumeration-constant
  71. :ref:`Operation<enum_CSGShape_Operation>` **OPERATION_INTERSECTION** = ``1``
  72. Only intersecting geometry remains, the rest is removed.
  73. .. _class_CSGShape_constant_OPERATION_SUBTRACTION:
  74. .. rst-class:: classref-enumeration-constant
  75. :ref:`Operation<enum_CSGShape_Operation>` **OPERATION_SUBTRACTION** = ``2``
  76. The second shape is subtracted from the first, leaving a dent with its shape.
  77. .. rst-class:: classref-section-separator
  78. ----
  79. .. rst-class:: classref-descriptions-group
  80. Property Descriptions
  81. ---------------------
  82. .. _class_CSGShape_property_calculate_tangents:
  83. .. rst-class:: classref-property
  84. :ref:`bool<class_bool>` **calculate_tangents** = ``true``
  85. .. rst-class:: classref-property-setget
  86. - void **set_calculate_tangents** **(** :ref:`bool<class_bool>` value **)**
  87. - :ref:`bool<class_bool>` **is_calculating_tangents** **(** **)**
  88. 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.
  89. .. rst-class:: classref-item-separator
  90. ----
  91. .. _class_CSGShape_property_collision_layer:
  92. .. rst-class:: classref-property
  93. :ref:`int<class_int>` **collision_layer** = ``1``
  94. .. rst-class:: classref-property-setget
  95. - void **set_collision_layer** **(** :ref:`int<class_int>` value **)**
  96. - :ref:`int<class_int>` **get_collision_layer** **(** **)**
  97. The physics layers this area is in.
  98. 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.
  99. 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.
  100. .. rst-class:: classref-item-separator
  101. ----
  102. .. _class_CSGShape_property_collision_mask:
  103. .. rst-class:: classref-property
  104. :ref:`int<class_int>` **collision_mask** = ``1``
  105. .. rst-class:: classref-property-setget
  106. - void **set_collision_mask** **(** :ref:`int<class_int>` value **)**
  107. - :ref:`int<class_int>` **get_collision_mask** **(** **)**
  108. The physics layers this CSG shape scans for collisions. 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_CSGShape_property_operation:
  112. .. rst-class:: classref-property
  113. :ref:`Operation<enum_CSGShape_Operation>` **operation** = ``0``
  114. .. rst-class:: classref-property-setget
  115. - void **set_operation** **(** :ref:`Operation<enum_CSGShape_Operation>` value **)**
  116. - :ref:`Operation<enum_CSGShape_Operation>` **get_operation** **(** **)**
  117. 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.
  118. .. rst-class:: classref-item-separator
  119. ----
  120. .. _class_CSGShape_property_snap:
  121. .. rst-class:: classref-property
  122. :ref:`float<class_float>` **snap** = ``0.001``
  123. .. rst-class:: classref-property-setget
  124. - void **set_snap** **(** :ref:`float<class_float>` value **)**
  125. - :ref:`float<class_float>` **get_snap** **(** **)**
  126. Snap makes the mesh 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.
  127. .. rst-class:: classref-item-separator
  128. ----
  129. .. _class_CSGShape_property_use_collision:
  130. .. rst-class:: classref-property
  131. :ref:`bool<class_bool>` **use_collision** = ``false``
  132. .. rst-class:: classref-property-setget
  133. - void **set_use_collision** **(** :ref:`bool<class_bool>` value **)**
  134. - :ref:`bool<class_bool>` **is_using_collision** **(** **)**
  135. 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.
  136. .. rst-class:: classref-section-separator
  137. ----
  138. .. rst-class:: classref-descriptions-group
  139. Method Descriptions
  140. -------------------
  141. .. _class_CSGShape_method_get_collision_layer_bit:
  142. .. rst-class:: classref-method
  143. :ref:`bool<class_bool>` **get_collision_layer_bit** **(** :ref:`int<class_int>` bit **)** |const|
  144. Returns an individual bit on the collision mask.
  145. .. rst-class:: classref-item-separator
  146. ----
  147. .. _class_CSGShape_method_get_collision_mask_bit:
  148. .. rst-class:: classref-method
  149. :ref:`bool<class_bool>` **get_collision_mask_bit** **(** :ref:`int<class_int>` bit **)** |const|
  150. Returns an individual bit on the collision mask.
  151. .. rst-class:: classref-item-separator
  152. ----
  153. .. _class_CSGShape_method_get_meshes:
  154. .. rst-class:: classref-method
  155. :ref:`Array<class_Array>` **get_meshes** **(** **)** |const|
  156. Returns an :ref:`Array<class_Array>` with two elements, the first is the :ref:`Transform<class_Transform>` 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.
  157. .. rst-class:: classref-item-separator
  158. ----
  159. .. _class_CSGShape_method_is_root_shape:
  160. .. rst-class:: classref-method
  161. :ref:`bool<class_bool>` **is_root_shape** **(** **)** |const|
  162. Returns ``true`` if this is a root shape and is thus the object that is rendered.
  163. .. rst-class:: classref-item-separator
  164. ----
  165. .. _class_CSGShape_method_set_collision_layer_bit:
  166. .. rst-class:: classref-method
  167. void **set_collision_layer_bit** **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)**
  168. Sets individual bits on the layer mask. Use this if you only need to change one layer's value.
  169. .. rst-class:: classref-item-separator
  170. ----
  171. .. _class_CSGShape_method_set_collision_mask_bit:
  172. .. rst-class:: classref-method
  173. void **set_collision_mask_bit** **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)**
  174. Sets individual bits on the collision mask. Use this if you only need to change one layer's value.
  175. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  176. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  177. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  178. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`