Documentation
¶
Overview ¶
A real-time heightmap-shaped 3D particle collision shape affecting GPUParticles3D nodes.
Heightmap shapes allow for efficiently representing collisions for convex and concave objects with a single "floor" (such as terrain). This is less flexible than GPUParticlesCollisionSDF3D, but it doesn't require a baking step.
GPUParticlesCollisionHeightField3D can also be regenerated in real-time when it is moved, when the camera moves, or even continuously. This makes GPUParticlesCollisionHeightField3D a good choice for weather effects such as rain and snow and games with highly dynamic geometry. However, this class is limited since heightmaps cannot represent overhangs (e.g. indoors or caves).
Note: ParticleProcessMaterial.CollisionMode must be true on the GPUParticles3D's process material for collision to work.
Note: Particle collision only affects GPUParticles3D, not CPUParticles3D.
Index ¶
- type Advanced
- type Any
- type Extension
- func (self *Extension[T]) AsGPUParticlesCollision3D() GPUParticlesCollision3D.Instance
- func (self *Extension[T]) AsGPUParticlesCollisionHeightField3D() Instance
- func (self *Extension[T]) AsNode() Node.Instance
- func (self *Extension[T]) AsNode3D() Node3D.Instance
- func (self *Extension[T]) AsObject() [1]gd.Object
- func (self *Extension[T]) AsVisualInstance3D() VisualInstance3D.Instance
- type ID
- type Instance
- func (self Instance) AsGPUParticlesCollision3D() GPUParticlesCollision3D.Instance
- func (self Instance) AsGPUParticlesCollisionHeightField3D() Instance
- func (self Instance) AsNode() Node.Instance
- func (self Instance) AsNode3D() Node3D.Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsVisualInstance3D() VisualInstance3D.Instance
- func (self Instance) FollowCameraEnabled() bool
- func (self Instance) GetHeightfieldMaskValue(layer_number int) bool
- func (self Instance) HeightfieldMask() int
- func (self Instance) ID() ID
- func (self Instance) Resolution() Resolution
- func (self Instance) SetFollowCameraEnabled(value bool)
- func (self Instance) SetHeightfieldMask(value int)
- func (self Instance) SetHeightfieldMaskValue(layer_number int, value bool)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetResolution(value Resolution)
- func (self Instance) SetSize(value Vector3.XYZ)
- func (self Instance) SetUpdateMode(value UpdateMode)
- func (self Instance) Size() Vector3.XYZ
- func (self Instance) UpdateMode() UpdateMode
- func (self Instance) Virtual(name string) reflect.Value
- type Resolution
- type UpdateMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Advanced ¶
type Advanced = class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
type Extension ¶
Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension
func (*Extension[T]) AsGPUParticlesCollision3D ¶
func (self *Extension[T]) AsGPUParticlesCollision3D() GPUParticlesCollision3D.Instance
func (*Extension[T]) AsGPUParticlesCollisionHeightField3D ¶
func (*Extension[T]) AsVisualInstance3D ¶
func (self *Extension[T]) AsVisualInstance3D() VisualInstance3D.Instance
type ID ¶
ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.
type Instance ¶
type Instance [1]gdclass.GPUParticlesCollisionHeightField3D
Instance of the class with convieniently typed arguments and results.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) AsGPUParticlesCollision3D ¶
func (self Instance) AsGPUParticlesCollision3D() GPUParticlesCollision3D.Instance
func (Instance) AsGPUParticlesCollisionHeightField3D ¶
func (Instance) AsVisualInstance3D ¶
func (self Instance) AsVisualInstance3D() VisualInstance3D.Instance
func (Instance) FollowCameraEnabled ¶
If true, the GPUParticlesCollisionHeightField3D will follow the current camera in global space. The GPUParticlesCollisionHeightField3D does not need to be a child of the Camera3D node for this to work.
Following the camera has a performance cost, as it will force the heightmap to update whenever the camera moves. Consider lowering Resolution to improve performance if FollowCameraEnabled is true.
func (Instance) GetHeightfieldMaskValue ¶
Returns true if the specified layer of the HeightfieldMask is enabled, given a 'layer_number' between 1 and 20, inclusive.
func (Instance) HeightfieldMask ¶
The visual layers to account for when updating the heightmap. Only MeshInstance3Ds whose VisualInstance3D.Layers match with this HeightfieldMask will be included in the heightmap collision update. By default, all 20 user-visible layers are taken into account for updating the heightmap collision.
Note: Since the HeightfieldMask allows for 32 layers to be stored in total, there are an additional 12 layers that are only used internally by the engine and aren't exposed in the editor. Setting HeightfieldMask using a script allows you to toggle those reserved layers, which can be useful for editor plugins.
To adjust HeightfieldMask more easily using a script, use GetHeightfieldMaskValue and SetHeightfieldMaskValue.
func (Instance) Resolution ¶
func (self Instance) Resolution() Resolution
Higher resolutions can represent small details more accurately in large scenes, at the cost of lower performance. If UpdateMode is UpdateModeAlways, consider using the lowest resolution possible.
func (Instance) SetFollowCameraEnabled ¶
SetFollowCameraEnabled sets the property returned by [IsFollowCameraEnabled].
func (Instance) SetHeightfieldMask ¶
SetHeightfieldMask sets the property returned by [GetHeightfieldMask].
func (Instance) SetHeightfieldMaskValue ¶
Based on 'value', enables or disables the specified layer in the HeightfieldMask, given a 'layer_number' between 1 and 20, inclusive.
func (Instance) SetResolution ¶
func (self Instance) SetResolution(value Resolution)
SetResolution sets the property returned by [GetResolution].
func (Instance) SetUpdateMode ¶
func (self Instance) SetUpdateMode(value UpdateMode)
SetUpdateMode sets the property returned by [GetUpdateMode].
func (Instance) Size ¶
The collision heightmap's size in 3D units. To improve heightmap quality, Size should be set as small as possible while covering the parts of the scene you need.
func (Instance) UpdateMode ¶
func (self Instance) UpdateMode() UpdateMode
The update policy to use for the generated heightmap.
type Resolution ¶
type Resolution int //gd:GPUParticlesCollisionHeightField3D.Resolution
const ( // Generate a 256×256 heightmap. Intended for small-scale scenes, or larger scenes with no distant particles. Resolution256 Resolution = 0 // Generate a 512×512 heightmap. Intended for medium-scale scenes, or larger scenes with no distant particles. Resolution512 Resolution = 1 // Generate a 1024×1024 heightmap. Intended for large scenes with distant particles. Resolution1024 Resolution = 2 // Generate a 2048×2048 heightmap. Intended for very large scenes with distant particles. Resolution2048 Resolution = 3 // Generate a 4096×4096 heightmap. Intended for huge scenes with distant particles. Resolution4096 Resolution = 4 // Generate a 8192×8192 heightmap. Intended for gigantic scenes with distant particles. Resolution8192 Resolution = 5 // Represents the size of the [Resolution] enum. ResolutionMax Resolution = 6 )
type UpdateMode ¶
type UpdateMode int //gd:GPUParticlesCollisionHeightField3D.UpdateMode
const ( // Only update the heightmap when the [GPUParticlesCollisionHeightField3D] node is moved, or when the camera moves if [FollowCameraEnabled] is true. An update can be forced by slightly moving the [GPUParticlesCollisionHeightField3D] in any direction, or by calling [RenderingServer.ParticlesCollisionHeightFieldUpdate]. // // [FollowCameraEnabled]: https://pkg.go.dev/graphics.gd/classdb/#Instance.FollowCameraEnabled // [GPUParticlesCollisionHeightField3D]: https://pkg.go.dev/graphics.gd/classdb/GPUParticlesCollisionHeightField3D // [RenderingServer.ParticlesCollisionHeightFieldUpdate]: https://pkg.go.dev/graphics.gd/classdb/RenderingServer#ParticlesCollisionHeightFieldUpdate UpdateModeWhenMoved UpdateMode = 0 // Update the heightmap every frame. This has a significant performance cost. This update should only be used when geometry that particles can collide with changes significantly during gameplay. UpdateModeAlways UpdateMode = 1 )