-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Add a setting to control applying area transform to gravity #79268
base: master
Are you sure you want to change the base?
Changes from all commits
ba0bd81
4fe566c
6475f5a
5ead893
04f7e9d
ce49503
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -152,6 +152,9 @@ void GodotArea3D::set_param(PhysicsServer3D::AreaParameter p_param, const Varian | |
case PhysicsServer3D::AREA_PARAM_GRAVITY_IS_POINT: | ||
gravity_is_point = p_value; | ||
break; | ||
case PhysicsServer3D::AREA_PARAM_GRAVITY_APPLY_TRANSFORM: | ||
gravity_apply_transform = p_value; | ||
break; | ||
case PhysicsServer3D::AREA_PARAM_GRAVITY_POINT_UNIT_DISTANCE: | ||
gravity_point_unit_distance = p_value; | ||
break; | ||
|
@@ -197,6 +200,8 @@ Variant GodotArea3D::get_param(PhysicsServer3D::AreaParameter p_param) const { | |
return gravity_vector; | ||
case PhysicsServer3D::AREA_PARAM_GRAVITY_IS_POINT: | ||
return gravity_is_point; | ||
case PhysicsServer3D::AREA_PARAM_GRAVITY_APPLY_TRANSFORM: | ||
return gravity_apply_transform; | ||
case PhysicsServer3D::AREA_PARAM_GRAVITY_POINT_UNIT_DISTANCE: | ||
return gravity_point_unit_distance; | ||
case PhysicsServer3D::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE: | ||
|
@@ -341,6 +346,8 @@ void GodotArea3D::compute_gravity(const Vector3 &p_position, Vector3 &r_gravity) | |
} else { | ||
r_gravity = v.normalized() * get_gravity(); | ||
} | ||
} else if (gravity_apply_transform) { | ||
r_gravity = get_transform().get_basis().xform(get_gravity_vector()) * get_gravity(); | ||
Comment on lines
+349
to
+350
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. With this code, point gravity will always take the transform into account, but directional gravity will only take the transform into account when 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. I'd say there's a valid use case for not applying transform to the direction, much less so for the point, if we are to break compatibility I'd argue it would be to make both controllable, not make the directional one local |
||
} else { | ||
r_gravity = get_gravity_vector() * get_gravity(); | ||
} | ||
|
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.
This implies that only rotation will apply, I think a more general wording is better