Class reference

GPUParticlesCollisionHeightField3D

Inherits GPUParticlesCollision3D

A real-time heightmap-shaped 3D particle collision shape affecting GPUParticles3D nodes.

Description

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.collision_mode must be true on the GPUParticles3D's process material for collision to work. Note: Particle collision only affects GPUParticles3D, not CPUParticles3D.

Properties

int heightfield_mask = 1048575

The visual layers to account for when updating the heightmap. Only MeshInstance3Ds whose VisualInstance3D.layers match with this heightfield_mask 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 heightfield_mask 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 heightfield_mask using a script allows you to toggle those reserved layers, which can be useful for editor plugins. To adjust heightfield_mask more easily using a script, use get_heightfield_mask_value() and set_heightfield_mask_value().

int resolution = 2

Higher resolutions can represent small details more accurately in large scenes, at the cost of lower performance. If update_mode is UPDATE_MODE_ALWAYS, consider using the lowest resolution possible.

Vector3 size = Vector3(2, 2, 2)

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.

int update_mode = 0

The update policy to use for the generated heightmap.

Methods

bool get_heightfield_mask_value(int layer_number) const

Returns true if the specified layer of the heightfield_mask is enabled, given a layer_number between 1 and 20, inclusive.

void set_heightfield_mask_value(int layer_number, bool value)

Based on value, enables or disables the specified layer in the heightfield_mask, given a layer_number between 1 and 20, inclusive.

Constants

RESOLUTION_256 = 0

Enum: Resolution

Generate a 256×256 heightmap. Intended for small-scale scenes, or larger scenes with no distant particles.

RESOLUTION_512 = 1

Enum: Resolution

Generate a 512×512 heightmap. Intended for medium-scale scenes, or larger scenes with no distant particles.

RESOLUTION_1024 = 2

Enum: Resolution

Generate a 1024×1024 heightmap. Intended for large scenes with distant particles.

RESOLUTION_2048 = 3

Enum: Resolution

Generate a 2048×2048 heightmap. Intended for very large scenes with distant particles.

RESOLUTION_4096 = 4

Enum: Resolution

Generate a 4096×4096 heightmap. Intended for huge scenes with distant particles.

RESOLUTION_8192 = 5

Enum: Resolution

Generate a 8192×8192 heightmap. Intended for gigantic scenes with distant particles.

RESOLUTION_MAX = 6

Enum: Resolution

Represents the size of the Resolution enum.

UPDATE_MODE_ALWAYS = 1

Enum: UpdateMode

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.

Source revision 5592dc3a7a61
Connection interrupted. Reload×

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.