-
-
Notifications
You must be signed in to change notification settings - Fork 23.8k
Better options for billboarding and rotation in particles #113838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
QbieShay
wants to merge
5
commits into
godotengine:master
Choose a base branch
from
QbieShay:qbe/rework-align
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+381
−16
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
63cb95e
save space for transform align extra options
QbieShay 49832c4
added rotate around axis particle align
QbieShay af5144d
use custom for billboarding, add local billboarding
QbieShay 59239c7
local billboard fix
QbieShay 4df27c6
fixed initialization
QbieShay File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -627,7 +627,7 @@ Ref<Skin> GPUParticles3D::get_skin() const { | |||||
| } | ||||||
|
|
||||||
| void GPUParticles3D::set_transform_align(TransformAlign p_align) { | ||||||
| ERR_FAIL_INDEX(uint32_t(p_align), 4); | ||||||
| ERR_FAIL_INDEX(uint32_t(p_align), uint32_t(RS::ParticlesTransformAlign::PARTICLES_TRANSFORM_MAX)); | ||||||
| transform_align = p_align; | ||||||
| RS::get_singleton()->particles_set_transform_align(particles, RS::ParticlesTransformAlign(transform_align)); | ||||||
| } | ||||||
|
|
@@ -636,6 +636,40 @@ GPUParticles3D::TransformAlign GPUParticles3D::get_transform_align() const { | |||||
| return transform_align; | ||||||
| } | ||||||
|
|
||||||
| void GPUParticles3D::set_transform_align_custom_src(RS::ParticlesAlignCustomSrc p_align_custom_src) { | ||||||
| ERR_FAIL_INDEX(uint32_t(p_align_custom_src), uint32_t(RS::ParticlesAlignCustomSrc::PARTICLES_ALIGN_CUSTOM_SRC_MAX)); | ||||||
| transform_align_custom_src = p_align_custom_src; | ||||||
| RS::get_singleton()->particles_set_transform_align_custom_src(particles, transform_align_custom_src); | ||||||
| } | ||||||
|
|
||||||
| RS::ParticlesAlignCustomSrc GPUParticles3D::get_transform_align_custom_src() const { | ||||||
| return transform_align_custom_src; | ||||||
| } | ||||||
|
|
||||||
| void GPUParticles3D::set_transform_align_rotation_axis(RS::ParticlesAlignRotationAxis p_axis) { | ||||||
| ERR_FAIL_INDEX(uint32_t(p_axis), uint32_t(RS::ParticlesAlignRotationAxis::PARTICLES_ALIGN_AXIS_MAX)); | ||||||
| transform_align_rotation_axis = p_axis; | ||||||
| RS::get_singleton()->particles_set_transform_align_rotation_axis(particles, p_axis); | ||||||
| } | ||||||
|
|
||||||
| RS::ParticlesAlignRotationAxis GPUParticles3D::get_transform_align_rotation_axis() const { | ||||||
| return transform_align_rotation_axis; | ||||||
| } | ||||||
|
|
||||||
| uint32_t GPUParticles3D::compute_align_flags() const { | ||||||
| return uint32_t(transform_align_use_velocity) & uint32_t(1); | ||||||
| } | ||||||
|
|
||||||
| void GPUParticles3D::set_transform_align_use_velocity(bool p_align_to_velocity){ | ||||||
| transform_align_use_velocity = p_align_to_velocity; | ||||||
| RS::get_singleton()->particles_set_transform_align_flags(particles, compute_align_flags()); | ||||||
|
|
||||||
| } | ||||||
|
|
||||||
| bool GPUParticles3D::get_transform_align_use_velocity() const{ | ||||||
| return transform_align_use_velocity; | ||||||
| } | ||||||
|
|
||||||
| void GPUParticles3D::convert_from_particles(Node *p_particles) { | ||||||
| CPUParticles3D *cpu_particles = Object::cast_to<CPUParticles3D>(p_particles); | ||||||
| ERR_FAIL_NULL_MSG(cpu_particles, "Only CPUParticles3D nodes can be converted to GPUParticles3D."); | ||||||
|
|
@@ -807,6 +841,16 @@ void GPUParticles3D::_bind_methods() { | |||||
| ClassDB::bind_method(D_METHOD("set_transform_align", "align"), &GPUParticles3D::set_transform_align); | ||||||
| ClassDB::bind_method(D_METHOD("get_transform_align"), &GPUParticles3D::get_transform_align); | ||||||
|
|
||||||
| ClassDB::bind_method(D_METHOD("set_transform_align_custom_src", "align"), &GPUParticles3D::set_transform_align_custom_src); | ||||||
| ClassDB::bind_method(D_METHOD("get_transform_align_custom_src"), &GPUParticles3D::get_transform_align_custom_src); | ||||||
|
|
||||||
| ClassDB::bind_method(D_METHOD("set_transform_align_rotation_axis", "align"), &GPUParticles3D::set_transform_align_rotation_axis); | ||||||
| ClassDB::bind_method(D_METHOD("get_transform_align_rotation_axis"), &GPUParticles3D::get_transform_align_rotation_axis); | ||||||
|
|
||||||
| ClassDB::bind_method(D_METHOD("set_transform_align_use_velocity", "align_use_velocity"), &GPUParticles3D::set_transform_align_use_velocity); | ||||||
| ClassDB::bind_method(D_METHOD("get_transform_align_use_velocity"), &GPUParticles3D::get_transform_align_use_velocity); | ||||||
|
|
||||||
|
|
||||||
| ClassDB::bind_method(D_METHOD("convert_from_particles", "particles"), &GPUParticles3D::convert_from_particles); | ||||||
|
|
||||||
| ClassDB::bind_method(D_METHOD("set_amount_ratio", "ratio"), &GPUParticles3D::set_amount_ratio); | ||||||
|
|
@@ -841,7 +885,11 @@ void GPUParticles3D::_bind_methods() { | |||||
| ADD_PROPERTY(PropertyInfo(Variant::AABB, "visibility_aabb", PROPERTY_HINT_NONE, "suffix:m"), "set_visibility_aabb", "get_visibility_aabb"); | ||||||
| ADD_PROPERTY(PropertyInfo(Variant::BOOL, "local_coords"), "set_use_local_coordinates", "get_use_local_coordinates"); | ||||||
| ADD_PROPERTY(PropertyInfo(Variant::INT, "draw_order", PROPERTY_HINT_ENUM, "Index,Lifetime,Reverse Lifetime,View Depth"), "set_draw_order", "get_draw_order"); | ||||||
| ADD_PROPERTY(PropertyInfo(Variant::INT, "transform_align", PROPERTY_HINT_ENUM, "Disabled,Z-Billboard,Y to Velocity,Z-Billboard + Y to Velocity"), "set_transform_align", "get_transform_align"); | ||||||
| ADD_PROPERTY(PropertyInfo(Variant::INT, "transform_align", PROPERTY_HINT_ENUM, "Disabled,Z-Billboard,Y to Velocity,Z-Billboard + Y to Velocity,Rotate around Axis, Local Billboard"), "set_transform_align", "get_transform_align"); | ||||||
| ADD_PROPERTY(PropertyInfo(Variant::INT, "transform_align_custom_src", PROPERTY_HINT_ENUM, "Disabled, X, Y, Z, W"), "set_transform_align_custom_src", "get_transform_align_custom_src"); | ||||||
| ADD_PROPERTY(PropertyInfo(Variant::INT, "transform_align_rotation_axis", PROPERTY_HINT_ENUM, "X, Y, Z"), "set_transform_align_rotation_axis", "get_transform_align_rotation_axis"); | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| ADD_PROPERTY(PropertyInfo(Variant::BOOL, "transform_align_use_velocity"), "set_transform_align_use_velocity", "get_transform_align_use_velocity"); | ||||||
|
|
||||||
| ADD_GROUP("Trails", "trail_"); | ||||||
| ADD_PROPERTY(PropertyInfo(Variant::BOOL, "trail_enabled", PROPERTY_HINT_GROUP_ENABLE), "set_trail_enabled", "is_trail_enabled"); | ||||||
| ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "trail_lifetime", PROPERTY_HINT_RANGE, "0.01,10,0.01,or_greater,suffix:s"), "set_trail_lifetime", "get_trail_lifetime"); | ||||||
|
|
@@ -900,6 +948,9 @@ GPUParticles3D::GPUParticles3D() { | |||||
| set_speed_scale(1); | ||||||
| set_collision_base_size(collision_base_size); | ||||||
| set_transform_align(TRANSFORM_ALIGN_DISABLED); | ||||||
| set_transform_align_custom_src(RS::ParticlesAlignCustomSrc::PARTICLES_ALIGN_CUSTOM_SRC_X); | ||||||
| set_transform_align_rotation_axis(RS::ParticlesAlignRotationAxis::PARTICLES_ALIGN_AXIS_Y); | ||||||
| set_transform_align_use_velocity(true); | ||||||
| set_use_fixed_seed(false); | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.