Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
PhairZ committed Nov 17, 2024
1 parent 6c05ec3 commit 0c6cff3
Show file tree
Hide file tree
Showing 25 changed files with 300 additions and 87 deletions.
4 changes: 2 additions & 2 deletions core/math/geometry_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ Vector<Plane> Geometry3D::build_box_planes(const Vector3 &p_extents) {
return planes;
}

Vector<Plane> Geometry3D::build_cylinder_planes(real_t p_radius, real_t p_height, int p_sides, Vector3::Axis p_axis) {
Vector<Plane> Geometry3D::build_cylinder_planes(real_t p_radius, real_t p_height, int p_sides, int p_axis) {
ERR_FAIL_INDEX_V(p_axis, 3, Vector<Plane>());

Vector<Plane> planes;
Expand Down Expand Up @@ -793,7 +793,7 @@ Vector<Plane> Geometry3D::build_sphere_planes(real_t p_radius, int p_lats, int p
return planes;
}

Vector<Plane> Geometry3D::build_capsule_planes(real_t p_radius, real_t p_height, int p_sides, int p_lats, Vector3::Axis p_axis) {
Vector<Plane> Geometry3D::build_capsule_planes(real_t p_radius, real_t p_height, int p_sides, int p_lats, int p_axis) {
ERR_FAIL_INDEX_V(p_axis, 3, Vector<Plane>());

Vector<Plane> planes;
Expand Down
4 changes: 2 additions & 2 deletions core/math/geometry_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,8 @@ class Geometry3D {
static MeshData build_convex_mesh(const Vector<Plane> &p_planes);
static Vector<Plane> build_sphere_planes(real_t p_radius, int p_lats, int p_lons, Vector3::Axis p_axis = Vector3::AXIS_Z);
static Vector<Plane> build_box_planes(const Vector3 &p_extents);
static Vector<Plane> build_cylinder_planes(real_t p_radius, real_t p_height, int p_sides, Vector3::Axis p_axis = Vector3::AXIS_Z);
static Vector<Plane> build_capsule_planes(real_t p_radius, real_t p_height, int p_sides, int p_lats, Vector3::Axis p_axis = Vector3::AXIS_Z);
static Vector<Plane> build_cylinder_planes(real_t p_radius, real_t p_height, int p_sides, int p_axis = Vector3::AXIS_Z);
static Vector<Plane> build_capsule_planes(real_t p_radius, real_t p_height, int p_sides, int p_lats, int p_axis = Vector3::AXIS_Z);

static Vector<Vector3> compute_convex_mesh_points(const Plane *p_planes, int p_plane_count);

Expand Down
4 changes: 2 additions & 2 deletions doc/classes/Geometry3D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<param index="3" name="lats" type="int" />
<param index="4" name="axis" type="int" enum="Vector3.Axis" default="2" />
<description>
Returns an array of [Plane]s closely bounding a faceted capsule centered at the origin with radius [param radius] and height [param height]. The parameter [param sides] defines how many planes will be generated for the side part of the capsule, whereas [param lats] gives the number of latitudinal steps at the bottom and top of the capsule. The parameter [param axis] describes the axis along which the capsule is oriented (0 for X, 1 for Y, 2 for Z).
Returns an array of [Plane]s closely bounding a faceted capsule centered at the origin with radius [param radius] and height [param height]. The parameter [param sides] defines how many planes will be generated for the side part of the capsule, whereas [param lats] gives the number of latitudinal steps at the bottom and top of the capsule. The parameter [param axis] describes the index of the axis along which the capsule is oriented (see [constant Vector3.AXIS_X], [constant Vector3.AXIS_Y], and [constant Vector3.AXIS_Z]).
</description>
</method>
<method name="build_cylinder_planes">
Expand All @@ -34,7 +34,7 @@
<param index="2" name="sides" type="int" />
<param index="3" name="axis" type="int" enum="Vector3.Axis" default="2" />
<description>
Returns an array of [Plane]s closely bounding a faceted cylinder centered at the origin with radius [param radius] and height [param height]. The parameter [param sides] defines how many planes will be generated for the round part of the cylinder. The parameter [param axis] describes the axis along which the cylinder is oriented (0 for X, 1 for Y, 2 for Z).
Returns an array of [Plane]s closely bounding a faceted cylinder centered at the origin with radius [param radius] and height [param height]. The parameter [param sides] defines how many planes will be generated for the round part of the cylinder. The parameter [param axis] describes the index of the axis along which the cylinder is oriented (see [constant Vector3.AXIS_X], [constant Vector3.AXIS_Y], and [constant Vector3.AXIS_Z]).
</description>
</method>
<method name="clip_polygon">
Expand Down
4 changes: 2 additions & 2 deletions doc/classes/LookAtModifier3D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@
<member name="primary_positive_limit_angle" type="float" setter="set_primary_positive_limit_angle" getter="get_primary_positive_limit_angle">
The limit angle of positive side of the primary rotation when [member symmetry_limitation] is [code]false[/code].
</member>
<member name="primary_rotation_axis" type="int" setter="set_primary_rotation_axis" getter="get_primary_rotation_axis" enum="Vector3.Axis" default="1">
The axis of the first rotation. This [SkeletonModifier3D] works by compositing the rotation by Euler angles to prevent to rotate the [member forward_axis].
<member name="primary_rotation_axis" type="int" setter="set_primary_rotation_axis" getter="get_primary_rotation_axis" default="1">
The index of the axis of the first rotation. This [SkeletonModifier3D] works by compositing the rotation by Euler angles to prevent to rotate the [member forward_axis] (see [constant Vector3.AXIS_X], [constant Vector3.AXIS_Y], and [constant Vector3.AXIS_Z]).
</member>
<member name="secondary_damp_threshold" type="float" setter="set_secondary_damp_threshold" getter="get_secondary_damp_threshold">
The threshold to start damping for [member secondary_limit_angle].
Expand Down
8 changes: 4 additions & 4 deletions doc/classes/PhysicsServer3D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@
<method name="generic_6dof_joint_get_flag" qualifiers="const">
<return type="bool" />
<param index="0" name="joint" type="RID" />
<param index="1" name="axis" type="int" enum="Vector3.Axis" />
<param index="1" name="axis" type="int" />
<param index="2" name="flag" type="int" enum="PhysicsServer3D.G6DOFJointAxisFlag" />
<description>
Returns the value of a generic 6DOF joint flag. See [enum G6DOFJointAxisFlag] for the list of available flags.
Expand All @@ -764,7 +764,7 @@
<method name="generic_6dof_joint_get_param" qualifiers="const">
<return type="float" />
<param index="0" name="joint" type="RID" />
<param index="1" name="axis" type="int" enum="Vector3.Axis" />
<param index="1" name="axis" type="int" />
<param index="2" name="param" type="int" enum="PhysicsServer3D.G6DOFJointAxisParam" />
<description>
Returns the value of a generic 6DOF joint parameter. See [enum G6DOFJointAxisParam] for the list of available parameters.
Expand All @@ -773,7 +773,7 @@
<method name="generic_6dof_joint_set_flag">
<return type="void" />
<param index="0" name="joint" type="RID" />
<param index="1" name="axis" type="int" enum="Vector3.Axis" />
<param index="1" name="axis" type="int" />
<param index="2" name="flag" type="int" enum="PhysicsServer3D.G6DOFJointAxisFlag" />
<param index="3" name="enable" type="bool" />
<description>
Expand All @@ -783,7 +783,7 @@
<method name="generic_6dof_joint_set_param">
<return type="void" />
<param index="0" name="joint" type="RID" />
<param index="1" name="axis" type="int" enum="Vector3.Axis" />
<param index="1" name="axis" type="int" />
<param index="2" name="param" type="int" enum="PhysicsServer3D.G6DOFJointAxisParam" />
<param index="3" name="value" type="float" />
<description>
Expand Down
8 changes: 4 additions & 4 deletions doc/classes/PhysicsServer3DExtension.xml
Original file line number Diff line number Diff line change
Expand Up @@ -683,23 +683,23 @@
<method name="_generic_6dof_joint_get_flag" qualifiers="virtual const">
<return type="bool" />
<param index="0" name="joint" type="RID" />
<param index="1" name="axis" type="int" enum="Vector3.Axis" />
<param index="1" name="axis" type="int" />
<param index="2" name="flag" type="int" enum="PhysicsServer3D.G6DOFJointAxisFlag" />
<description>
</description>
</method>
<method name="_generic_6dof_joint_get_param" qualifiers="virtual const">
<return type="float" />
<param index="0" name="joint" type="RID" />
<param index="1" name="axis" type="int" enum="Vector3.Axis" />
<param index="1" name="axis" type="int" />
<param index="2" name="param" type="int" enum="PhysicsServer3D.G6DOFJointAxisParam" />
<description>
</description>
</method>
<method name="_generic_6dof_joint_set_flag" qualifiers="virtual">
<return type="void" />
<param index="0" name="joint" type="RID" />
<param index="1" name="axis" type="int" enum="Vector3.Axis" />
<param index="1" name="axis" type="int" />
<param index="2" name="flag" type="int" enum="PhysicsServer3D.G6DOFJointAxisFlag" />
<param index="3" name="enable" type="bool" />
<description>
Expand All @@ -708,7 +708,7 @@
<method name="_generic_6dof_joint_set_param" qualifiers="virtual">
<return type="void" />
<param index="0" name="joint" type="RID" />
<param index="1" name="axis" type="int" enum="Vector3.Axis" />
<param index="1" name="axis" type="int" />
<param index="2" name="param" type="int" enum="PhysicsServer3D.G6DOFJointAxisParam" />
<param index="3" name="value" type="float" />
<description>
Expand Down
4 changes: 2 additions & 2 deletions doc/classes/SpriteBase3D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
<member name="alpha_scissor_threshold" type="float" setter="set_alpha_scissor_threshold" getter="get_alpha_scissor_threshold" default="0.5">
Threshold at which the alpha scissor will discard values.
</member>
<member name="axis" type="int" setter="set_axis" getter="get_axis" enum="Vector3.Axis" default="2">
The direction in which the front of the texture faces.
<member name="axis" type="int" setter="set_axis" getter="get_axis" default="2">
The index of the axis in which the front of the texture faces (see [constant Vector3.AXIS_X], [constant Vector3.AXIS_Y], and [constant Vector3.AXIS_Z]).
</member>
<member name="billboard" type="int" setter="set_billboard_mode" getter="get_billboard_mode" enum="BaseMaterial3D.BillboardMode" default="0">
The billboard mode to use for the sprite. See [enum BaseMaterial3D.BillboardMode] for possible values.
Expand Down
16 changes: 16 additions & 0 deletions misc/extension_api_validation/4.3-stable.expected
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,19 @@ GH-98918
Validate extension JSON: Error: Field 'classes/FileAccess/methods/open_encrypted/arguments': size changed value in new API, from 3 to 4.

Optional argument added to allow setting initialization vector. Compatibility method registered.


GH-99341
--------
Validate extension JSON: Error: Field 'classes/PhysicsServer3D/methods/generic_6dof_joint_set_param/arguments/1': type changed value in new API, from "enum::Vector3.Axis" to "int".
Validate extension JSON: Error: Field 'classes/PhysicsServer3D/methods/generic_6dof_joint_get_param/arguments/1': type changed value in new API, from "enum::Vector3.Axis" to "int".
Validate extension JSON: Error: Field 'classes/PhysicsServer3D/methods/generic_6dof_joint_set_flag/arguments/1': type changed value in new API, from "enum::Vector3.Axis" to "int".
Validate extension JSON: Error: Field 'classes/PhysicsServer3D/methods/generic_6dof_joint_get_flag/arguments/1': type changed value in new API, from "enum::Vector3.Axis" to "int".
Validate extension JSON: Error: Field 'classes/PhysicsServer3DExtension/methods/_generic_6dof_joint_set_param/arguments/1': type changed value in new API, from "enum::Vector3.Axis" to "int".
Validate extension JSON: Error: Field 'classes/PhysicsServer3DExtension/methods/_generic_6dof_joint_get_param/arguments/1': type changed value in new API, from "enum::Vector3.Axis" to "int".
Validate extension JSON: Error: Field 'classes/PhysicsServer3DExtension/methods/_generic_6dof_joint_set_flag/arguments/1': type changed value in new API, from "enum::Vector3.Axis" to "int".
Validate extension JSON: Error: Field 'classes/PhysicsServer3DExtension/methods/_generic_6dof_joint_get_flag/arguments/1': type changed value in new API, from "enum::Vector3.Axis" to "int".
Validate extension JSON: Error: Field 'classes/SpriteBase3D/methods/set_axis/arguments/0': type changed value in new API, from "enum::Vector3.Axis" to "int".
Validate extension JSON: Error: Field 'classes/SpriteBase3D/methods/get_axis/return_value': type changed value in new API, from "enum::Vector3.Axis" to "int".

Fix use of non-existent Vector3.Axis enum type in built-in methods and members
50 changes: 50 additions & 0 deletions modules/godot_physics_3d/godot_physics_server_3d.compat.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**************************************************************************/
/* godot_physics_server_3d.compat.inc */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/

#ifndef DISABLE_DEPRECATED
#include "godot_physics_server_3d.h"

void GodotPhysicsServer3D::_generic_6dof_joint_set_param_bind_compat_99341(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param, real_t p_value) {
GodotPhysicsServer3D::generic_6dof_joint_set_param(p_joint, (int)p_axis, p_param, p_value);
}

real_t GodotPhysicsServer3D::_generic_6dof_joint_get_param_bind_compat_99341(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param) const {
return GodotPhysicsServer3D::generic_6dof_joint_get_param(p_joint, (int)p_axis, p_param);
}

void GodotPhysicsServer3D::_generic_6dof_joint_set_flag_bind_compat_99341(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag, bool p_enable) {
GodotPhysicsServer3D::generic_6dof_joint_set_flag(p_joint, (int)p_axis, p_flag, p_enable);
}

bool GodotPhysicsServer3D::_generic_6dof_joint_get_flag_bind_compat_99341(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag) const {
return GodotPhysicsServer3D::generic_6dof_joint_get_flag(p_joint, (int)p_axis, p_flag);
}

#endif //DISABLE_DEPRECATED
9 changes: 5 additions & 4 deletions modules/godot_physics_3d/godot_physics_server_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
/**************************************************************************/

#include "godot_physics_server_3d.h"
#include "godot_physics_server_3d.compat.inc"

#include "godot_body_direct_state_3d.h"
#include "godot_broad_phase_3d_bvh.h"
Expand Down Expand Up @@ -1521,31 +1522,31 @@ void GodotPhysicsServer3D::joint_make_generic_6dof(RID p_joint, RID p_body_A, co
memdelete(prev_joint);
}

void GodotPhysicsServer3D::generic_6dof_joint_set_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param, real_t p_value) {
void GodotPhysicsServer3D::generic_6dof_joint_set_param(RID p_joint, int p_axis, G6DOFJointAxisParam p_param, real_t p_value) {
GodotJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_6DOF);
GodotGeneric6DOFJoint3D *generic_6dof_joint = static_cast<GodotGeneric6DOFJoint3D *>(joint);
generic_6dof_joint->set_param(p_axis, p_param, p_value);
}

real_t GodotPhysicsServer3D::generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param) const {
real_t GodotPhysicsServer3D::generic_6dof_joint_get_param(RID p_joint, int p_axis, G6DOFJointAxisParam p_param) const {
GodotJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, 0);
ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_6DOF, 0);
GodotGeneric6DOFJoint3D *generic_6dof_joint = static_cast<GodotGeneric6DOFJoint3D *>(joint);
return generic_6dof_joint->get_param(p_axis, p_param);
}

void GodotPhysicsServer3D::generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag, bool p_enable) {
void GodotPhysicsServer3D::generic_6dof_joint_set_flag(RID p_joint, int p_axis, G6DOFJointAxisFlag p_flag, bool p_enable) {
GodotJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL(joint);
ERR_FAIL_COND(joint->get_type() != JOINT_TYPE_6DOF);
GodotGeneric6DOFJoint3D *generic_6dof_joint = static_cast<GodotGeneric6DOFJoint3D *>(joint);
generic_6dof_joint->set_flag(p_axis, p_flag, p_enable);
}

bool GodotPhysicsServer3D::generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag) const {
bool GodotPhysicsServer3D::generic_6dof_joint_get_flag(RID p_joint, int p_axis, G6DOFJointAxisFlag p_flag) const {
GodotJoint3D *joint = joint_owner.get_or_null(p_joint);
ERR_FAIL_NULL_V(joint, false);
ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_6DOF, false);
Expand Down
17 changes: 13 additions & 4 deletions modules/godot_physics_3d/godot_physics_server_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,20 @@ class GodotPhysicsServer3D : public PhysicsServer3D {

virtual void joint_make_generic_6dof(RID p_joint, RID p_body_A, const Transform3D &p_local_frame_A, RID p_body_B, const Transform3D &p_local_frame_B) override; //reference frame is A

virtual void generic_6dof_joint_set_param(RID p_joint, Vector3::Axis, G6DOFJointAxisParam p_param, real_t p_value) override;
virtual real_t generic_6dof_joint_get_param(RID p_joint, Vector3::Axis, G6DOFJointAxisParam p_param) const override;
virtual void generic_6dof_joint_set_param(RID p_joint, int, G6DOFJointAxisParam p_param, real_t p_value) override;
virtual real_t generic_6dof_joint_get_param(RID p_joint, int, G6DOFJointAxisParam p_param) const override;

virtual void generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis, G6DOFJointAxisFlag p_flag, bool p_enable) override;
virtual bool generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis, G6DOFJointAxisFlag p_flag) const override;
virtual void generic_6dof_joint_set_flag(RID p_joint, int, G6DOFJointAxisFlag p_flag, bool p_enable) override;
virtual bool generic_6dof_joint_get_flag(RID p_joint, int, G6DOFJointAxisFlag p_flag) const override;

#ifndef DISABLE_DEPRECATED
virtual void _generic_6dof_joint_set_param_bind_compat_99341(RID p_joint, Vector3::Axis, G6DOFJointAxisParam p_param, real_t p_value) override;
virtual real_t _generic_6dof_joint_get_param_bind_compat_99341(RID p_joint, Vector3::Axis, G6DOFJointAxisParam p_param) const override;

virtual void _generic_6dof_joint_set_flag_bind_compat_99341(RID p_joint, Vector3::Axis, G6DOFJointAxisFlag p_flag, bool p_enable) override;
virtual bool _generic_6dof_joint_get_flag_bind_compat_99341(RID p_joint, Vector3::Axis, G6DOFJointAxisFlag p_flag) const override;

#endif //DISABLE_DEPRECATED

virtual JointType joint_get_type(RID p_joint) const override;

Expand Down
Loading

0 comments on commit 0c6cff3

Please sign in to comment.