Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
GPUParticlesCollisionHeightField3D
繼承: GPUParticlesCollision3D < VisualInstance3D < Node3D < Node < Object
球狀的 3D 粒子碰撞形狀,影響 GPUParticles3D 節點。
說明
即時高度圖形狀的 3D 粒子吸引器會影響 GPUParticles3D 節點。
高度圖形狀允許有效地表示凸面和凹面物件與單個“地板”(例如地形)的碰撞。它不如 GPUParticlesCollisionSDF3D 靈活,但不需要烘焙步驟。
也可以在移動時、相機移動時、甚至連續時,即時重新生成 GPUParticlesCollisionHeightField3D。這對雨雪等天氣效果、以及具有高度動態幾何體的遊戲來說,GPUParticlesCollisionHeightField3D 是一個不錯的選擇。但是,由於高度圖不能表示懸垂,因此 GPUParticlesCollisionHeightField3D 不適用於室內粒子碰撞。
注意:在 GPUParticles3D 的處理材質上,ParticleProcessMaterial.collision_mode 必須為 true,才能使碰撞生效。
注意:粒子碰撞只影響 GPUParticles3D,不影響 CPUParticles3D。
屬性
|
||
|
||
|
||
|
||
|
方法
get_heightfield_mask_value(layer_number: int) const |
|
void |
set_heightfield_mask_value(layer_number: int, value: bool) |
列舉
enum Resolution: 🔗
Resolution RESOLUTION_256 = 0
生成 256×256 的高度圖。適用於小規模場景,或沒有遠景粒子的較大場景。
Resolution RESOLUTION_512 = 1
生成 512×512 的高度圖。適用於中等規模的場景,或沒有遠景粒子的較大場景。
Resolution RESOLUTION_1024 = 2
生成 1024×1024 的高度圖。適用於具有遠景粒子的大型場景。
Resolution RESOLUTION_2048 = 3
生成 2048×2048 的高度圖。適用於具有遠景粒子的非常大的場景。
Resolution RESOLUTION_4096 = 4
生成 4096×4096 的高度圖。適用於具有遠景粒子的巨大場景。
Resolution RESOLUTION_8192 = 5
生成 8192×8192 的高度圖。適用於具有遠景粒子的巨大場景。
Resolution RESOLUTION_MAX = 6
代表 Resolution 列舉的大小。
enum UpdateMode: 🔗
UpdateMode UPDATE_MODE_WHEN_MOVED = 0
僅在 GPUParticlesCollisionHeightField3D 節點移動時,或者當 follow_camera_enabled 為 true 且相機移動時,更新高度圖。可以通過向任意方向稍微移動 GPUParticlesCollisionHeightField3D 或者呼叫 RenderingServer.particles_collision_height_field_update() 來強制更新。
UpdateMode UPDATE_MODE_ALWAYS = 1
每影格更新高度圖。這具有顯著的性能成本。只有當粒子可以碰撞的幾何體在遊戲過程中發生顯著變化時,才應使用該更新選項。
屬性說明
bool follow_camera_enabled = false 🔗
如果為 true,則 GPUParticlesCollisionHeightField3D 將在全域空間中跟隨目前相機。GPUParticlesCollisionHeightField3D 不需要是該 Camera3D 節點的子節點也能工作。
跟隨相機會有性能成本,因為它會在相機移動時強制更新高度圖。如果 follow_camera_enabled 為 true,請考慮降低 resolution 以提高性能。
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().
Resolution resolution = 2 🔗
void set_resolution(value: Resolution)
Resolution get_resolution()
更高的解析度可以更準確地表示大場景中的小細節,但會降低性能。如果 update_mode 為 UPDATE_MODE_ALWAYS,請考慮使用可能的最低解析度。
Vector3 size = Vector3(2, 2, 2) 🔗
碰撞高度圖的 3D 單位大小。為了提高高度圖品質,size 應被設定得盡可能小,同時覆蓋需要的場景部分。
UpdateMode update_mode = 0 🔗
void set_update_mode(value: UpdateMode)
UpdateMode get_update_mode()
生成的高度圖的更新策略。
方法說明
bool get_heightfield_mask_value(layer_number: int) 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(layer_number: int, value: bool) 🔗
Based on value, enables or disables the specified layer in the heightfield_mask, given a layer_number between 1 and 20, inclusive.