Merge pull request #54810 from nekomatata/area-separate-override-modes

Separate space override modes for gravity/damping in Area
This commit is contained in:
Camille Mohr-Daurat 2021-11-11 15:11:21 -07:00 committed by GitHub
commit 11e03ae7f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 621 additions and 332 deletions

View File

@ -50,6 +50,9 @@
The rate at which objects stop spinning in this area. Represents the angular velocity lost per second. The rate at which objects stop spinning in this area. Represents the angular velocity lost per second.
See [member ProjectSettings.physics/2d/default_angular_damp] for more details about damping. See [member ProjectSettings.physics/2d/default_angular_damp] for more details about damping.
</member> </member>
<member name="angular_damp_space_override" type="int" setter="set_angular_damp_space_override_mode" getter="get_angular_damp_space_override_mode" enum="Area2D.SpaceOverride" default="0">
Override mode for angular damping calculations within this area. See [enum SpaceOverride] for possible values.
</member>
<member name="audio_bus_name" type="StringName" setter="set_audio_bus_name" getter="get_audio_bus_name" default="&amp;&quot;Master&quot;"> <member name="audio_bus_name" type="StringName" setter="set_audio_bus_name" getter="get_audio_bus_name" default="&amp;&quot;Master&quot;">
The name of the area's audio bus. The name of the area's audio bus.
</member> </member>
@ -57,21 +60,30 @@
If [code]true[/code], the area's audio bus overrides the default audio bus. If [code]true[/code], the area's audio bus overrides the default audio bus.
</member> </member>
<member name="gravity" type="float" setter="set_gravity" getter="get_gravity" default="980.0"> <member name="gravity" type="float" setter="set_gravity" getter="get_gravity" default="980.0">
The area's gravity intensity (in pixels per second squared). This value multiplies the gravity vector. This is useful to alter the force of gravity without altering its direction. The area's gravity intensity (in pixels per second squared). This value multiplies the gravity direction. This is useful to alter the force of gravity without altering its direction.
</member> </member>
<member name="gravity_distance_scale" type="float" setter="set_gravity_distance_scale" getter="get_gravity_distance_scale" default="0.0"> <member name="gravity_direction" type="Vector2" setter="set_gravity_direction" getter="get_gravity_direction" default="Vector2(0, 1)">
The falloff factor for point gravity. The greater the value, the faster gravity decreases with distance. The area's gravity vector (not normalized).
</member> </member>
<member name="gravity_point" type="bool" setter="set_gravity_is_point" getter="is_gravity_a_point" default="false"> <member name="gravity_point" type="bool" setter="set_gravity_is_point" getter="is_gravity_a_point" default="false">
If [code]true[/code], gravity is calculated from a point (set via [member gravity_vec]). See also [member space_override]. If [code]true[/code], gravity is calculated from a point (set via [member gravity_point_center]). See also [member gravity_space_override].
</member> </member>
<member name="gravity_vec" type="Vector2" setter="set_gravity_vector" getter="get_gravity_vector" default="Vector2(0, 1)"> <member name="gravity_point_center" type="Vector2" setter="set_gravity_point_center" getter="get_gravity_point_center" default="Vector2(0, 1)">
The area's gravity vector (not normalized). If gravity is a point (see [member gravity_point]), this will be the point of attraction. If gravity is a point (see [member gravity_point]), this will be the point of attraction.
</member>
<member name="gravity_point_distance_scale" type="float" setter="set_gravity_point_distance_scale" getter="get_gravity_point_distance_scale" default="0.0">
The falloff factor for point gravity. The greater the value, the faster gravity decreases with distance.
</member>
<member name="gravity_space_override" type="int" setter="set_gravity_space_override_mode" getter="get_gravity_space_override_mode" enum="Area2D.SpaceOverride" default="0">
Override mode for gravity calculations within this area. See [enum SpaceOverride] for possible values.
</member> </member>
<member name="linear_damp" type="float" setter="set_linear_damp" getter="get_linear_damp" default="0.1"> <member name="linear_damp" type="float" setter="set_linear_damp" getter="get_linear_damp" default="0.1">
The rate at which objects stop moving in this area. Represents the linear velocity lost per second. The rate at which objects stop moving in this area. Represents the linear velocity lost per second.
See [member ProjectSettings.physics/2d/default_linear_damp] for more details about damping. See [member ProjectSettings.physics/2d/default_linear_damp] for more details about damping.
</member> </member>
<member name="linear_damp_space_override" type="int" setter="set_linear_damp_space_override_mode" getter="get_linear_damp_space_override_mode" enum="Area2D.SpaceOverride" default="0">
Override mode for linear damping calculations within this area. See [enum SpaceOverride] for possible values.
</member>
<member name="monitorable" type="bool" setter="set_monitorable" getter="is_monitorable" default="true"> <member name="monitorable" type="bool" setter="set_monitorable" getter="is_monitorable" default="true">
If [code]true[/code], other monitoring areas can detect this area. If [code]true[/code], other monitoring areas can detect this area.
</member> </member>
@ -81,9 +93,6 @@
<member name="priority" type="float" setter="set_priority" getter="get_priority" default="0.0"> <member name="priority" type="float" setter="set_priority" getter="get_priority" default="0.0">
The area's priority. Higher priority areas are processed first. The area's priority. Higher priority areas are processed first.
</member> </member>
<member name="space_override" type="int" setter="set_space_override_mode" getter="get_space_override_mode" enum="Area2D.SpaceOverride" default="0">
Override mode for gravity and damping calculations within this area. See [enum SpaceOverride] for possible values.
</member>
</members> </members>
<signals> <signals>
<signal name="area_entered"> <signal name="area_entered">

View File

@ -48,6 +48,9 @@
The rate at which objects stop spinning in this area. Represents the angular velocity lost per second. The rate at which objects stop spinning in this area. Represents the angular velocity lost per second.
See [member ProjectSettings.physics/3d/default_angular_damp] for more details about damping. See [member ProjectSettings.physics/3d/default_angular_damp] for more details about damping.
</member> </member>
<member name="angular_damp_space_override" type="int" setter="set_angular_damp_space_override_mode" getter="get_angular_damp_space_override_mode" enum="Area3D.SpaceOverride" default="0">
Override mode for angular damping calculations within this area. See [enum SpaceOverride] for possible values.
</member>
<member name="audio_bus_name" type="StringName" setter="set_audio_bus_name" getter="get_audio_bus_name" default="&amp;&quot;Master&quot;"> <member name="audio_bus_name" type="StringName" setter="set_audio_bus_name" getter="get_audio_bus_name" default="&amp;&quot;Master&quot;">
The name of the area's audio bus. The name of the area's audio bus.
</member> </member>
@ -55,21 +58,30 @@
If [code]true[/code], the area's audio bus overrides the default audio bus. If [code]true[/code], the area's audio bus overrides the default audio bus.
</member> </member>
<member name="gravity" type="float" setter="set_gravity" getter="get_gravity" default="9.8"> <member name="gravity" type="float" setter="set_gravity" getter="get_gravity" default="9.8">
The area's gravity intensity (in meters per second squared). This value multiplies the gravity vector. This is useful to alter the force of gravity without altering its direction. The area's gravity intensity (in meters per second squared). This value multiplies the gravity direction. This is useful to alter the force of gravity without altering its direction.
</member> </member>
<member name="gravity_distance_scale" type="float" setter="set_gravity_distance_scale" getter="get_gravity_distance_scale" default="0.0"> <member name="gravity_direction" type="Vector3" setter="set_gravity_direction" getter="get_gravity_direction" default="Vector3(0, -1, 0)">
The falloff factor for point gravity. The greater the value, the faster gravity decreases with distance. The area's gravity vector (not normalized).
</member> </member>
<member name="gravity_point" type="bool" setter="set_gravity_is_point" getter="is_gravity_a_point" default="false"> <member name="gravity_point" type="bool" setter="set_gravity_is_point" getter="is_gravity_a_point" default="false">
If [code]true[/code], gravity is calculated from a point (set via [member gravity_vec]). See also [member space_override]. If [code]true[/code], gravity is calculated from a point (set via [member gravity_point_center]). See also [member gravity_space_override].
</member> </member>
<member name="gravity_vec" type="Vector3" setter="set_gravity_vector" getter="get_gravity_vector" default="Vector3(0, -1, 0)"> <member name="gravity_point_center" type="Vector3" setter="set_gravity_point_center" getter="get_gravity_point_center" default="Vector3(0, -1, 0)">
The area's gravity vector (not normalized). If gravity is a point (see [member gravity_point]), this will be the point of attraction. If gravity is a point (see [member gravity_point]), this will be the point of attraction.
</member>
<member name="gravity_point_distance_scale" type="float" setter="set_gravity_point_distance_scale" getter="get_gravity_point_distance_scale" default="0.0">
The falloff factor for point gravity. The greater the value, the faster gravity decreases with distance.
</member>
<member name="gravity_space_override" type="int" setter="set_gravity_space_override_mode" getter="get_gravity_space_override_mode" enum="Area3D.SpaceOverride" default="0">
Override mode for gravity calculations within this area. See [enum SpaceOverride] for possible values.
</member> </member>
<member name="linear_damp" type="float" setter="set_linear_damp" getter="get_linear_damp" default="0.1"> <member name="linear_damp" type="float" setter="set_linear_damp" getter="get_linear_damp" default="0.1">
The rate at which objects stop moving in this area. Represents the linear velocity lost per second. The rate at which objects stop moving in this area. Represents the linear velocity lost per second.
See [member ProjectSettings.physics/3d/default_linear_damp] for more details about damping. See [member ProjectSettings.physics/3d/default_linear_damp] for more details about damping.
</member> </member>
<member name="linear_damp_space_override" type="int" setter="set_linear_damp_space_override_mode" getter="get_linear_damp_space_override_mode" enum="Area3D.SpaceOverride" default="0">
Override mode for linear damping calculations within this area. See [enum SpaceOverride] for possible values.
</member>
<member name="monitorable" type="bool" setter="set_monitorable" getter="is_monitorable" default="true"> <member name="monitorable" type="bool" setter="set_monitorable" getter="is_monitorable" default="true">
If [code]true[/code], other monitoring areas can detect this area. If [code]true[/code], other monitoring areas can detect this area.
</member> </member>
@ -91,9 +103,6 @@
<member name="reverb_bus_uniformity" type="float" setter="set_reverb_uniformity" getter="get_reverb_uniformity" default="0.0"> <member name="reverb_bus_uniformity" type="float" setter="set_reverb_uniformity" getter="get_reverb_uniformity" default="0.0">
The degree to which this area's reverb is a uniform effect. Ranges from [code]0[/code] to [code]1[/code] with [code]0.1[/code] precision. The degree to which this area's reverb is a uniform effect. Ranges from [code]0[/code] to [code]1[/code] with [code]0.1[/code] precision.
</member> </member>
<member name="space_override" type="int" setter="set_space_override_mode" getter="get_space_override_mode" enum="Area3D.SpaceOverride" default="0">
Override mode for gravity and damping calculations within this area. See [enum SpaceOverride] for possible values.
</member>
<member name="wind_attenuation_factor" type="float" setter="set_wind_attenuation_factor" getter="get_wind_attenuation_factor" default="0.0"> <member name="wind_attenuation_factor" type="float" setter="set_wind_attenuation_factor" getter="get_wind_attenuation_factor" default="0.0">
The exponential rate at which wind force decreases with distance from its origin. The exponential rate at which wind force decreases with distance from its origin.
</member> </member>

View File

@ -98,13 +98,6 @@
Returns the space assigned to the area. Returns the space assigned to the area.
</description> </description>
</method> </method>
<method name="area_get_space_override_mode" qualifiers="const">
<return type="int" enum="PhysicsServer2D.AreaSpaceOverrideMode" />
<argument index="0" name="area" type="RID" />
<description>
Returns the space override mode for the area.
</description>
</method>
<method name="area_get_transform" qualifiers="const"> <method name="area_get_transform" qualifiers="const">
<return type="Transform2D" /> <return type="Transform2D" />
<argument index="0" name="area" type="RID" /> <argument index="0" name="area" type="RID" />
@ -207,14 +200,6 @@
Assigns a space to the area. Assigns a space to the area.
</description> </description>
</method> </method>
<method name="area_set_space_override_mode">
<return type="void" />
<argument index="0" name="area" type="RID" />
<argument index="1" name="mode" type="int" enum="PhysicsServer2D.AreaSpaceOverrideMode" />
<description>
Sets the space override mode for the area. See [enum AreaSpaceOverrideMode] for a list of available modes.
</description>
</method>
<method name="area_set_transform"> <method name="area_set_transform">
<return type="void" /> <return type="void" />
<argument index="0" name="area" type="RID" /> <argument index="0" name="area" type="RID" />
@ -855,28 +840,37 @@
<constant name="SHAPE_CUSTOM" value="8" enum="ShapeType"> <constant name="SHAPE_CUSTOM" value="8" enum="ShapeType">
This constant is used internally by the engine. Any attempt to create this kind of shape results in an error. This constant is used internally by the engine. Any attempt to create this kind of shape results in an error.
</constant> </constant>
<constant name="AREA_PARAM_GRAVITY" value="0" enum="AreaParameter"> <constant name="AREA_PARAM_GRAVITY_OVERRIDE_MODE" value="0" enum="AreaParameter">
Constant to set/get gravity override mode in an area. See [enum AreaSpaceOverrideMode] for possible values.
</constant>
<constant name="AREA_PARAM_GRAVITY" value="1" enum="AreaParameter">
Constant to set/get gravity strength in an area. Constant to set/get gravity strength in an area.
</constant> </constant>
<constant name="AREA_PARAM_GRAVITY_VECTOR" value="1" enum="AreaParameter"> <constant name="AREA_PARAM_GRAVITY_VECTOR" value="2" enum="AreaParameter">
Constant to set/get gravity vector/center in an area. Constant to set/get gravity vector/center in an area.
</constant> </constant>
<constant name="AREA_PARAM_GRAVITY_IS_POINT" value="2" enum="AreaParameter"> <constant name="AREA_PARAM_GRAVITY_IS_POINT" value="3" enum="AreaParameter">
Constant to set/get whether the gravity vector of an area is a direction, or a center point. Constant to set/get whether the gravity vector of an area is a direction, or a center point.
</constant> </constant>
<constant name="AREA_PARAM_GRAVITY_DISTANCE_SCALE" value="3" enum="AreaParameter"> <constant name="AREA_PARAM_GRAVITY_DISTANCE_SCALE" value="4" enum="AreaParameter">
Constant to set/get the falloff factor for point gravity of an area. The greater this value is, the faster the strength of gravity decreases with the square of distance. Constant to set/get the falloff factor for point gravity of an area. The greater this value is, the faster the strength of gravity decreases with the square of distance.
</constant> </constant>
<constant name="AREA_PARAM_GRAVITY_POINT_ATTENUATION" value="4" enum="AreaParameter"> <constant name="AREA_PARAM_GRAVITY_POINT_ATTENUATION" value="5" enum="AreaParameter">
This constant was used to set/get the falloff factor for point gravity. It has been superseded by [constant AREA_PARAM_GRAVITY_DISTANCE_SCALE]. This constant was used to set/get the falloff factor for point gravity. It has been superseded by [constant AREA_PARAM_GRAVITY_DISTANCE_SCALE].
</constant> </constant>
<constant name="AREA_PARAM_LINEAR_DAMP" value="5" enum="AreaParameter"> <constant name="AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE" value="6" enum="AreaParameter">
Constant to set/get the linear dampening factor of an area. Constant to set/get linear damping override mode in an area. See [enum AreaSpaceOverrideMode] for possible values.
</constant> </constant>
<constant name="AREA_PARAM_ANGULAR_DAMP" value="6" enum="AreaParameter"> <constant name="AREA_PARAM_LINEAR_DAMP" value="7" enum="AreaParameter">
Constant to set/get the angular dampening factor of an area. Constant to set/get the linear damping factor of an area.
</constant> </constant>
<constant name="AREA_PARAM_PRIORITY" value="7" enum="AreaParameter"> <constant name="AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE" value="8" enum="AreaParameter">
Constant to set/get angular damping override mode in an area. See [enum AreaSpaceOverrideMode] for possible values.
</constant>
<constant name="AREA_PARAM_ANGULAR_DAMP" value="9" enum="AreaParameter">
Constant to set/get the angular damping factor of an area.
</constant>
<constant name="AREA_PARAM_PRIORITY" value="10" enum="AreaParameter">
Constant to set/get the priority (order of processing) of an area. Constant to set/get the priority (order of processing) of an area.
</constant> </constant>
<constant name="AREA_SPACE_OVERRIDE_DISABLED" value="0" enum="AreaSpaceOverrideMode"> <constant name="AREA_SPACE_OVERRIDE_DISABLED" value="0" enum="AreaSpaceOverrideMode">

View File

@ -85,13 +85,6 @@
Returns the space assigned to the area. Returns the space assigned to the area.
</description> </description>
</method> </method>
<method name="area_get_space_override_mode" qualifiers="const">
<return type="int" enum="PhysicsServer3D.AreaSpaceOverrideMode" />
<argument index="0" name="area" type="RID" />
<description>
Returns the space override mode for the area.
</description>
</method>
<method name="area_get_transform" qualifiers="const"> <method name="area_get_transform" qualifiers="const">
<return type="Transform3D" /> <return type="Transform3D" />
<argument index="0" name="area" type="RID" /> <argument index="0" name="area" type="RID" />
@ -201,14 +194,6 @@
Assigns a space to the area. Assigns a space to the area.
</description> </description>
</method> </method>
<method name="area_set_space_override_mode">
<return type="void" />
<argument index="0" name="area" type="RID" />
<argument index="1" name="mode" type="int" enum="PhysicsServer3D.AreaSpaceOverrideMode" />
<description>
Sets the space override mode for the area. The modes are described in the [enum AreaSpaceOverrideMode] constants.
</description>
</method>
<method name="area_set_transform"> <method name="area_set_transform">
<return type="void" /> <return type="void" />
<argument index="0" name="area" type="RID" /> <argument index="0" name="area" type="RID" />
@ -1211,40 +1196,49 @@
<constant name="SHAPE_CUSTOM" value="10" enum="ShapeType"> <constant name="SHAPE_CUSTOM" value="10" enum="ShapeType">
This constant is used internally by the engine. Any attempt to create this kind of shape results in an error. This constant is used internally by the engine. Any attempt to create this kind of shape results in an error.
</constant> </constant>
<constant name="AREA_PARAM_GRAVITY" value="0" enum="AreaParameter"> <constant name="AREA_PARAM_GRAVITY_OVERRIDE_MODE" value="0" enum="AreaParameter">
Constant to set/get gravity override mode in an area. See [enum AreaSpaceOverrideMode] for possible values.
</constant>
<constant name="AREA_PARAM_GRAVITY" value="1" enum="AreaParameter">
Constant to set/get gravity strength in an area. Constant to set/get gravity strength in an area.
</constant> </constant>
<constant name="AREA_PARAM_GRAVITY_VECTOR" value="1" enum="AreaParameter"> <constant name="AREA_PARAM_GRAVITY_VECTOR" value="2" enum="AreaParameter">
Constant to set/get gravity vector/center in an area. Constant to set/get gravity vector/center in an area.
</constant> </constant>
<constant name="AREA_PARAM_GRAVITY_IS_POINT" value="2" enum="AreaParameter"> <constant name="AREA_PARAM_GRAVITY_IS_POINT" value="3" enum="AreaParameter">
Constant to set/get whether the gravity vector of an area is a direction, or a center point. Constant to set/get whether the gravity vector of an area is a direction, or a center point.
</constant> </constant>
<constant name="AREA_PARAM_GRAVITY_DISTANCE_SCALE" value="3" enum="AreaParameter"> <constant name="AREA_PARAM_GRAVITY_DISTANCE_SCALE" value="4" enum="AreaParameter">
Constant to set/get the falloff factor for point gravity of an area. The greater this value is, the faster the strength of gravity decreases with the square of distance. Constant to set/get the falloff factor for point gravity of an area. The greater this value is, the faster the strength of gravity decreases with the square of distance.
</constant> </constant>
<constant name="AREA_PARAM_GRAVITY_POINT_ATTENUATION" value="4" enum="AreaParameter"> <constant name="AREA_PARAM_GRAVITY_POINT_ATTENUATION" value="5" enum="AreaParameter">
This constant was used to set/get the falloff factor for point gravity. It has been superseded by [constant AREA_PARAM_GRAVITY_DISTANCE_SCALE]. This constant was used to set/get the falloff factor for point gravity. It has been superseded by [constant AREA_PARAM_GRAVITY_DISTANCE_SCALE].
</constant> </constant>
<constant name="AREA_PARAM_LINEAR_DAMP" value="5" enum="AreaParameter"> <constant name="AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE" value="6" enum="AreaParameter">
Constant to set/get the linear dampening factor of an area. Constant to set/get linear damping override mode in an area. See [enum AreaSpaceOverrideMode] for possible values.
</constant> </constant>
<constant name="AREA_PARAM_ANGULAR_DAMP" value="6" enum="AreaParameter"> <constant name="AREA_PARAM_LINEAR_DAMP" value="7" enum="AreaParameter">
Constant to set/get the angular dampening factor of an area. Constant to set/get the linear damping factor of an area.
</constant> </constant>
<constant name="AREA_PARAM_PRIORITY" value="7" enum="AreaParameter"> <constant name="AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE" value="8" enum="AreaParameter">
Constant to set/get angular damping override mode in an area. See [enum AreaSpaceOverrideMode] for possible values.
</constant>
<constant name="AREA_PARAM_ANGULAR_DAMP" value="9" enum="AreaParameter">
Constant to set/get the angular damping factor of an area.
</constant>
<constant name="AREA_PARAM_PRIORITY" value="10" enum="AreaParameter">
Constant to set/get the priority (order of processing) of an area. Constant to set/get the priority (order of processing) of an area.
</constant> </constant>
<constant name="AREA_PARAM_WIND_FORCE_MAGNITUDE" value="8" enum="AreaParameter"> <constant name="AREA_PARAM_WIND_FORCE_MAGNITUDE" value="11" enum="AreaParameter">
Constant to set/get the magnitude of area-specific wind force. Constant to set/get the magnitude of area-specific wind force.
</constant> </constant>
<constant name="AREA_PARAM_WIND_SOURCE" value="9" enum="AreaParameter"> <constant name="AREA_PARAM_WIND_SOURCE" value="12" enum="AreaParameter">
Constant to set/get the 3D vector that specifies the origin from which an area-specific wind blows. Constant to set/get the 3D vector that specifies the origin from which an area-specific wind blows.
</constant> </constant>
<constant name="AREA_PARAM_WIND_DIRECTION" value="10" enum="AreaParameter"> <constant name="AREA_PARAM_WIND_DIRECTION" value="13" enum="AreaParameter">
Constant to set/get the 3D vector that specifies the direction in which an area-specific wind blows. Constant to set/get the 3D vector that specifies the direction in which an area-specific wind blows.
</constant> </constant>
<constant name="AREA_PARAM_WIND_ATTENUATION_FACTOR" value="11" enum="AreaParameter"> <constant name="AREA_PARAM_WIND_ATTENUATION_FACTOR" value="14" enum="AreaParameter">
Constant to set/get the exponential rate at which wind force decreases with distance from its origin. Constant to set/get the exponential rate at which wind force decreases with distance from its origin.
</constant> </constant>
<constant name="AREA_SPACE_OVERRIDE_DISABLED" value="0" enum="AreaSpaceOverrideMode"> <constant name="AREA_SPACE_OVERRIDE_DISABLED" value="0" enum="AreaSpaceOverrideMode">

View File

@ -33,13 +33,13 @@
#include "scene/scene_string_names.h" #include "scene/scene_string_names.h"
#include "servers/audio_server.h" #include "servers/audio_server.h"
void Area2D::set_space_override_mode(SpaceOverride p_mode) { void Area2D::set_gravity_space_override_mode(SpaceOverride p_mode) {
space_override = p_mode; gravity_space_override = p_mode;
PhysicsServer2D::get_singleton()->area_set_space_override_mode(get_rid(), PhysicsServer2D::AreaSpaceOverrideMode(p_mode)); PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_GRAVITY_OVERRIDE_MODE, p_mode);
} }
Area2D::SpaceOverride Area2D::get_space_override_mode() const { Area2D::SpaceOverride Area2D::get_gravity_space_override_mode() const {
return space_override; return gravity_space_override;
} }
void Area2D::set_gravity_is_point(bool p_enabled) { void Area2D::set_gravity_is_point(bool p_enabled) {
@ -51,21 +51,30 @@ bool Area2D::is_gravity_a_point() const {
return gravity_is_point; return gravity_is_point;
} }
void Area2D::set_gravity_distance_scale(real_t p_scale) { void Area2D::set_gravity_point_distance_scale(real_t p_scale) {
gravity_distance_scale = p_scale; gravity_distance_scale = p_scale;
PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_GRAVITY_DISTANCE_SCALE, p_scale); PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_GRAVITY_DISTANCE_SCALE, p_scale);
} }
real_t Area2D::get_gravity_distance_scale() const { real_t Area2D::get_gravity_point_distance_scale() const {
return gravity_distance_scale; return gravity_distance_scale;
} }
void Area2D::set_gravity_vector(const Vector2 &p_vec) { void Area2D::set_gravity_point_center(const Vector2 &p_center) {
gravity_vec = p_vec; gravity_vec = p_center;
PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_GRAVITY_VECTOR, p_vec); PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_GRAVITY_VECTOR, p_center);
} }
Vector2 Area2D::get_gravity_vector() const { const Vector2 &Area2D::get_gravity_point_center() const {
return gravity_vec;
}
void Area2D::set_gravity_direction(const Vector2 &p_direction) {
gravity_vec = p_direction;
PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_GRAVITY_VECTOR, p_direction);
}
const Vector2 &Area2D::get_gravity_direction() const {
return gravity_vec; return gravity_vec;
} }
@ -78,6 +87,24 @@ real_t Area2D::get_gravity() const {
return gravity; return gravity;
} }
void Area2D::set_linear_damp_space_override_mode(SpaceOverride p_mode) {
linear_damp_space_override = p_mode;
PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE, p_mode);
}
Area2D::SpaceOverride Area2D::get_linear_damp_space_override_mode() const {
return linear_damp_space_override;
}
void Area2D::set_angular_damp_space_override_mode(SpaceOverride p_mode) {
angular_damp_space_override = p_mode;
PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE, p_mode);
}
Area2D::SpaceOverride Area2D::get_angular_damp_space_override_mode() const {
return angular_damp_space_override;
}
void Area2D::set_linear_damp(real_t p_linear_damp) { void Area2D::set_linear_damp(real_t p_linear_damp) {
linear_damp = p_linear_damp; linear_damp = p_linear_damp;
PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_LINEAR_DAMP, p_linear_damp); PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_LINEAR_DAMP, p_linear_damp);
@ -483,25 +510,56 @@ void Area2D::_validate_property(PropertyInfo &property) const {
} }
property.hint_string = options; property.hint_string = options;
} else if (property.name.begins_with("gravity") && property.name != "gravity_space_override") {
if (gravity_space_override == SPACE_OVERRIDE_DISABLED) {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL;
} else {
if (gravity_is_point) {
if (property.name == "gravity_direction") {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL;
}
} else {
if (property.name.begins_with("gravity_point_")) {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL;
}
}
}
} else if (property.name.begins_with("linear_damp") && property.name != "linear_damp_space_override") {
if (linear_damp_space_override == SPACE_OVERRIDE_DISABLED) {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL;
}
} else if (property.name.begins_with("angular_damp") && property.name != "angular_damp_space_override") {
if (angular_damp_space_override == SPACE_OVERRIDE_DISABLED) {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL;
}
} }
} }
void Area2D::_bind_methods() { void Area2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_space_override_mode", "space_override_mode"), &Area2D::set_space_override_mode); ClassDB::bind_method(D_METHOD("set_gravity_space_override_mode", "space_override_mode"), &Area2D::set_gravity_space_override_mode);
ClassDB::bind_method(D_METHOD("get_space_override_mode"), &Area2D::get_space_override_mode); ClassDB::bind_method(D_METHOD("get_gravity_space_override_mode"), &Area2D::get_gravity_space_override_mode);
ClassDB::bind_method(D_METHOD("set_gravity_is_point", "enable"), &Area2D::set_gravity_is_point); ClassDB::bind_method(D_METHOD("set_gravity_is_point", "enable"), &Area2D::set_gravity_is_point);
ClassDB::bind_method(D_METHOD("is_gravity_a_point"), &Area2D::is_gravity_a_point); ClassDB::bind_method(D_METHOD("is_gravity_a_point"), &Area2D::is_gravity_a_point);
ClassDB::bind_method(D_METHOD("set_gravity_distance_scale", "distance_scale"), &Area2D::set_gravity_distance_scale); ClassDB::bind_method(D_METHOD("set_gravity_point_distance_scale", "distance_scale"), &Area2D::set_gravity_point_distance_scale);
ClassDB::bind_method(D_METHOD("get_gravity_distance_scale"), &Area2D::get_gravity_distance_scale); ClassDB::bind_method(D_METHOD("get_gravity_point_distance_scale"), &Area2D::get_gravity_point_distance_scale);
ClassDB::bind_method(D_METHOD("set_gravity_vector", "vector"), &Area2D::set_gravity_vector); ClassDB::bind_method(D_METHOD("set_gravity_point_center", "center"), &Area2D::set_gravity_point_center);
ClassDB::bind_method(D_METHOD("get_gravity_vector"), &Area2D::get_gravity_vector); ClassDB::bind_method(D_METHOD("get_gravity_point_center"), &Area2D::get_gravity_point_center);
ClassDB::bind_method(D_METHOD("set_gravity_direction", "direction"), &Area2D::set_gravity_direction);
ClassDB::bind_method(D_METHOD("get_gravity_direction"), &Area2D::get_gravity_direction);
ClassDB::bind_method(D_METHOD("set_gravity", "gravity"), &Area2D::set_gravity); ClassDB::bind_method(D_METHOD("set_gravity", "gravity"), &Area2D::set_gravity);
ClassDB::bind_method(D_METHOD("get_gravity"), &Area2D::get_gravity); ClassDB::bind_method(D_METHOD("get_gravity"), &Area2D::get_gravity);
ClassDB::bind_method(D_METHOD("set_linear_damp_space_override_mode", "space_override_mode"), &Area2D::set_linear_damp_space_override_mode);
ClassDB::bind_method(D_METHOD("get_linear_damp_space_override_mode"), &Area2D::get_linear_damp_space_override_mode);
ClassDB::bind_method(D_METHOD("set_angular_damp_space_override_mode", "space_override_mode"), &Area2D::set_angular_damp_space_override_mode);
ClassDB::bind_method(D_METHOD("get_angular_damp_space_override_mode"), &Area2D::get_angular_damp_space_override_mode);
ClassDB::bind_method(D_METHOD("set_linear_damp", "linear_damp"), &Area2D::set_linear_damp); ClassDB::bind_method(D_METHOD("set_linear_damp", "linear_damp"), &Area2D::set_linear_damp);
ClassDB::bind_method(D_METHOD("get_linear_damp"), &Area2D::get_linear_damp); ClassDB::bind_method(D_METHOD("get_linear_damp"), &Area2D::get_linear_damp);
@ -543,13 +601,20 @@ void Area2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "monitorable"), "set_monitorable", "is_monitorable"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "monitorable"), "set_monitorable", "is_monitorable");
ADD_PROPERTY(PropertyInfo(Variant::INT, "priority", PROPERTY_HINT_RANGE, "0,128,1"), "set_priority", "get_priority"); ADD_PROPERTY(PropertyInfo(Variant::INT, "priority", PROPERTY_HINT_RANGE, "0,128,1"), "set_priority", "get_priority");
ADD_GROUP("Physics Overrides", ""); ADD_GROUP("Gravity", "gravity_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "space_override", PROPERTY_HINT_ENUM, "Disabled,Combine,Combine-Replace,Replace,Replace-Combine"), "set_space_override_mode", "get_space_override_mode"); ADD_PROPERTY(PropertyInfo(Variant::INT, "gravity_space_override", PROPERTY_HINT_ENUM, "Disabled,Combine,Combine-Replace,Replace,Replace-Combine", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), "set_gravity_space_override_mode", "get_gravity_space_override_mode");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "gravity_point"), "set_gravity_is_point", "is_gravity_a_point"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "gravity_point", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), "set_gravity_is_point", "is_gravity_a_point");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "gravity_distance_scale", PROPERTY_HINT_RANGE, "0,1024,0.001,or_greater,exp"), "set_gravity_distance_scale", "get_gravity_distance_scale"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "gravity_point_distance_scale", PROPERTY_HINT_RANGE, "0,1024,0.001,or_greater,exp"), "set_gravity_point_distance_scale", "get_gravity_point_distance_scale");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "gravity_vec"), "set_gravity_vector", "get_gravity_vector"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "gravity_point_center"), "set_gravity_point_center", "get_gravity_point_center");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "gravity_direction"), "set_gravity_direction", "get_gravity_direction");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "gravity", PROPERTY_HINT_RANGE, "-4096,4096,0.001,or_lesser,or_greater"), "set_gravity", "get_gravity"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "gravity", PROPERTY_HINT_RANGE, "-4096,4096,0.001,or_lesser,or_greater"), "set_gravity", "get_gravity");
ADD_GROUP("Linear Damp", "linear_damp_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "linear_damp_space_override", PROPERTY_HINT_ENUM, "Disabled,Combine,Combine-Replace,Replace,Replace-Combine", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), "set_linear_damp_space_override_mode", "get_linear_damp_space_override_mode");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "linear_damp", PROPERTY_HINT_RANGE, "0,100,0.001,or_greater"), "set_linear_damp", "get_linear_damp"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "linear_damp", PROPERTY_HINT_RANGE, "0,100,0.001,or_greater"), "set_linear_damp", "get_linear_damp");
ADD_GROUP("Angular Damp", "angular_damp_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "angular_damp_space_override", PROPERTY_HINT_ENUM, "Disabled,Combine,Combine-Replace,Replace,Replace-Combine", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), "set_angular_damp_space_override_mode", "get_angular_damp_space_override_mode");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "angular_damp", PROPERTY_HINT_RANGE, "0,100,0.001,or_greater"), "set_angular_damp", "get_angular_damp"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "angular_damp", PROPERTY_HINT_RANGE, "0,100,0.001,or_greater"), "set_angular_damp", "get_angular_damp");
ADD_GROUP("Audio Bus", "audio_bus_"); ADD_GROUP("Audio Bus", "audio_bus_");
@ -566,7 +631,7 @@ void Area2D::_bind_methods() {
Area2D::Area2D() : Area2D::Area2D() :
CollisionObject2D(PhysicsServer2D::get_singleton()->area_create(), true) { CollisionObject2D(PhysicsServer2D::get_singleton()->area_create(), true) {
set_gravity(980); set_gravity(980);
set_gravity_vector(Vector2(0, 1)); set_gravity_direction(Vector2(0, 1));
set_monitoring(true); set_monitoring(true);
set_monitorable(true); set_monitorable(true);
} }

View File

@ -47,14 +47,19 @@ public:
}; };
private: private:
SpaceOverride space_override = SPACE_OVERRIDE_DISABLED; SpaceOverride gravity_space_override = SPACE_OVERRIDE_DISABLED;
Vector2 gravity_vec; Vector2 gravity_vec;
real_t gravity; real_t gravity;
bool gravity_is_point = false; bool gravity_is_point = false;
real_t gravity_distance_scale = 0.0; real_t gravity_distance_scale = 0.0;
SpaceOverride linear_damp_space_override = SPACE_OVERRIDE_DISABLED;
SpaceOverride angular_damp_space_override = SPACE_OVERRIDE_DISABLED;
real_t linear_damp = 0.1; real_t linear_damp = 0.1;
real_t angular_damp = 1.0; real_t angular_damp = 1.0;
int priority = 0; int priority = 0;
bool monitoring = false; bool monitoring = false;
bool monitorable = false; bool monitorable = false;
bool locked = false; bool locked = false;
@ -133,21 +138,30 @@ protected:
void _validate_property(PropertyInfo &property) const override; void _validate_property(PropertyInfo &property) const override;
public: public:
void set_space_override_mode(SpaceOverride p_mode); void set_gravity_space_override_mode(SpaceOverride p_mode);
SpaceOverride get_space_override_mode() const; SpaceOverride get_gravity_space_override_mode() const;
void set_gravity_is_point(bool p_enabled); void set_gravity_is_point(bool p_enabled);
bool is_gravity_a_point() const; bool is_gravity_a_point() const;
void set_gravity_distance_scale(real_t p_scale); void set_gravity_point_distance_scale(real_t p_scale);
real_t get_gravity_distance_scale() const; real_t get_gravity_point_distance_scale() const;
void set_gravity_vector(const Vector2 &p_vec); void set_gravity_point_center(const Vector2 &p_center);
Vector2 get_gravity_vector() const; const Vector2 &get_gravity_point_center() const;
void set_gravity_direction(const Vector2 &p_direction);
const Vector2 &get_gravity_direction() const;
void set_gravity(real_t p_gravity); void set_gravity(real_t p_gravity);
real_t get_gravity() const; real_t get_gravity() const;
void set_linear_damp_space_override_mode(SpaceOverride p_mode);
SpaceOverride get_linear_damp_space_override_mode() const;
void set_angular_damp_space_override_mode(SpaceOverride p_mode);
SpaceOverride get_angular_damp_space_override_mode() const;
void set_linear_damp(real_t p_linear_damp); void set_linear_damp(real_t p_linear_damp);
real_t get_linear_damp() const; real_t get_linear_damp() const;

View File

@ -33,13 +33,13 @@
#include "scene/scene_string_names.h" #include "scene/scene_string_names.h"
#include "servers/audio_server.h" #include "servers/audio_server.h"
void Area3D::set_space_override_mode(SpaceOverride p_mode) { void Area3D::set_gravity_space_override_mode(SpaceOverride p_mode) {
space_override = p_mode; gravity_space_override = p_mode;
PhysicsServer3D::get_singleton()->area_set_space_override_mode(get_rid(), PhysicsServer3D::AreaSpaceOverrideMode(p_mode)); PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_GRAVITY_OVERRIDE_MODE, p_mode);
} }
Area3D::SpaceOverride Area3D::get_space_override_mode() const { Area3D::SpaceOverride Area3D::get_gravity_space_override_mode() const {
return space_override; return gravity_space_override;
} }
void Area3D::set_gravity_is_point(bool p_enabled) { void Area3D::set_gravity_is_point(bool p_enabled) {
@ -51,21 +51,30 @@ bool Area3D::is_gravity_a_point() const {
return gravity_is_point; return gravity_is_point;
} }
void Area3D::set_gravity_distance_scale(real_t p_scale) { void Area3D::set_gravity_point_distance_scale(real_t p_scale) {
gravity_distance_scale = p_scale; gravity_distance_scale = p_scale;
PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_GRAVITY_DISTANCE_SCALE, p_scale); PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_GRAVITY_DISTANCE_SCALE, p_scale);
} }
real_t Area3D::get_gravity_distance_scale() const { real_t Area3D::get_gravity_point_distance_scale() const {
return gravity_distance_scale; return gravity_distance_scale;
} }
void Area3D::set_gravity_vector(const Vector3 &p_vec) { void Area3D::set_gravity_point_center(const Vector3 &p_center) {
gravity_vec = p_vec; gravity_vec = p_center;
PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR, p_vec); PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR, p_center);
} }
Vector3 Area3D::get_gravity_vector() const { const Vector3 &Area3D::get_gravity_point_center() const {
return gravity_vec;
}
void Area3D::set_gravity_direction(const Vector3 &p_direction) {
gravity_vec = p_direction;
PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR, p_direction);
}
const Vector3 &Area3D::get_gravity_direction() const {
return gravity_vec; return gravity_vec;
} }
@ -78,6 +87,24 @@ real_t Area3D::get_gravity() const {
return gravity; return gravity;
} }
void Area3D::set_linear_damp_space_override_mode(SpaceOverride p_mode) {
linear_damp_space_override = p_mode;
PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE, p_mode);
}
Area3D::SpaceOverride Area3D::get_linear_damp_space_override_mode() const {
return linear_damp_space_override;
}
void Area3D::set_angular_damp_space_override_mode(SpaceOverride p_mode) {
angular_damp_space_override = p_mode;
PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE, p_mode);
}
Area3D::SpaceOverride Area3D::get_angular_damp_space_override_mode() const {
return angular_damp_space_override;
}
void Area3D::set_linear_damp(real_t p_linear_damp) { void Area3D::set_linear_damp(real_t p_linear_damp) {
linear_damp = p_linear_damp; linear_damp = p_linear_damp;
PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_LINEAR_DAMP, p_linear_damp); PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_LINEAR_DAMP, p_linear_damp);
@ -579,27 +606,58 @@ void Area3D::_validate_property(PropertyInfo &property) const {
} }
property.hint_string = options; property.hint_string = options;
} else if (property.name.begins_with("gravity") && property.name != "gravity_space_override") {
if (gravity_space_override == SPACE_OVERRIDE_DISABLED) {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL;
} else {
if (gravity_is_point) {
if (property.name == "gravity_direction") {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL;
}
} else {
if (property.name.begins_with("gravity_point_")) {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL;
}
}
}
} else if (property.name.begins_with("linear_damp") && property.name != "linear_damp_space_override") {
if (linear_damp_space_override == SPACE_OVERRIDE_DISABLED) {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL;
}
} else if (property.name.begins_with("angular_damp") && property.name != "angular_damp_space_override") {
if (angular_damp_space_override == SPACE_OVERRIDE_DISABLED) {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL;
}
} }
CollisionObject3D::_validate_property(property); CollisionObject3D::_validate_property(property);
} }
void Area3D::_bind_methods() { void Area3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_space_override_mode", "enable"), &Area3D::set_space_override_mode); ClassDB::bind_method(D_METHOD("set_gravity_space_override_mode", "space_override_mode"), &Area3D::set_gravity_space_override_mode);
ClassDB::bind_method(D_METHOD("get_space_override_mode"), &Area3D::get_space_override_mode); ClassDB::bind_method(D_METHOD("get_gravity_space_override_mode"), &Area3D::get_gravity_space_override_mode);
ClassDB::bind_method(D_METHOD("set_gravity_is_point", "enable"), &Area3D::set_gravity_is_point); ClassDB::bind_method(D_METHOD("set_gravity_is_point", "enable"), &Area3D::set_gravity_is_point);
ClassDB::bind_method(D_METHOD("is_gravity_a_point"), &Area3D::is_gravity_a_point); ClassDB::bind_method(D_METHOD("is_gravity_a_point"), &Area3D::is_gravity_a_point);
ClassDB::bind_method(D_METHOD("set_gravity_distance_scale", "distance_scale"), &Area3D::set_gravity_distance_scale); ClassDB::bind_method(D_METHOD("set_gravity_point_distance_scale", "distance_scale"), &Area3D::set_gravity_point_distance_scale);
ClassDB::bind_method(D_METHOD("get_gravity_distance_scale"), &Area3D::get_gravity_distance_scale); ClassDB::bind_method(D_METHOD("get_gravity_point_distance_scale"), &Area3D::get_gravity_point_distance_scale);
ClassDB::bind_method(D_METHOD("set_gravity_vector", "vector"), &Area3D::set_gravity_vector); ClassDB::bind_method(D_METHOD("set_gravity_point_center", "center"), &Area3D::set_gravity_point_center);
ClassDB::bind_method(D_METHOD("get_gravity_vector"), &Area3D::get_gravity_vector); ClassDB::bind_method(D_METHOD("get_gravity_point_center"), &Area3D::get_gravity_point_center);
ClassDB::bind_method(D_METHOD("set_gravity_direction", "direction"), &Area3D::set_gravity_direction);
ClassDB::bind_method(D_METHOD("get_gravity_direction"), &Area3D::get_gravity_direction);
ClassDB::bind_method(D_METHOD("set_gravity", "gravity"), &Area3D::set_gravity); ClassDB::bind_method(D_METHOD("set_gravity", "gravity"), &Area3D::set_gravity);
ClassDB::bind_method(D_METHOD("get_gravity"), &Area3D::get_gravity); ClassDB::bind_method(D_METHOD("get_gravity"), &Area3D::get_gravity);
ClassDB::bind_method(D_METHOD("set_linear_damp_space_override_mode", "space_override_mode"), &Area3D::set_linear_damp_space_override_mode);
ClassDB::bind_method(D_METHOD("get_linear_damp_space_override_mode"), &Area3D::get_linear_damp_space_override_mode);
ClassDB::bind_method(D_METHOD("set_angular_damp_space_override_mode", "space_override_mode"), &Area3D::set_angular_damp_space_override_mode);
ClassDB::bind_method(D_METHOD("get_angular_damp_space_override_mode"), &Area3D::get_angular_damp_space_override_mode);
ClassDB::bind_method(D_METHOD("set_angular_damp", "angular_damp"), &Area3D::set_angular_damp); ClassDB::bind_method(D_METHOD("set_angular_damp", "angular_damp"), &Area3D::set_angular_damp);
ClassDB::bind_method(D_METHOD("get_angular_damp"), &Area3D::get_angular_damp); ClassDB::bind_method(D_METHOD("get_angular_damp"), &Area3D::get_angular_damp);
@ -662,14 +720,23 @@ void Area3D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "monitorable"), "set_monitorable", "is_monitorable"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "monitorable"), "set_monitorable", "is_monitorable");
ADD_PROPERTY(PropertyInfo(Variant::INT, "priority", PROPERTY_HINT_RANGE, "0,128,1"), "set_priority", "get_priority"); ADD_PROPERTY(PropertyInfo(Variant::INT, "priority", PROPERTY_HINT_RANGE, "0,128,1"), "set_priority", "get_priority");
ADD_GROUP("Physics Overrides", ""); ADD_GROUP("Gravity", "gravity_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "space_override", PROPERTY_HINT_ENUM, "Disabled,Combine,Combine-Replace,Replace,Replace-Combine"), "set_space_override_mode", "get_space_override_mode"); ADD_PROPERTY(PropertyInfo(Variant::INT, "gravity_space_override", PROPERTY_HINT_ENUM, "Disabled,Combine,Combine-Replace,Replace,Replace-Combine", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), "set_gravity_space_override_mode", "get_gravity_space_override_mode");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "gravity_point"), "set_gravity_is_point", "is_gravity_a_point"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "gravity_point", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), "set_gravity_is_point", "is_gravity_a_point");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "gravity_distance_scale", PROPERTY_HINT_RANGE, "0,1024,0.001,or_greater,exp"), "set_gravity_distance_scale", "get_gravity_distance_scale"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "gravity_point_distance_scale", PROPERTY_HINT_RANGE, "0,1024,0.001,or_greater,exp"), "set_gravity_point_distance_scale", "get_gravity_point_distance_scale");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "gravity_vec"), "set_gravity_vector", "get_gravity_vector"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "gravity_point_center"), "set_gravity_point_center", "get_gravity_point_center");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "gravity_direction"), "set_gravity_direction", "get_gravity_direction");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "gravity", PROPERTY_HINT_RANGE, "-32,32,0.001,or_lesser,or_greater"), "set_gravity", "get_gravity"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "gravity", PROPERTY_HINT_RANGE, "-32,32,0.001,or_lesser,or_greater"), "set_gravity", "get_gravity");
ADD_GROUP("Linear Damp", "linear_damp_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "linear_damp_space_override", PROPERTY_HINT_ENUM, "Disabled,Combine,Combine-Replace,Replace,Replace-Combine", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), "set_linear_damp_space_override_mode", "get_linear_damp_space_override_mode");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "linear_damp", PROPERTY_HINT_RANGE, "0,100,0.001,or_greater"), "set_linear_damp", "get_linear_damp"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "linear_damp", PROPERTY_HINT_RANGE, "0,100,0.001,or_greater"), "set_linear_damp", "get_linear_damp");
ADD_GROUP("Angular Damp", "angular_damp_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "angular_damp_space_override", PROPERTY_HINT_ENUM, "Disabled,Combine,Combine-Replace,Replace,Replace-Combine", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), "set_angular_damp_space_override_mode", "get_angular_damp_space_override_mode");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "angular_damp", PROPERTY_HINT_RANGE, "0,100,0.001,or_greater"), "set_angular_damp", "get_angular_damp"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "angular_damp", PROPERTY_HINT_RANGE, "0,100,0.001,or_greater"), "set_angular_damp", "get_angular_damp");
ADD_GROUP("Wind", "wind_");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "wind_force_magnitude", PROPERTY_HINT_RANGE, "0,10,0.001,or_greater"), "set_wind_force_magnitude", "get_wind_force_magnitude"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "wind_force_magnitude", PROPERTY_HINT_RANGE, "0,10,0.001,or_greater"), "set_wind_force_magnitude", "get_wind_force_magnitude");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "wind_attenuation_factor", PROPERTY_HINT_RANGE, "0.0,3.0,0.001,or_greater"), "set_wind_attenuation_factor", "get_wind_attenuation_factor"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "wind_attenuation_factor", PROPERTY_HINT_RANGE, "0.0,3.0,0.001,or_greater"), "set_wind_attenuation_factor", "get_wind_attenuation_factor");
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "wind_source_path", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "Node3D"), "set_wind_source_path", "get_wind_source_path"); ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "wind_source_path", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "Node3D"), "set_wind_source_path", "get_wind_source_path");
@ -694,7 +761,7 @@ void Area3D::_bind_methods() {
Area3D::Area3D() : Area3D::Area3D() :
CollisionObject3D(PhysicsServer3D::get_singleton()->area_create(), true) { CollisionObject3D(PhysicsServer3D::get_singleton()->area_create(), true) {
set_gravity(9.8); set_gravity(9.8);
set_gravity_vector(Vector3(0, -1, 0)); set_gravity_direction(Vector3(0, -1, 0));
set_monitoring(true); set_monitoring(true);
set_monitorable(true); set_monitorable(true);
} }

View File

@ -47,17 +47,23 @@ public:
}; };
private: private:
SpaceOverride space_override = SPACE_OVERRIDE_DISABLED; SpaceOverride gravity_space_override = SPACE_OVERRIDE_DISABLED;
Vector3 gravity_vec; Vector3 gravity_vec;
real_t gravity; real_t gravity;
bool gravity_is_point = false; bool gravity_is_point = false;
real_t gravity_distance_scale = 0.0; real_t gravity_distance_scale = 0.0;
SpaceOverride linear_damp_space_override = SPACE_OVERRIDE_DISABLED;
SpaceOverride angular_damp_space_override = SPACE_OVERRIDE_DISABLED;
real_t angular_damp = 0.1; real_t angular_damp = 0.1;
real_t linear_damp = 0.1; real_t linear_damp = 0.1;
int priority = 0; int priority = 0;
real_t wind_force_magnitude = 0.0; real_t wind_force_magnitude = 0.0;
real_t wind_attenuation_factor = 0.0; real_t wind_attenuation_factor = 0.0;
NodePath wind_source_path; NodePath wind_source_path;
bool monitoring = false; bool monitoring = false;
bool monitorable = false; bool monitorable = false;
bool locked = false; bool locked = false;
@ -144,21 +150,30 @@ protected:
static void _bind_methods(); static void _bind_methods();
public: public:
void set_space_override_mode(SpaceOverride p_mode); void set_gravity_space_override_mode(SpaceOverride p_mode);
SpaceOverride get_space_override_mode() const; SpaceOverride get_gravity_space_override_mode() const;
void set_gravity_is_point(bool p_enabled); void set_gravity_is_point(bool p_enabled);
bool is_gravity_a_point() const; bool is_gravity_a_point() const;
void set_gravity_distance_scale(real_t p_scale); void set_gravity_point_distance_scale(real_t p_scale);
real_t get_gravity_distance_scale() const; real_t get_gravity_point_distance_scale() const;
void set_gravity_vector(const Vector3 &p_vec); void set_gravity_point_center(const Vector3 &p_center);
Vector3 get_gravity_vector() const; const Vector3 &get_gravity_point_center() const;
void set_gravity_direction(const Vector3 &p_direction);
const Vector3 &get_gravity_direction() const;
void set_gravity(real_t p_gravity); void set_gravity(real_t p_gravity);
real_t get_gravity() const; real_t get_gravity() const;
void set_linear_damp_space_override_mode(SpaceOverride p_mode);
SpaceOverride get_linear_damp_space_override_mode() const;
void set_angular_damp_space_override_mode(SpaceOverride p_mode);
SpaceOverride get_angular_damp_space_override_mode() const;
void set_angular_damp(real_t p_angular_damp); void set_angular_damp(real_t p_angular_damp);
real_t get_angular_damp() const; real_t get_angular_damp() const;

View File

@ -121,18 +121,21 @@ void GodotArea2D::set_area_monitor_callback(const Callable &p_callback) {
} }
} }
void GodotArea2D::set_space_override_mode(PhysicsServer2D::AreaSpaceOverrideMode p_mode) { void GodotArea2D::_set_space_override_mode(PhysicsServer2D::AreaSpaceOverrideMode &r_mode, PhysicsServer2D::AreaSpaceOverrideMode p_new_mode) {
bool do_override = p_mode != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED; bool do_override = p_new_mode != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED;
if (do_override == (space_override_mode != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED)) { if (do_override == (r_mode != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED)) {
return; return;
} }
_unregister_shapes(); _unregister_shapes();
space_override_mode = p_mode; r_mode = p_new_mode;
_shape_changed(); _shape_changed();
} }
void GodotArea2D::set_param(PhysicsServer2D::AreaParameter p_param, const Variant &p_value) { void GodotArea2D::set_param(PhysicsServer2D::AreaParameter p_param, const Variant &p_value) {
switch (p_param) { switch (p_param) {
case PhysicsServer2D::AREA_PARAM_GRAVITY_OVERRIDE_MODE:
_set_space_override_mode(gravity_override_mode, (PhysicsServer2D::AreaSpaceOverrideMode)(int)p_value);
break;
case PhysicsServer2D::AREA_PARAM_GRAVITY: case PhysicsServer2D::AREA_PARAM_GRAVITY:
gravity = p_value; gravity = p_value;
break; break;
@ -148,9 +151,15 @@ void GodotArea2D::set_param(PhysicsServer2D::AreaParameter p_param, const Varian
case PhysicsServer2D::AREA_PARAM_GRAVITY_POINT_ATTENUATION: case PhysicsServer2D::AREA_PARAM_GRAVITY_POINT_ATTENUATION:
point_attenuation = p_value; point_attenuation = p_value;
break; break;
case PhysicsServer2D::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE:
_set_space_override_mode(linear_damping_override_mode, (PhysicsServer2D::AreaSpaceOverrideMode)(int)p_value);
break;
case PhysicsServer2D::AREA_PARAM_LINEAR_DAMP: case PhysicsServer2D::AREA_PARAM_LINEAR_DAMP:
linear_damp = p_value; linear_damp = p_value;
break; break;
case PhysicsServer2D::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE:
_set_space_override_mode(angular_damping_override_mode, (PhysicsServer2D::AreaSpaceOverrideMode)(int)p_value);
break;
case PhysicsServer2D::AREA_PARAM_ANGULAR_DAMP: case PhysicsServer2D::AREA_PARAM_ANGULAR_DAMP:
angular_damp = p_value; angular_damp = p_value;
break; break;
@ -162,6 +171,8 @@ void GodotArea2D::set_param(PhysicsServer2D::AreaParameter p_param, const Varian
Variant GodotArea2D::get_param(PhysicsServer2D::AreaParameter p_param) const { Variant GodotArea2D::get_param(PhysicsServer2D::AreaParameter p_param) const {
switch (p_param) { switch (p_param) {
case PhysicsServer2D::AREA_PARAM_GRAVITY_OVERRIDE_MODE:
return gravity_override_mode;
case PhysicsServer2D::AREA_PARAM_GRAVITY: case PhysicsServer2D::AREA_PARAM_GRAVITY:
return gravity; return gravity;
case PhysicsServer2D::AREA_PARAM_GRAVITY_VECTOR: case PhysicsServer2D::AREA_PARAM_GRAVITY_VECTOR:
@ -172,8 +183,12 @@ Variant GodotArea2D::get_param(PhysicsServer2D::AreaParameter p_param) const {
return gravity_distance_scale; return gravity_distance_scale;
case PhysicsServer2D::AREA_PARAM_GRAVITY_POINT_ATTENUATION: case PhysicsServer2D::AREA_PARAM_GRAVITY_POINT_ATTENUATION:
return point_attenuation; return point_attenuation;
case PhysicsServer2D::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE:
return linear_damping_override_mode;
case PhysicsServer2D::AREA_PARAM_LINEAR_DAMP: case PhysicsServer2D::AREA_PARAM_LINEAR_DAMP:
return linear_damp; return linear_damp;
case PhysicsServer2D::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE:
return angular_damping_override_mode;
case PhysicsServer2D::AREA_PARAM_ANGULAR_DAMP: case PhysicsServer2D::AREA_PARAM_ANGULAR_DAMP:
return angular_damp; return angular_damp;
case PhysicsServer2D::AREA_PARAM_PRIORITY: case PhysicsServer2D::AREA_PARAM_PRIORITY:

View File

@ -41,7 +41,10 @@ class GodotBody2D;
class GodotConstraint2D; class GodotConstraint2D;
class GodotArea2D : public GodotCollisionObject2D { class GodotArea2D : public GodotCollisionObject2D {
PhysicsServer2D::AreaSpaceOverrideMode space_override_mode = PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED; PhysicsServer2D::AreaSpaceOverrideMode gravity_override_mode = PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED;
PhysicsServer2D::AreaSpaceOverrideMode linear_damping_override_mode = PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED;
PhysicsServer2D::AreaSpaceOverrideMode angular_damping_override_mode = PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED;
real_t gravity = 9.80665; real_t gravity = 9.80665;
Vector2 gravity_vector = Vector2(0, -1); Vector2 gravity_vector = Vector2(0, -1);
bool gravity_is_point = false; bool gravity_is_point = false;
@ -96,6 +99,8 @@ class GodotArea2D : public GodotCollisionObject2D {
virtual void _shapes_changed(); virtual void _shapes_changed();
void _queue_monitor_update(); void _queue_monitor_update();
void _set_space_override_mode(PhysicsServer2D::AreaSpaceOverrideMode &r_mode, PhysicsServer2D::AreaSpaceOverrideMode p_new_mode);
public: public:
void set_monitor_callback(const Callable &p_callback); void set_monitor_callback(const Callable &p_callback);
_FORCE_INLINE_ bool has_monitor_callback() const { return !monitor_callback.is_null(); } _FORCE_INLINE_ bool has_monitor_callback() const { return !monitor_callback.is_null(); }
@ -112,9 +117,6 @@ public:
void set_param(PhysicsServer2D::AreaParameter p_param, const Variant &p_value); void set_param(PhysicsServer2D::AreaParameter p_param, const Variant &p_value);
Variant get_param(PhysicsServer2D::AreaParameter p_param) const; Variant get_param(PhysicsServer2D::AreaParameter p_param) const;
void set_space_override_mode(PhysicsServer2D::AreaSpaceOverrideMode p_mode);
PhysicsServer2D::AreaSpaceOverrideMode get_space_override_mode() const { return space_override_mode; }
_FORCE_INLINE_ void set_gravity(real_t p_gravity) { gravity = p_gravity; } _FORCE_INLINE_ void set_gravity(real_t p_gravity) { gravity = p_gravity; }
_FORCE_INLINE_ real_t get_gravity() const { return gravity; } _FORCE_INLINE_ real_t get_gravity() const { return gravity; }

View File

@ -38,10 +38,18 @@ bool GodotAreaPair2D::setup(real_t p_step) {
} }
process_collision = false; process_collision = false;
has_space_override = false;
if (result != colliding) { if (result != colliding) {
if (area->get_space_override_mode() != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED) { if ((int)area->get_param(PhysicsServer2D::AREA_PARAM_GRAVITY_OVERRIDE_MODE) != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED) {
process_collision = true; has_space_override = true;
} else if (area->has_monitor_callback()) { } else if ((int)area->get_param(PhysicsServer2D::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE) != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED) {
has_space_override = true;
} else if ((int)area->get_param(PhysicsServer2D::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE) != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED) {
has_space_override = true;
}
process_collision = has_space_override;
if (area->has_monitor_callback()) {
process_collision = true; process_collision = true;
} }
@ -57,7 +65,7 @@ bool GodotAreaPair2D::pre_solve(real_t p_step) {
} }
if (colliding) { if (colliding) {
if (area->get_space_override_mode() != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED) { if (has_space_override) {
body->add_area(area); body->add_area(area);
} }
@ -65,7 +73,7 @@ bool GodotAreaPair2D::pre_solve(real_t p_step) {
area->add_body_to_query(body, body_shape, area_shape); area->add_body_to_query(body, body_shape, area_shape);
} }
} else { } else {
if (area->get_space_override_mode() != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED) { if (has_space_override) {
body->remove_area(area); body->remove_area(area);
} }
@ -95,7 +103,7 @@ GodotAreaPair2D::GodotAreaPair2D(GodotBody2D *p_body, int p_body_shape, GodotAre
GodotAreaPair2D::~GodotAreaPair2D() { GodotAreaPair2D::~GodotAreaPair2D() {
if (colliding) { if (colliding) {
if (area->get_space_override_mode() != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED) { if (has_space_override) {
body->remove_area(area); body->remove_area(area);
} }
if (area->has_monitor_callback()) { if (area->has_monitor_callback()) {

View File

@ -41,6 +41,7 @@ class GodotAreaPair2D : public GodotConstraint2D {
int body_shape = 0; int body_shape = 0;
int area_shape = 0; int area_shape = 0;
bool colliding = false; bool colliding = false;
bool has_space_override = false;
bool process_collision = false; bool process_collision = false;
public: public:

View File

@ -410,15 +410,6 @@ void GodotBody2D::set_space(GodotSpace2D *p_space) {
} }
} }
void GodotBody2D::_compute_area_gravity_and_damping(const GodotArea2D *p_area) {
Vector2 area_gravity;
p_area->compute_gravity(get_transform().get_origin(), area_gravity);
gravity += area_gravity;
total_linear_damp += p_area->get_linear_damp();
total_angular_damp += p_area->get_angular_damp();
}
void GodotBody2D::_update_transform_dependent() { void GodotBody2D::_update_transform_dependent() {
center_of_mass = get_transform().basis_xform(center_of_mass_local); center_of_mass = get_transform().basis_xform(center_of_mass_local);
} }
@ -428,8 +419,16 @@ void GodotBody2D::integrate_forces(real_t p_step) {
return; return;
} }
ERR_FAIL_COND(!get_space());
int ac = areas.size(); int ac = areas.size();
bool gravity_done = false;
bool linear_damp_done = false;
bool angular_damp_done = false;
bool stopped = false; bool stopped = false;
gravity = Vector2(0, 0); gravity = Vector2(0, 0);
total_linear_damp = 0.0; total_linear_damp = 0.0;
@ -440,33 +439,89 @@ void GodotBody2D::integrate_forces(real_t p_step) {
areas.sort(); areas.sort();
const AreaCMP *aa = &areas[0]; const AreaCMP *aa = &areas[0];
for (int i = ac - 1; i >= 0 && !stopped; i--) { for (int i = ac - 1; i >= 0 && !stopped; i--) {
PhysicsServer2D::AreaSpaceOverrideMode mode = aa[i].area->get_space_override_mode(); if (!gravity_done) {
switch (mode) { PhysicsServer2D::AreaSpaceOverrideMode area_gravity_mode = (PhysicsServer2D::AreaSpaceOverrideMode)(int)aa[i].area->get_param(PhysicsServer2D::AREA_PARAM_GRAVITY_OVERRIDE_MODE);
case PhysicsServer2D::AREA_SPACE_OVERRIDE_COMBINE: if (area_gravity_mode != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED) {
case PhysicsServer2D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: { Vector2 area_gravity;
_compute_area_gravity_and_damping(aa[i].area); aa[i].area->compute_gravity(get_transform().get_origin(), area_gravity);
stopped = mode == PhysicsServer2D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE; switch (area_gravity_mode) {
} break; case PhysicsServer2D::AREA_SPACE_OVERRIDE_COMBINE:
case PhysicsServer2D::AREA_SPACE_OVERRIDE_REPLACE: case PhysicsServer2D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: {
case PhysicsServer2D::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: { gravity += area_gravity;
gravity = Vector2(0, 0); gravity_done = area_gravity_mode == PhysicsServer2D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE;
total_linear_damp = 0.0; } break;
total_angular_damp = 0.0; case PhysicsServer2D::AREA_SPACE_OVERRIDE_REPLACE:
_compute_area_gravity_and_damping(aa[i].area); case PhysicsServer2D::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: {
stopped = mode == PhysicsServer2D::AREA_SPACE_OVERRIDE_REPLACE; gravity = area_gravity;
} break; gravity_done = area_gravity_mode == PhysicsServer2D::AREA_SPACE_OVERRIDE_REPLACE;
default: { } break;
default: {
}
}
} }
} }
if (!linear_damp_done) {
PhysicsServer2D::AreaSpaceOverrideMode area_linear_damp_mode = (PhysicsServer2D::AreaSpaceOverrideMode)(int)aa[i].area->get_param(PhysicsServer2D::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE);
if (area_linear_damp_mode != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED) {
real_t area_linear_damp = aa[i].area->get_linear_damp();
switch (area_linear_damp_mode) {
case PhysicsServer2D::AREA_SPACE_OVERRIDE_COMBINE:
case PhysicsServer2D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: {
total_linear_damp += area_linear_damp;
linear_damp_done = area_linear_damp_mode == PhysicsServer2D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE;
} break;
case PhysicsServer2D::AREA_SPACE_OVERRIDE_REPLACE:
case PhysicsServer2D::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: {
total_linear_damp = area_linear_damp;
linear_damp_done = area_linear_damp_mode == PhysicsServer2D::AREA_SPACE_OVERRIDE_REPLACE;
} break;
default: {
}
}
}
}
if (!angular_damp_done) {
PhysicsServer2D::AreaSpaceOverrideMode area_angular_damp_mode = (PhysicsServer2D::AreaSpaceOverrideMode)(int)aa[i].area->get_param(PhysicsServer2D::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE);
if (area_angular_damp_mode != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED) {
real_t area_angular_damp = aa[i].area->get_angular_damp();
switch (area_angular_damp_mode) {
case PhysicsServer2D::AREA_SPACE_OVERRIDE_COMBINE:
case PhysicsServer2D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: {
total_angular_damp += area_angular_damp;
angular_damp_done = area_angular_damp_mode == PhysicsServer2D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE;
} break;
case PhysicsServer2D::AREA_SPACE_OVERRIDE_REPLACE:
case PhysicsServer2D::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: {
total_angular_damp = area_angular_damp;
angular_damp_done = area_angular_damp_mode == PhysicsServer2D::AREA_SPACE_OVERRIDE_REPLACE;
} break;
default: {
}
}
}
}
stopped = gravity_done && linear_damp_done && angular_damp_done;
} }
} }
// Override linear damping with body's value. // Add default gravity and damping from space area.
if (!stopped) { if (!stopped) {
GodotArea2D *def_area = get_space()->get_default_area(); GodotArea2D *default_area = get_space()->get_default_area();
ERR_FAIL_COND(!def_area); ERR_FAIL_COND(!default_area);
_compute_area_gravity_and_damping(def_area); if (!gravity_done) {
Vector2 default_gravity;
default_area->compute_gravity(get_transform().get_origin(), default_gravity);
gravity += default_gravity;
}
if (!linear_damp_done) {
total_linear_damp += default_area->get_linear_damp();
}
if (!angular_damp_done) {
total_angular_damp += default_area->get_angular_damp();
}
} }
// Override linear damping with body's value. // Override linear damping with body's value.

View File

@ -145,8 +145,6 @@ class GodotBody2D : public GodotCollisionObject2D {
uint64_t island_step = 0; uint64_t island_step = 0;
void _compute_area_gravity_and_damping(const GodotArea2D *p_area);
void _update_transform_dependent(); void _update_transform_dependent();
friend class GodotPhysicsDirectBodyState2D; // i give up, too many functions to expose friend class GodotPhysicsDirectBodyState2D; // i give up, too many functions to expose

View File

@ -289,7 +289,7 @@ RID GodotPhysicsServer2D::area_create() {
RID rid = area_owner.make_rid(area); RID rid = area_owner.make_rid(area);
area->set_self(rid); area->set_self(rid);
return rid; return rid;
}; }
void GodotPhysicsServer2D::area_set_space(RID p_area, RID p_space) { void GodotPhysicsServer2D::area_set_space(RID p_area, RID p_space) {
GodotArea2D *area = area_owner.get_or_null(p_area); GodotArea2D *area = area_owner.get_or_null(p_area);
@ -307,7 +307,7 @@ void GodotPhysicsServer2D::area_set_space(RID p_area, RID p_space) {
area->clear_constraints(); area->clear_constraints();
area->set_space(space); area->set_space(space);
}; }
RID GodotPhysicsServer2D::area_get_space(RID p_area) const { RID GodotPhysicsServer2D::area_get_space(RID p_area) const {
GodotArea2D *area = area_owner.get_or_null(p_area); GodotArea2D *area = area_owner.get_or_null(p_area);
@ -318,20 +318,6 @@ RID GodotPhysicsServer2D::area_get_space(RID p_area) const {
return RID(); return RID();
} }
return space->get_self(); return space->get_self();
};
void GodotPhysicsServer2D::area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode) {
GodotArea2D *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_space_override_mode(p_mode);
}
PhysicsServer2D::AreaSpaceOverrideMode GodotPhysicsServer2D::area_get_space_override_mode(RID p_area) const {
const GodotArea2D *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, AREA_SPACE_OVERRIDE_DISABLED);
return area->get_space_override_mode();
} }
void GodotPhysicsServer2D::area_add_shape(RID p_area, RID p_shape, const Transform2D &p_transform, bool p_disabled) { void GodotPhysicsServer2D::area_add_shape(RID p_area, RID p_shape, const Transform2D &p_transform, bool p_disabled) {

View File

@ -124,9 +124,6 @@ public:
virtual RID area_create() override; virtual RID area_create() override;
virtual void area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode) override;
virtual AreaSpaceOverrideMode area_get_space_override_mode(RID p_area) const override;
virtual void area_set_space(RID p_area, RID p_space) override; virtual void area_set_space(RID p_area, RID p_space) override;
virtual RID area_get_space(RID p_area) const override; virtual RID area_get_space(RID p_area) const override;

View File

@ -128,18 +128,21 @@ void GodotArea3D::set_area_monitor_callback(const Callable &p_callback) {
} }
} }
void GodotArea3D::set_space_override_mode(PhysicsServer3D::AreaSpaceOverrideMode p_mode) { void GodotArea3D::_set_space_override_mode(PhysicsServer3D::AreaSpaceOverrideMode &r_mode, PhysicsServer3D::AreaSpaceOverrideMode p_new_mode) {
bool do_override = p_mode != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED; bool do_override = p_new_mode != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED;
if (do_override == (space_override_mode != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED)) { if (do_override == (r_mode != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED)) {
return; return;
} }
_unregister_shapes(); _unregister_shapes();
space_override_mode = p_mode; r_mode = p_new_mode;
_shape_changed(); _shape_changed();
} }
void GodotArea3D::set_param(PhysicsServer3D::AreaParameter p_param, const Variant &p_value) { void GodotArea3D::set_param(PhysicsServer3D::AreaParameter p_param, const Variant &p_value) {
switch (p_param) { switch (p_param) {
case PhysicsServer3D::AREA_PARAM_GRAVITY_OVERRIDE_MODE:
_set_space_override_mode(gravity_override_mode, (PhysicsServer3D::AreaSpaceOverrideMode)(int)p_value);
break;
case PhysicsServer3D::AREA_PARAM_GRAVITY: case PhysicsServer3D::AREA_PARAM_GRAVITY:
gravity = p_value; gravity = p_value;
break; break;
@ -155,9 +158,15 @@ void GodotArea3D::set_param(PhysicsServer3D::AreaParameter p_param, const Varian
case PhysicsServer3D::AREA_PARAM_GRAVITY_POINT_ATTENUATION: case PhysicsServer3D::AREA_PARAM_GRAVITY_POINT_ATTENUATION:
point_attenuation = p_value; point_attenuation = p_value;
break; break;
case PhysicsServer3D::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE:
_set_space_override_mode(linear_damping_override_mode, (PhysicsServer3D::AreaSpaceOverrideMode)(int)p_value);
break;
case PhysicsServer3D::AREA_PARAM_LINEAR_DAMP: case PhysicsServer3D::AREA_PARAM_LINEAR_DAMP:
linear_damp = p_value; linear_damp = p_value;
break; break;
case PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE:
_set_space_override_mode(angular_damping_override_mode, (PhysicsServer3D::AreaSpaceOverrideMode)(int)p_value);
break;
case PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP: case PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP:
angular_damp = p_value; angular_damp = p_value;
break; break;
@ -183,6 +192,8 @@ void GodotArea3D::set_param(PhysicsServer3D::AreaParameter p_param, const Varian
Variant GodotArea3D::get_param(PhysicsServer3D::AreaParameter p_param) const { Variant GodotArea3D::get_param(PhysicsServer3D::AreaParameter p_param) const {
switch (p_param) { switch (p_param) {
case PhysicsServer3D::AREA_PARAM_GRAVITY_OVERRIDE_MODE:
return gravity_override_mode;
case PhysicsServer3D::AREA_PARAM_GRAVITY: case PhysicsServer3D::AREA_PARAM_GRAVITY:
return gravity; return gravity;
case PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR: case PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR:
@ -193,8 +204,12 @@ Variant GodotArea3D::get_param(PhysicsServer3D::AreaParameter p_param) const {
return gravity_distance_scale; return gravity_distance_scale;
case PhysicsServer3D::AREA_PARAM_GRAVITY_POINT_ATTENUATION: case PhysicsServer3D::AREA_PARAM_GRAVITY_POINT_ATTENUATION:
return point_attenuation; return point_attenuation;
case PhysicsServer3D::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE:
return linear_damping_override_mode;
case PhysicsServer3D::AREA_PARAM_LINEAR_DAMP: case PhysicsServer3D::AREA_PARAM_LINEAR_DAMP:
return linear_damp; return linear_damp;
case PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE:
return angular_damping_override_mode;
case PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP: case PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP:
return angular_damp; return angular_damp;
case PhysicsServer3D::AREA_PARAM_PRIORITY: case PhysicsServer3D::AREA_PARAM_PRIORITY:

View File

@ -42,7 +42,10 @@ class GodotSoftBody3D;
class GodotConstraint3D; class GodotConstraint3D;
class GodotArea3D : public GodotCollisionObject3D { class GodotArea3D : public GodotCollisionObject3D {
PhysicsServer3D::AreaSpaceOverrideMode space_override_mode = PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED; PhysicsServer3D::AreaSpaceOverrideMode gravity_override_mode = PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED;
PhysicsServer3D::AreaSpaceOverrideMode linear_damping_override_mode = PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED;
PhysicsServer3D::AreaSpaceOverrideMode angular_damping_override_mode = PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED;
real_t gravity = 9.80665; real_t gravity = 9.80665;
Vector3 gravity_vector = Vector3(0, -1, 0); Vector3 gravity_vector = Vector3(0, -1, 0);
bool gravity_is_point = false; bool gravity_is_point = false;
@ -102,6 +105,8 @@ class GodotArea3D : public GodotCollisionObject3D {
virtual void _shapes_changed(); virtual void _shapes_changed();
void _queue_monitor_update(); void _queue_monitor_update();
void _set_space_override_mode(PhysicsServer3D::AreaSpaceOverrideMode &r_mode, PhysicsServer3D::AreaSpaceOverrideMode p_new_mode);
public: public:
void set_monitor_callback(const Callable &p_callback); void set_monitor_callback(const Callable &p_callback);
_FORCE_INLINE_ bool has_monitor_callback() const { return !monitor_callback.is_null(); } _FORCE_INLINE_ bool has_monitor_callback() const { return !monitor_callback.is_null(); }
@ -121,9 +126,6 @@ public:
void set_param(PhysicsServer3D::AreaParameter p_param, const Variant &p_value); void set_param(PhysicsServer3D::AreaParameter p_param, const Variant &p_value);
Variant get_param(PhysicsServer3D::AreaParameter p_param) const; Variant get_param(PhysicsServer3D::AreaParameter p_param) const;
void set_space_override_mode(PhysicsServer3D::AreaSpaceOverrideMode p_mode);
PhysicsServer3D::AreaSpaceOverrideMode get_space_override_mode() const { return space_override_mode; }
_FORCE_INLINE_ void set_gravity(real_t p_gravity) { gravity = p_gravity; } _FORCE_INLINE_ void set_gravity(real_t p_gravity) { gravity = p_gravity; }
_FORCE_INLINE_ real_t get_gravity() const { return gravity; } _FORCE_INLINE_ real_t get_gravity() const { return gravity; }

View File

@ -39,10 +39,18 @@ bool GodotAreaPair3D::setup(real_t p_step) {
} }
process_collision = false; process_collision = false;
has_space_override = false;
if (result != colliding) { if (result != colliding) {
if (area->get_space_override_mode() != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED) { if ((int)area->get_param(PhysicsServer3D::AREA_PARAM_GRAVITY_OVERRIDE_MODE) != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED) {
process_collision = true; has_space_override = true;
} else if (area->has_monitor_callback()) { } else if ((int)area->get_param(PhysicsServer3D::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE) != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED) {
has_space_override = true;
} else if ((int)area->get_param(PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE) != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED) {
has_space_override = true;
}
process_collision = has_space_override;
if (area->has_monitor_callback()) {
process_collision = true; process_collision = true;
} }
@ -58,7 +66,7 @@ bool GodotAreaPair3D::pre_solve(real_t p_step) {
} }
if (colliding) { if (colliding) {
if (area->get_space_override_mode() != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED) { if (has_space_override) {
body->add_area(area); body->add_area(area);
} }
@ -66,7 +74,7 @@ bool GodotAreaPair3D::pre_solve(real_t p_step) {
area->add_body_to_query(body, body_shape, area_shape); area->add_body_to_query(body, body_shape, area_shape);
} }
} else { } else {
if (area->get_space_override_mode() != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED) { if (has_space_override) {
body->remove_area(area); body->remove_area(area);
} }
@ -96,7 +104,7 @@ GodotAreaPair3D::GodotAreaPair3D(GodotBody3D *p_body, int p_body_shape, GodotAre
GodotAreaPair3D::~GodotAreaPair3D() { GodotAreaPair3D::~GodotAreaPair3D() {
if (colliding) { if (colliding) {
if (area->get_space_override_mode() != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED) { if (has_space_override) {
body->remove_area(area); body->remove_area(area);
} }
if (area->has_monitor_callback()) { if (area->has_monitor_callback()) {
@ -207,10 +215,15 @@ bool GodotAreaSoftBodyPair3D::setup(real_t p_step) {
} }
process_collision = false; process_collision = false;
has_space_override = false;
if (result != colliding) { if (result != colliding) {
if (area->get_space_override_mode() != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED) { if ((int)area->get_param(PhysicsServer3D::AREA_PARAM_GRAVITY_OVERRIDE_MODE) != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED) {
process_collision = true; has_space_override = true;
} else if (area->has_monitor_callback()) { } else if (area->get_wind_force_magnitude() > CMP_EPSILON) {
has_space_override = true;
}
if (area->has_monitor_callback()) {
process_collision = true; process_collision = true;
} }
@ -226,7 +239,7 @@ bool GodotAreaSoftBodyPair3D::pre_solve(real_t p_step) {
} }
if (colliding) { if (colliding) {
if (area->get_space_override_mode() != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED) { if (has_space_override) {
soft_body->add_area(area); soft_body->add_area(area);
} }
@ -234,7 +247,7 @@ bool GodotAreaSoftBodyPair3D::pre_solve(real_t p_step) {
area->add_soft_body_to_query(soft_body, soft_body_shape, area_shape); area->add_soft_body_to_query(soft_body, soft_body_shape, area_shape);
} }
} else { } else {
if (area->get_space_override_mode() != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED) { if (has_space_override) {
soft_body->remove_area(area); soft_body->remove_area(area);
} }
@ -261,7 +274,7 @@ GodotAreaSoftBodyPair3D::GodotAreaSoftBodyPair3D(GodotSoftBody3D *p_soft_body, i
GodotAreaSoftBodyPair3D::~GodotAreaSoftBodyPair3D() { GodotAreaSoftBodyPair3D::~GodotAreaSoftBodyPair3D() {
if (colliding) { if (colliding) {
if (area->get_space_override_mode() != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED) { if (has_space_override) {
soft_body->remove_area(area); soft_body->remove_area(area);
} }
if (area->has_monitor_callback()) { if (area->has_monitor_callback()) {

View File

@ -43,6 +43,7 @@ class GodotAreaPair3D : public GodotConstraint3D {
int area_shape; int area_shape;
bool colliding = false; bool colliding = false;
bool process_collision = false; bool process_collision = false;
bool has_space_override = false;
public: public:
virtual bool setup(real_t p_step) override; virtual bool setup(real_t p_step) override;
@ -79,6 +80,7 @@ class GodotAreaSoftBodyPair3D : public GodotConstraint3D {
int area_shape; int area_shape;
bool colliding = false; bool colliding = false;
bool process_collision = false; bool process_collision = false;
bool has_space_override = false;
public: public:
virtual bool setup(real_t p_step) override; virtual bool setup(real_t p_step) override;

View File

@ -457,15 +457,6 @@ void GodotBody3D::set_space(GodotSpace3D *p_space) {
} }
} }
void GodotBody3D::_compute_area_gravity_and_damping(const GodotArea3D *p_area) {
Vector3 area_gravity;
p_area->compute_gravity(get_transform().get_origin(), area_gravity);
gravity += area_gravity;
total_linear_damp += p_area->get_linear_damp();
total_angular_damp += p_area->get_angular_damp();
}
void GodotBody3D::set_axis_lock(PhysicsServer3D::BodyAxis p_axis, bool lock) { void GodotBody3D::set_axis_lock(PhysicsServer3D::BodyAxis p_axis, bool lock) {
if (lock) { if (lock) {
locked_axis |= p_axis; locked_axis |= p_axis;
@ -483,8 +474,16 @@ void GodotBody3D::integrate_forces(real_t p_step) {
return; return;
} }
ERR_FAIL_COND(!get_space());
int ac = areas.size(); int ac = areas.size();
bool gravity_done = false;
bool linear_damp_done = false;
bool angular_damp_done = false;
bool stopped = false; bool stopped = false;
gravity = Vector3(0, 0, 0); gravity = Vector3(0, 0, 0);
total_linear_damp = 0.0; total_linear_damp = 0.0;
@ -495,33 +494,89 @@ void GodotBody3D::integrate_forces(real_t p_step) {
areas.sort(); areas.sort();
const AreaCMP *aa = &areas[0]; const AreaCMP *aa = &areas[0];
for (int i = ac - 1; i >= 0 && !stopped; i--) { for (int i = ac - 1; i >= 0 && !stopped; i--) {
PhysicsServer3D::AreaSpaceOverrideMode mode = aa[i].area->get_space_override_mode(); if (!gravity_done) {
switch (mode) { PhysicsServer3D::AreaSpaceOverrideMode area_gravity_mode = (PhysicsServer3D::AreaSpaceOverrideMode)(int)aa[i].area->get_param(PhysicsServer3D::AREA_PARAM_GRAVITY_OVERRIDE_MODE);
case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE: if (area_gravity_mode != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED) {
case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: { Vector3 area_gravity;
_compute_area_gravity_and_damping(aa[i].area); aa[i].area->compute_gravity(get_transform().get_origin(), area_gravity);
stopped = mode == PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE; switch (area_gravity_mode) {
} break; case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE:
case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE: case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: {
case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: { gravity += area_gravity;
gravity = Vector3(0, 0, 0); gravity_done = area_gravity_mode == PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE;
total_linear_damp = 0.0; } break;
total_angular_damp = 0.0; case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE:
_compute_area_gravity_and_damping(aa[i].area); case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: {
stopped = mode == PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE; gravity = area_gravity;
} break; gravity_done = area_gravity_mode == PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE;
default: { } break;
default: {
}
}
} }
} }
if (!linear_damp_done) {
PhysicsServer3D::AreaSpaceOverrideMode area_linear_damp_mode = (PhysicsServer3D::AreaSpaceOverrideMode)(int)aa[i].area->get_param(PhysicsServer3D::AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE);
if (area_linear_damp_mode != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED) {
real_t area_linear_damp = aa[i].area->get_linear_damp();
switch (area_linear_damp_mode) {
case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE:
case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: {
total_linear_damp += area_linear_damp;
linear_damp_done = area_linear_damp_mode == PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE;
} break;
case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE:
case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: {
total_linear_damp = area_linear_damp;
linear_damp_done = area_linear_damp_mode == PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE;
} break;
default: {
}
}
}
}
if (!angular_damp_done) {
PhysicsServer3D::AreaSpaceOverrideMode area_angular_damp_mode = (PhysicsServer3D::AreaSpaceOverrideMode)(int)aa[i].area->get_param(PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE);
if (area_angular_damp_mode != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED) {
real_t area_angular_damp = aa[i].area->get_angular_damp();
switch (area_angular_damp_mode) {
case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE:
case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: {
total_angular_damp += area_angular_damp;
angular_damp_done = area_angular_damp_mode == PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE;
} break;
case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE:
case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: {
total_angular_damp = area_angular_damp;
angular_damp_done = area_angular_damp_mode == PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE;
} break;
default: {
}
}
}
}
stopped = gravity_done && linear_damp_done && angular_damp_done;
} }
} }
// Add default gravity and damping from space area. // Add default gravity and damping from space area.
if (!stopped) { if (!stopped) {
GodotArea3D *def_area = get_space()->get_default_area(); GodotArea3D *default_area = get_space()->get_default_area();
ERR_FAIL_COND(!def_area); ERR_FAIL_COND(!default_area);
_compute_area_gravity_and_damping(def_area); if (!gravity_done) {
Vector3 default_gravity;
default_area->compute_gravity(get_transform().get_origin(), default_gravity);
gravity += default_gravity;
}
if (!linear_damp_done) {
total_linear_damp += default_area->get_linear_damp();
}
if (!angular_damp_done) {
total_angular_damp += default_area->get_angular_damp();
}
} }
// Override linear damping with body's value. // Override linear damping with body's value.

View File

@ -139,8 +139,6 @@ class GodotBody3D : public GodotCollisionObject3D {
uint64_t island_step = 0; uint64_t island_step = 0;
void _compute_area_gravity_and_damping(const GodotArea3D *p_area);
void _update_transform_dependent(); void _update_transform_dependent();
friend class GodotPhysicsDirectBodyState3D; // i give up, too many functions to expose friend class GodotPhysicsDirectBodyState3D; // i give up, too many functions to expose

View File

@ -219,7 +219,7 @@ RID GodotPhysicsServer3D::area_create() {
RID rid = area_owner.make_rid(area); RID rid = area_owner.make_rid(area);
area->set_self(rid); area->set_self(rid);
return rid; return rid;
}; }
void GodotPhysicsServer3D::area_set_space(RID p_area, RID p_space) { void GodotPhysicsServer3D::area_set_space(RID p_area, RID p_space) {
GodotArea3D *area = area_owner.get_or_null(p_area); GodotArea3D *area = area_owner.get_or_null(p_area);
@ -237,7 +237,7 @@ void GodotPhysicsServer3D::area_set_space(RID p_area, RID p_space) {
area->clear_constraints(); area->clear_constraints();
area->set_space(space); area->set_space(space);
}; }
RID GodotPhysicsServer3D::area_get_space(RID p_area) const { RID GodotPhysicsServer3D::area_get_space(RID p_area) const {
GodotArea3D *area = area_owner.get_or_null(p_area); GodotArea3D *area = area_owner.get_or_null(p_area);
@ -248,20 +248,6 @@ RID GodotPhysicsServer3D::area_get_space(RID p_area) const {
return RID(); return RID();
} }
return space->get_self(); return space->get_self();
};
void GodotPhysicsServer3D::area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode) {
GodotArea3D *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND(!area);
area->set_space_override_mode(p_mode);
}
PhysicsServer3D::AreaSpaceOverrideMode GodotPhysicsServer3D::area_get_space_override_mode(RID p_area) const {
const GodotArea3D *area = area_owner.get_or_null(p_area);
ERR_FAIL_COND_V(!area, AREA_SPACE_OVERRIDE_DISABLED);
return area->get_space_override_mode();
} }
void GodotPhysicsServer3D::area_add_shape(RID p_area, RID p_shape, const Transform3D &p_transform, bool p_disabled) { void GodotPhysicsServer3D::area_add_shape(RID p_area, RID p_shape, const Transform3D &p_transform, bool p_disabled) {

View File

@ -122,9 +122,6 @@ public:
virtual RID area_create() override; virtual RID area_create() override;
virtual void area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode) override;
virtual AreaSpaceOverrideMode area_get_space_override_mode(RID p_area) const override;
virtual void area_set_space(RID p_area, RID p_space) override; virtual void area_set_space(RID p_area, RID p_space) override;
virtual RID area_get_space(RID p_area) const override; virtual RID area_get_space(RID p_area) const override;

View File

@ -917,9 +917,7 @@ void GodotSoftBody3D::add_velocity(const Vector3 &p_velocity) {
} }
} }
void GodotSoftBody3D::apply_forces(bool p_has_wind_forces) { void GodotSoftBody3D::apply_forces(const LocalVector<GodotArea3D *> &p_wind_areas) {
int ac = areas.size();
if (nodes.is_empty()) { if (nodes.is_empty()) {
return; return;
} }
@ -932,7 +930,6 @@ void GodotSoftBody3D::apply_forces(bool p_has_wind_forces) {
// Iterate over faces (try not to iterate elsewhere if possible). // Iterate over faces (try not to iterate elsewhere if possible).
for (i = 0, ni = faces.size(); i < ni; ++i) { for (i = 0, ni = faces.size(); i < ni; ++i) {
bool stopped = false;
const Face &face = faces[i]; const Face &face = faces[i];
Vector3 wind_force(0, 0, 0); Vector3 wind_force(0, 0, 0);
@ -941,24 +938,10 @@ void GodotSoftBody3D::apply_forces(bool p_has_wind_forces) {
volume += vec3_dot(face.n[0]->x - org, vec3_cross(face.n[1]->x - org, face.n[2]->x - org)); volume += vec3_dot(face.n[0]->x - org, vec3_cross(face.n[1]->x - org, face.n[2]->x - org));
// Compute nodal forces from area winds. // Compute nodal forces from area winds.
if (ac && p_has_wind_forces) { int wind_area_count = p_wind_areas.size();
const AreaCMP *aa = &areas[0]; if (wind_area_count > 0) {
for (j = ac - 1; j >= 0 && !stopped; j--) { for (j = 0; j < wind_area_count; j++) {
PhysicsServer3D::AreaSpaceOverrideMode mode = aa[j].area->get_space_override_mode(); wind_force += _compute_area_windforce(p_wind_areas[j], &face);
switch (mode) {
case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE:
case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: {
wind_force += _compute_area_windforce(aa[j].area, &face);
stopped = mode == PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE;
} break;
case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE:
case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: {
wind_force = _compute_area_windforce(aa[j].area, &face);
stopped = mode == PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE;
} break;
default: {
}
}
} }
for (j = 0; j < 3; j++) { for (j = 0; j < 3; j++) {
@ -1004,44 +987,59 @@ void GodotSoftBody3D::predict_motion(real_t p_delta) {
ERR_FAIL_COND(!get_space()); ERR_FAIL_COND(!get_space());
GodotArea3D *def_area = get_space()->get_default_area();
ERR_FAIL_COND(!def_area);
gravity = def_area->get_gravity_vector() * def_area->get_gravity();
int ac = areas.size(); int ac = areas.size();
bool stopped = false;
bool has_wind_forces = false; bool gravity_done = false;
LocalVector<GodotArea3D *> wind_areas;
if (ac) { if (ac) {
areas.sort(); areas.sort();
const AreaCMP *aa = &areas[0]; const AreaCMP *aa = &areas[0];
for (int i = ac - 1; i >= 0 && !stopped; i--) { for (int i = ac - 1; i >= 0; i--) {
// Avoids unnecessary loop in apply_forces(). if (!gravity_done) {
has_wind_forces = has_wind_forces || aa[i].area->get_wind_force_magnitude() > CMP_EPSILON; PhysicsServer3D::AreaSpaceOverrideMode area_gravity_mode = (PhysicsServer3D::AreaSpaceOverrideMode)(int)aa[i].area->get_param(PhysicsServer3D::AREA_PARAM_GRAVITY_OVERRIDE_MODE);
if (area_gravity_mode != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED) {
PhysicsServer3D::AreaSpaceOverrideMode mode = aa[i].area->get_space_override_mode(); Vector3 area_gravity;
switch (mode) { aa[i].area->compute_gravity(get_transform().get_origin(), area_gravity);
case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE: switch (area_gravity_mode) {
case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: { case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE:
_compute_area_gravity(aa[i].area); case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: {
stopped = mode == PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE; gravity += area_gravity;
} break; gravity_done = area_gravity_mode == PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE;
case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE: } break;
case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: { case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE:
gravity = Vector3(0, 0, 0); case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: {
_compute_area_gravity(aa[i].area); gravity = Vector3(0, 0, 0);
stopped = mode == PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE; gravity = area_gravity;
} break; gravity_done = area_gravity_mode == PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE;
default: { } break;
default: {
}
}
} }
} }
if (aa[i].area->get_wind_force_magnitude() > CMP_EPSILON) {
wind_areas.push_back(aa[i].area);
}
} }
} }
// Add default gravity and damping from space area.
if (!gravity_done) {
GodotArea3D *default_area = get_space()->get_default_area();
ERR_FAIL_COND(!default_area);
Vector3 default_gravity;
default_area->compute_gravity(get_transform().get_origin(), default_gravity);
gravity += default_gravity;
}
// Apply forces. // Apply forces.
add_velocity(gravity * p_delta); add_velocity(gravity * p_delta);
if (pressure_coefficient > CMP_EPSILON || has_wind_forces) { if (pressure_coefficient > CMP_EPSILON || !wind_areas.is_empty()) {
apply_forces(has_wind_forces); apply_forces(wind_areas);
} }
// Avoid soft body from 'exploding' so use some upper threshold of maximum motion // Avoid soft body from 'exploding' so use some upper threshold of maximum motion

View File

@ -232,7 +232,7 @@ private:
void add_velocity(const Vector3 &p_velocity); void add_velocity(const Vector3 &p_velocity);
void apply_forces(bool p_has_wind_forces); void apply_forces(const LocalVector<GodotArea3D *> &p_wind_areas);
bool create_from_trimesh(const Vector<int> &p_indices, const Vector<Vector3> &p_vertices); bool create_from_trimesh(const Vector<int> &p_indices, const Vector<Vector3> &p_vertices);
void generate_bending_constraints(int p_distance); void generate_bending_constraints(int p_distance);

View File

@ -609,9 +609,6 @@ void PhysicsServer2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("area_set_space", "area", "space"), &PhysicsServer2D::area_set_space); ClassDB::bind_method(D_METHOD("area_set_space", "area", "space"), &PhysicsServer2D::area_set_space);
ClassDB::bind_method(D_METHOD("area_get_space", "area"), &PhysicsServer2D::area_get_space); ClassDB::bind_method(D_METHOD("area_get_space", "area"), &PhysicsServer2D::area_get_space);
ClassDB::bind_method(D_METHOD("area_set_space_override_mode", "area", "mode"), &PhysicsServer2D::area_set_space_override_mode);
ClassDB::bind_method(D_METHOD("area_get_space_override_mode", "area"), &PhysicsServer2D::area_get_space_override_mode);
ClassDB::bind_method(D_METHOD("area_add_shape", "area", "shape", "transform", "disabled"), &PhysicsServer2D::area_add_shape, DEFVAL(Transform2D()), DEFVAL(false)); ClassDB::bind_method(D_METHOD("area_add_shape", "area", "shape", "transform", "disabled"), &PhysicsServer2D::area_add_shape, DEFVAL(Transform2D()), DEFVAL(false));
ClassDB::bind_method(D_METHOD("area_set_shape", "area", "shape_idx", "shape"), &PhysicsServer2D::area_set_shape); ClassDB::bind_method(D_METHOD("area_set_shape", "area", "shape_idx", "shape"), &PhysicsServer2D::area_set_shape);
ClassDB::bind_method(D_METHOD("area_set_shape_transform", "area", "shape_idx", "transform"), &PhysicsServer2D::area_set_shape_transform); ClassDB::bind_method(D_METHOD("area_set_shape_transform", "area", "shape_idx", "transform"), &PhysicsServer2D::area_set_shape_transform);
@ -755,12 +752,15 @@ void PhysicsServer2D::_bind_methods() {
BIND_ENUM_CONSTANT(SHAPE_CONCAVE_POLYGON); BIND_ENUM_CONSTANT(SHAPE_CONCAVE_POLYGON);
BIND_ENUM_CONSTANT(SHAPE_CUSTOM); BIND_ENUM_CONSTANT(SHAPE_CUSTOM);
BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_OVERRIDE_MODE);
BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY); BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY);
BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_VECTOR); BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_VECTOR);
BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_IS_POINT); BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_IS_POINT);
BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_DISTANCE_SCALE); BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_DISTANCE_SCALE);
BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_POINT_ATTENUATION); BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_POINT_ATTENUATION);
BIND_ENUM_CONSTANT(AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE);
BIND_ENUM_CONSTANT(AREA_PARAM_LINEAR_DAMP); BIND_ENUM_CONSTANT(AREA_PARAM_LINEAR_DAMP);
BIND_ENUM_CONSTANT(AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE);
BIND_ENUM_CONSTANT(AREA_PARAM_ANGULAR_DAMP); BIND_ENUM_CONSTANT(AREA_PARAM_ANGULAR_DAMP);
BIND_ENUM_CONSTANT(AREA_PARAM_PRIORITY); BIND_ENUM_CONSTANT(AREA_PARAM_PRIORITY);

View File

@ -266,12 +266,15 @@ public:
//missing attenuation? missing better override? //missing attenuation? missing better override?
enum AreaParameter { enum AreaParameter {
AREA_PARAM_GRAVITY_OVERRIDE_MODE,
AREA_PARAM_GRAVITY, AREA_PARAM_GRAVITY,
AREA_PARAM_GRAVITY_VECTOR, AREA_PARAM_GRAVITY_VECTOR,
AREA_PARAM_GRAVITY_IS_POINT, AREA_PARAM_GRAVITY_IS_POINT,
AREA_PARAM_GRAVITY_DISTANCE_SCALE, AREA_PARAM_GRAVITY_DISTANCE_SCALE,
AREA_PARAM_GRAVITY_POINT_ATTENUATION, AREA_PARAM_GRAVITY_POINT_ATTENUATION,
AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE,
AREA_PARAM_LINEAR_DAMP, AREA_PARAM_LINEAR_DAMP,
AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE,
AREA_PARAM_ANGULAR_DAMP, AREA_PARAM_ANGULAR_DAMP,
AREA_PARAM_PRIORITY AREA_PARAM_PRIORITY
}; };
@ -289,9 +292,6 @@ public:
AREA_SPACE_OVERRIDE_REPLACE_COMBINE // Discards all previous calculations, then keeps combining AREA_SPACE_OVERRIDE_REPLACE_COMBINE // Discards all previous calculations, then keeps combining
}; };
virtual void area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode) = 0;
virtual AreaSpaceOverrideMode area_get_space_override_mode(RID p_area) const = 0;
virtual void area_add_shape(RID p_area, RID p_shape, const Transform2D &p_transform = Transform2D(), bool p_disabled = false) = 0; virtual void area_add_shape(RID p_area, RID p_shape, const Transform2D &p_transform = Transform2D(), bool p_disabled = false) = 0;
virtual void area_set_shape(RID p_area, int p_shape_idx, RID p_shape) = 0; virtual void area_set_shape(RID p_area, int p_shape_idx, RID p_shape) = 0;
virtual void area_set_shape_transform(RID p_area, int p_shape_idx, const Transform2D &p_transform) = 0; virtual void area_set_shape_transform(RID p_area, int p_shape_idx, const Transform2D &p_transform) = 0;

View File

@ -133,9 +133,6 @@ public:
FUNC2(area_set_space, RID, RID); FUNC2(area_set_space, RID, RID);
FUNC1RC(RID, area_get_space, RID); FUNC1RC(RID, area_get_space, RID);
FUNC2(area_set_space_override_mode, RID, AreaSpaceOverrideMode);
FUNC1RC(AreaSpaceOverrideMode, area_get_space_override_mode, RID);
FUNC4(area_add_shape, RID, RID, const Transform2D &, bool); FUNC4(area_add_shape, RID, RID, const Transform2D &, bool);
FUNC3(area_set_shape, RID, int, RID); FUNC3(area_set_shape, RID, int, RID);
FUNC3(area_set_shape_transform, RID, int, const Transform2D &); FUNC3(area_set_shape_transform, RID, int, const Transform2D &);

View File

@ -661,9 +661,6 @@ void PhysicsServer3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("area_set_space", "area", "space"), &PhysicsServer3D::area_set_space); ClassDB::bind_method(D_METHOD("area_set_space", "area", "space"), &PhysicsServer3D::area_set_space);
ClassDB::bind_method(D_METHOD("area_get_space", "area"), &PhysicsServer3D::area_get_space); ClassDB::bind_method(D_METHOD("area_get_space", "area"), &PhysicsServer3D::area_get_space);
ClassDB::bind_method(D_METHOD("area_set_space_override_mode", "area", "mode"), &PhysicsServer3D::area_set_space_override_mode);
ClassDB::bind_method(D_METHOD("area_get_space_override_mode", "area"), &PhysicsServer3D::area_get_space_override_mode);
ClassDB::bind_method(D_METHOD("area_add_shape", "area", "shape", "transform", "disabled"), &PhysicsServer3D::area_add_shape, DEFVAL(Transform3D()), DEFVAL(false)); ClassDB::bind_method(D_METHOD("area_add_shape", "area", "shape", "transform", "disabled"), &PhysicsServer3D::area_add_shape, DEFVAL(Transform3D()), DEFVAL(false));
ClassDB::bind_method(D_METHOD("area_set_shape", "area", "shape_idx", "shape"), &PhysicsServer3D::area_set_shape); ClassDB::bind_method(D_METHOD("area_set_shape", "area", "shape_idx", "shape"), &PhysicsServer3D::area_set_shape);
ClassDB::bind_method(D_METHOD("area_set_shape_transform", "area", "shape_idx", "transform"), &PhysicsServer3D::area_set_shape_transform); ClassDB::bind_method(D_METHOD("area_set_shape_transform", "area", "shape_idx", "transform"), &PhysicsServer3D::area_set_shape_transform);
@ -909,12 +906,15 @@ void PhysicsServer3D::_bind_methods() {
BIND_ENUM_CONSTANT(SHAPE_SOFT_BODY); BIND_ENUM_CONSTANT(SHAPE_SOFT_BODY);
BIND_ENUM_CONSTANT(SHAPE_CUSTOM); BIND_ENUM_CONSTANT(SHAPE_CUSTOM);
BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_OVERRIDE_MODE);
BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY); BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY);
BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_VECTOR); BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_VECTOR);
BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_IS_POINT); BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_IS_POINT);
BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_DISTANCE_SCALE); BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_DISTANCE_SCALE);
BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_POINT_ATTENUATION); BIND_ENUM_CONSTANT(AREA_PARAM_GRAVITY_POINT_ATTENUATION);
BIND_ENUM_CONSTANT(AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE);
BIND_ENUM_CONSTANT(AREA_PARAM_LINEAR_DAMP); BIND_ENUM_CONSTANT(AREA_PARAM_LINEAR_DAMP);
BIND_ENUM_CONSTANT(AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE);
BIND_ENUM_CONSTANT(AREA_PARAM_ANGULAR_DAMP); BIND_ENUM_CONSTANT(AREA_PARAM_ANGULAR_DAMP);
BIND_ENUM_CONSTANT(AREA_PARAM_PRIORITY); BIND_ENUM_CONSTANT(AREA_PARAM_PRIORITY);
BIND_ENUM_CONSTANT(AREA_PARAM_WIND_FORCE_MAGNITUDE); BIND_ENUM_CONSTANT(AREA_PARAM_WIND_FORCE_MAGNITUDE);

View File

@ -288,12 +288,15 @@ public:
//missing attenuation? missing better override? //missing attenuation? missing better override?
enum AreaParameter { enum AreaParameter {
AREA_PARAM_GRAVITY_OVERRIDE_MODE,
AREA_PARAM_GRAVITY, AREA_PARAM_GRAVITY,
AREA_PARAM_GRAVITY_VECTOR, AREA_PARAM_GRAVITY_VECTOR,
AREA_PARAM_GRAVITY_IS_POINT, AREA_PARAM_GRAVITY_IS_POINT,
AREA_PARAM_GRAVITY_DISTANCE_SCALE, AREA_PARAM_GRAVITY_DISTANCE_SCALE,
AREA_PARAM_GRAVITY_POINT_ATTENUATION, AREA_PARAM_GRAVITY_POINT_ATTENUATION,
AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE,
AREA_PARAM_LINEAR_DAMP, AREA_PARAM_LINEAR_DAMP,
AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE,
AREA_PARAM_ANGULAR_DAMP, AREA_PARAM_ANGULAR_DAMP,
AREA_PARAM_PRIORITY, AREA_PARAM_PRIORITY,
AREA_PARAM_WIND_FORCE_MAGNITUDE, AREA_PARAM_WIND_FORCE_MAGNITUDE,
@ -315,9 +318,6 @@ public:
AREA_SPACE_OVERRIDE_REPLACE_COMBINE AREA_SPACE_OVERRIDE_REPLACE_COMBINE
}; };
virtual void area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode) = 0;
virtual AreaSpaceOverrideMode area_get_space_override_mode(RID p_area) const = 0;
virtual void area_add_shape(RID p_area, RID p_shape, const Transform3D &p_transform = Transform3D(), bool p_disabled = false) = 0; virtual void area_add_shape(RID p_area, RID p_shape, const Transform3D &p_transform = Transform3D(), bool p_disabled = false) = 0;
virtual void area_set_shape(RID p_area, int p_shape_idx, RID p_shape) = 0; virtual void area_set_shape(RID p_area, int p_shape_idx, RID p_shape) = 0;
virtual void area_set_shape_transform(RID p_area, int p_shape_idx, const Transform3D &p_transform) = 0; virtual void area_set_shape_transform(RID p_area, int p_shape_idx, const Transform3D &p_transform) = 0;

View File

@ -137,9 +137,6 @@ public:
FUNC2(area_set_space, RID, RID); FUNC2(area_set_space, RID, RID);
FUNC1RC(RID, area_get_space, RID); FUNC1RC(RID, area_get_space, RID);
FUNC2(area_set_space_override_mode, RID, AreaSpaceOverrideMode);
FUNC1RC(AreaSpaceOverrideMode, area_get_space_override_mode, RID);
FUNC4(area_add_shape, RID, RID, const Transform3D &, bool); FUNC4(area_add_shape, RID, RID, const Transform3D &, bool);
FUNC3(area_set_shape, RID, int, RID); FUNC3(area_set_shape, RID, int, RID);
FUNC3(area_set_shape_transform, RID, int, const Transform3D &); FUNC3(area_set_shape_transform, RID, int, const Transform3D &);