Rename WorldMarginShape to WorldBoundaryShape
This commit is contained in:
parent
fd17ce1890
commit
bb75aec8bc
|
@ -823,7 +823,7 @@
|
|||
Sets the value for a space parameter. See [enum SpaceParameter] for a list of available parameters.
|
||||
</description>
|
||||
</method>
|
||||
<method name="world_margin_shape_create">
|
||||
<method name="world_boundary_shape_create">
|
||||
<return type="RID" />
|
||||
<description>
|
||||
</description>
|
||||
|
@ -853,8 +853,8 @@
|
|||
</constant>
|
||||
<constant name="SPACE_PARAM_TEST_MOTION_MIN_CONTACT_DEPTH" value="7" enum="SpaceParameter">
|
||||
</constant>
|
||||
<constant name="SHAPE_WORLD_MARGIN" value="0" enum="ShapeType">
|
||||
This is the constant for creating world margin shapes. A world margin shape is an [i]infinite[/i] line with an origin point, and a normal. Thus, it can be used for front/behind checks.
|
||||
<constant name="SHAPE_WORLD_BOUNDARY" value="0" enum="ShapeType">
|
||||
This is the constant for creating world boundary shapes. A world boundary shape is an [i]infinite[/i] line with an origin point, and a normal. Thus, it can be used for front/behind checks.
|
||||
</constant>
|
||||
<constant name="SHAPE_SEPARATION_RAY" value="1" enum="ShapeType">
|
||||
This is the constant for creating separation ray shapes. A separation ray is defined by a length and separates itself from what is touching its far endpoint. Useful for character controllers.
|
||||
|
|
|
@ -855,11 +855,6 @@
|
|||
Sets a pin_joint parameter (see [enum PinJointParam] constants).
|
||||
</description>
|
||||
</method>
|
||||
<method name="plane_shape_create">
|
||||
<return type="RID" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="separation_ray_shape_create">
|
||||
<return type="RID" />
|
||||
<description>
|
||||
|
@ -975,6 +970,11 @@
|
|||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="world_boundary_shape_create">
|
||||
<return type="RID" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<constants>
|
||||
<constant name="JOINT_TYPE_PIN" value="0" enum="JointType">
|
||||
|
@ -1184,8 +1184,8 @@
|
|||
<constant name="G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR" value="5" enum="G6DOFJointAxisFlag">
|
||||
If [code]set[/code] there is a linear motor on this axis that targets a specific velocity.
|
||||
</constant>
|
||||
<constant name="SHAPE_PLANE" value="0" enum="ShapeType">
|
||||
The [Shape3D] is a [WorldMarginShape3D].
|
||||
<constant name="SHAPE_WORLD_BOUNDARY" value="0" enum="ShapeType">
|
||||
The [Shape3D] is a [WorldBoundaryShape3D].
|
||||
</constant>
|
||||
<constant name="SHAPE_SEPARATION_RAY" value="1" enum="ShapeType">
|
||||
The [Shape3D] is a [SeparationRayShape3D].
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="WorldMarginShape2D" inherits="Shape2D" version="4.0">
|
||||
<class name="WorldBoundaryShape2D" inherits="Shape2D" version="4.0">
|
||||
<brief_description>
|
||||
Line shape for 2D collisions.
|
||||
World boundary shape for 2D collisions.
|
||||
</brief_description>
|
||||
<description>
|
||||
Line shape for 2D collisions. It works like a 2D plane and will not allow any physics body to go to the negative side. Not recommended for rigid bodies, and usually not recommended for static bodies either because it forces checks against it on every frame.
|
||||
World boundary shape for 2D collisions. It works like a 2D plane and will not allow any physics body to go to the negative side. Not recommended for rigid bodies, and usually not recommended for static bodies either because it forces checks against it on every frame.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="WorldBoundaryShape3D" inherits="Shape3D" version="4.0">
|
||||
<brief_description>
|
||||
World boundary shape for 3D collisions.
|
||||
</brief_description>
|
||||
<description>
|
||||
World boundary shape for 3D collisions. It works like an infinite plane and will not allow any physics body to go to the negative side. Note that the [Plane]'s normal matters; anything "below" the plane will collide with it. If the [WorldBoundaryShape3D] is used in a [PhysicsBody3D], it will cause colliding objects placed "below" it to teleport "above" the plane.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="plane" type="Plane" setter="set_plane" getter="get_plane" default="Plane(0, 1, 0, 0)">
|
||||
The [Plane] used by the [WorldBoundaryShape3D] for collision.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
|
@ -1,20 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="WorldMarginShape3D" inherits="Shape3D" version="4.0">
|
||||
<brief_description>
|
||||
Infinite plane shape for 3D collisions.
|
||||
</brief_description>
|
||||
<description>
|
||||
An infinite plane shape for 3D collisions. Note that the [Plane]'s normal matters; anything "below" the plane will collide with it. If the [WorldMarginShape3D] is used in a [PhysicsBody3D], it will cause colliding objects placed "below" it to teleport "above" the plane.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="plane" type="Plane" setter="set_plane" getter="get_plane" default="Plane(0, 1, 0, 0)">
|
||||
The [Plane] used by the [WorldMarginShape3D] for collision.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
Before Width: | Height: | Size: 392 B After Width: | Height: | Size: 392 B |
Before Width: | Height: | Size: 192 B After Width: | Height: | Size: 192 B |
|
@ -49,7 +49,7 @@
|
|||
#include "scene/resources/separation_ray_shape_3d.h"
|
||||
#include "scene/resources/sphere_shape_3d.h"
|
||||
#include "scene/resources/surface_tool.h"
|
||||
#include "scene/resources/world_margin_shape_3d.h"
|
||||
#include "scene/resources/world_boundary_shape_3d.h"
|
||||
|
||||
uint32_t EditorSceneImporter::get_import_flags() const {
|
||||
int ret;
|
||||
|
@ -386,8 +386,8 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<E
|
|||
colshape->set_shape(rayShape);
|
||||
Object::cast_to<Node3D>(sb)->rotate_x(Math_PI / 2);
|
||||
} else if (empty_draw_type == "IMAGE") {
|
||||
WorldMarginShape3D *world_margin_shape = memnew(WorldMarginShape3D);
|
||||
colshape->set_shape(world_margin_shape);
|
||||
WorldBoundaryShape3D *world_boundary_shape = memnew(WorldBoundaryShape3D);
|
||||
colshape->set_shape(world_boundary_shape);
|
||||
} else {
|
||||
SphereShape3D *sphereShape = memnew(SphereShape3D);
|
||||
sphereShape->set_radius(1);
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#include "scene/resources/rectangle_shape_2d.h"
|
||||
#include "scene/resources/segment_shape_2d.h"
|
||||
#include "scene/resources/separation_ray_shape_2d.h"
|
||||
#include "scene/resources/world_margin_shape_2d.h"
|
||||
#include "scene/resources/world_boundary_shape_2d.h"
|
||||
|
||||
void CollisionShape2DEditor::_node_removed(Node *p_node) {
|
||||
if (p_node == node) {
|
||||
|
@ -70,13 +70,13 @@ Variant CollisionShape2DEditor::get_handle_value(int idx) const {
|
|||
case CONVEX_POLYGON_SHAPE: {
|
||||
} break;
|
||||
|
||||
case WORLD_MARGIN_SHAPE: {
|
||||
Ref<WorldMarginShape2D> line = node->get_shape();
|
||||
case WORLD_BOUNDARY_SHAPE: {
|
||||
Ref<WorldBoundaryShape2D> world_boundary = node->get_shape();
|
||||
|
||||
if (idx == 0) {
|
||||
return line->get_distance();
|
||||
return world_boundary->get_distance();
|
||||
} else {
|
||||
return line->get_normal();
|
||||
return world_boundary->get_normal();
|
||||
}
|
||||
|
||||
} break;
|
||||
|
@ -147,14 +147,14 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) {
|
|||
case CONVEX_POLYGON_SHAPE: {
|
||||
} break;
|
||||
|
||||
case WORLD_MARGIN_SHAPE: {
|
||||
case WORLD_BOUNDARY_SHAPE: {
|
||||
if (idx < 2) {
|
||||
Ref<WorldMarginShape2D> line = node->get_shape();
|
||||
Ref<WorldBoundaryShape2D> world_boundary = node->get_shape();
|
||||
|
||||
if (idx == 0) {
|
||||
line->set_distance(p_point.length());
|
||||
world_boundary->set_distance(p_point.length());
|
||||
} else {
|
||||
line->set_normal(p_point.normalized());
|
||||
world_boundary->set_normal(p_point.normalized());
|
||||
}
|
||||
|
||||
canvas_item_editor->update_viewport();
|
||||
|
@ -255,18 +255,18 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) {
|
|||
// Cannot be edited directly, use CollisionPolygon2D instead.
|
||||
} break;
|
||||
|
||||
case WORLD_MARGIN_SHAPE: {
|
||||
Ref<WorldMarginShape2D> line = node->get_shape();
|
||||
case WORLD_BOUNDARY_SHAPE: {
|
||||
Ref<WorldBoundaryShape2D> world_boundary = node->get_shape();
|
||||
|
||||
if (idx == 0) {
|
||||
undo_redo->add_do_method(line.ptr(), "set_distance", line->get_distance());
|
||||
undo_redo->add_do_method(world_boundary.ptr(), "set_distance", world_boundary->get_distance());
|
||||
undo_redo->add_do_method(canvas_item_editor, "update_viewport");
|
||||
undo_redo->add_undo_method(line.ptr(), "set_distance", p_org);
|
||||
undo_redo->add_undo_method(world_boundary.ptr(), "set_distance", p_org);
|
||||
undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
|
||||
} else {
|
||||
undo_redo->add_do_method(line.ptr(), "set_normal", line->get_normal());
|
||||
undo_redo->add_do_method(world_boundary.ptr(), "set_normal", world_boundary->get_normal());
|
||||
undo_redo->add_do_method(canvas_item_editor, "update_viewport");
|
||||
undo_redo->add_undo_method(line.ptr(), "set_normal", p_org);
|
||||
undo_redo->add_undo_method(world_boundary.ptr(), "set_normal", p_org);
|
||||
undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
|
||||
}
|
||||
|
||||
|
@ -421,8 +421,8 @@ void CollisionShape2DEditor::_get_current_shape_type() {
|
|||
shape_type = CONCAVE_POLYGON_SHAPE;
|
||||
} else if (Object::cast_to<ConvexPolygonShape2D>(*s)) {
|
||||
shape_type = CONVEX_POLYGON_SHAPE;
|
||||
} else if (Object::cast_to<WorldMarginShape2D>(*s)) {
|
||||
shape_type = WORLD_MARGIN_SHAPE;
|
||||
} else if (Object::cast_to<WorldBoundaryShape2D>(*s)) {
|
||||
shape_type = WORLD_BOUNDARY_SHAPE;
|
||||
} else if (Object::cast_to<SeparationRayShape2D>(*s)) {
|
||||
shape_type = SEPARATION_RAY_SHAPE;
|
||||
} else if (Object::cast_to<RectangleShape2D>(*s)) {
|
||||
|
@ -490,8 +490,8 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla
|
|||
case CONVEX_POLYGON_SHAPE: {
|
||||
} break;
|
||||
|
||||
case WORLD_MARGIN_SHAPE: {
|
||||
Ref<WorldMarginShape2D> shape = node->get_shape();
|
||||
case WORLD_BOUNDARY_SHAPE: {
|
||||
Ref<WorldBoundaryShape2D> shape = node->get_shape();
|
||||
|
||||
handles.resize(2);
|
||||
handles.write[0] = shape->get_normal() * shape->get_distance();
|
||||
|
|
|
@ -46,7 +46,7 @@ class CollisionShape2DEditor : public Control {
|
|||
CIRCLE_SHAPE,
|
||||
CONCAVE_POLYGON_SHAPE,
|
||||
CONVEX_POLYGON_SHAPE,
|
||||
WORLD_MARGIN_SHAPE,
|
||||
WORLD_BOUNDARY_SHAPE,
|
||||
SEPARATION_RAY_SHAPE,
|
||||
RECTANGLE_SHAPE,
|
||||
SEGMENT_SHAPE
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
#include "scene/resources/separation_ray_shape_3d.h"
|
||||
#include "scene/resources/sphere_shape_3d.h"
|
||||
#include "scene/resources/surface_tool.h"
|
||||
#include "scene/resources/world_margin_shape_3d.h"
|
||||
#include "scene/resources/world_boundary_shape_3d.h"
|
||||
|
||||
#define HANDLE_HALF_SIZE 9.5
|
||||
|
||||
|
@ -4537,9 +4537,9 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
|||
p_gizmo->add_handles(handles, handles_material);
|
||||
}
|
||||
|
||||
if (Object::cast_to<WorldMarginShape3D>(*s)) {
|
||||
Ref<WorldMarginShape3D> ps = s;
|
||||
Plane p = ps->get_plane();
|
||||
if (Object::cast_to<WorldBoundaryShape3D>(*s)) {
|
||||
Ref<WorldBoundaryShape3D> wbs = s;
|
||||
const Plane &p = wbs->get_plane();
|
||||
Vector<Vector3> points;
|
||||
|
||||
Vector3 n1 = p.get_any_perpendicular_normal();
|
||||
|
|
|
@ -87,8 +87,8 @@ RID BulletPhysicsServer3D::shape_create(ShapeType p_shape) {
|
|||
ShapeBullet *shape = nullptr;
|
||||
|
||||
switch (p_shape) {
|
||||
case SHAPE_PLANE: {
|
||||
shape = bulletnew(PlaneShapeBullet);
|
||||
case SHAPE_WORLD_BOUNDARY: {
|
||||
shape = bulletnew(WorldBoundaryShapeBullet);
|
||||
} break;
|
||||
case SHAPE_SPHERE: {
|
||||
shape = bulletnew(SphereShapeBullet);
|
||||
|
|
|
@ -110,7 +110,7 @@ btEmptyShape *ShapeBullet::create_shape_empty() {
|
|||
return bulletnew(btEmptyShape);
|
||||
}
|
||||
|
||||
btStaticPlaneShape *ShapeBullet::create_shape_plane(const btVector3 &planeNormal, btScalar planeConstant) {
|
||||
btStaticPlaneShape *ShapeBullet::create_shape_world_boundary(const btVector3 &planeNormal, btScalar planeConstant) {
|
||||
return bulletnew(btStaticPlaneShape(planeNormal, planeConstant));
|
||||
}
|
||||
|
||||
|
@ -164,32 +164,32 @@ btRayShape *ShapeBullet::create_shape_ray(real_t p_length, bool p_slips_on_slope
|
|||
return r;
|
||||
}
|
||||
|
||||
/* PLANE */
|
||||
/* World boundary */
|
||||
|
||||
PlaneShapeBullet::PlaneShapeBullet() :
|
||||
WorldBoundaryShapeBullet::WorldBoundaryShapeBullet() :
|
||||
ShapeBullet() {}
|
||||
|
||||
void PlaneShapeBullet::set_data(const Variant &p_data) {
|
||||
void WorldBoundaryShapeBullet::set_data(const Variant &p_data) {
|
||||
setup(p_data);
|
||||
}
|
||||
|
||||
Variant PlaneShapeBullet::get_data() const {
|
||||
Variant WorldBoundaryShapeBullet::get_data() const {
|
||||
return plane;
|
||||
}
|
||||
|
||||
PhysicsServer3D::ShapeType PlaneShapeBullet::get_type() const {
|
||||
return PhysicsServer3D::SHAPE_PLANE;
|
||||
PhysicsServer3D::ShapeType WorldBoundaryShapeBullet::get_type() const {
|
||||
return PhysicsServer3D::SHAPE_WORLD_BOUNDARY;
|
||||
}
|
||||
|
||||
void PlaneShapeBullet::setup(const Plane &p_plane) {
|
||||
void WorldBoundaryShapeBullet::setup(const Plane &p_plane) {
|
||||
plane = p_plane;
|
||||
notifyShapeChanged();
|
||||
}
|
||||
|
||||
btCollisionShape *PlaneShapeBullet::create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge) {
|
||||
btCollisionShape *WorldBoundaryShapeBullet::create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge) {
|
||||
btVector3 btPlaneNormal;
|
||||
G_TO_B(plane.normal, btPlaneNormal);
|
||||
return prepare(PlaneShapeBullet::create_shape_plane(btPlaneNormal, plane.d));
|
||||
return prepare(WorldBoundaryShapeBullet::create_shape_world_boundary(btPlaneNormal, plane.d));
|
||||
}
|
||||
|
||||
/* Sphere */
|
||||
|
|
|
@ -81,7 +81,7 @@ public:
|
|||
|
||||
public:
|
||||
static class btEmptyShape *create_shape_empty();
|
||||
static class btStaticPlaneShape *create_shape_plane(const btVector3 &planeNormal, btScalar planeConstant);
|
||||
static class btStaticPlaneShape *create_shape_world_boundary(const btVector3 &planeNormal, btScalar planeConstant);
|
||||
static class btSphereShape *create_shape_sphere(btScalar radius);
|
||||
static class btBoxShape *create_shape_box(const btVector3 &boxHalfExtents);
|
||||
static class btCapsuleShape *create_shape_capsule(btScalar radius, btScalar height);
|
||||
|
@ -93,11 +93,11 @@ public:
|
|||
static class btRayShape *create_shape_ray(real_t p_length, bool p_slips_on_slope);
|
||||
};
|
||||
|
||||
class PlaneShapeBullet : public ShapeBullet {
|
||||
class WorldBoundaryShapeBullet : public ShapeBullet {
|
||||
Plane plane;
|
||||
|
||||
public:
|
||||
PlaneShapeBullet();
|
||||
WorldBoundaryShapeBullet();
|
||||
|
||||
virtual void set_data(const Variant &p_data);
|
||||
virtual Variant get_data() const;
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
#include "scene/resources/primitive_meshes.h"
|
||||
#include "scene/resources/shape_3d.h"
|
||||
#include "scene/resources/sphere_shape_3d.h"
|
||||
#include "scene/resources/world_margin_shape_3d.h"
|
||||
#include "scene/resources/world_boundary_shape_3d.h"
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
#include "editor/editor_node.h"
|
||||
|
|
|
@ -196,8 +196,8 @@
|
|||
#include "scene/resources/visual_shader_sdf_nodes.h"
|
||||
#include "scene/resources/world_2d.h"
|
||||
#include "scene/resources/world_3d.h"
|
||||
#include "scene/resources/world_margin_shape_2d.h"
|
||||
#include "scene/resources/world_margin_shape_3d.h"
|
||||
#include "scene/resources/world_boundary_shape_2d.h"
|
||||
#include "scene/resources/world_boundary_shape_3d.h"
|
||||
#include "scene/scene_string_names.h"
|
||||
|
||||
#include "scene/main/shader_globals_override.h"
|
||||
|
@ -748,7 +748,7 @@ void register_scene_types() {
|
|||
GDREGISTER_CLASS(CapsuleShape3D);
|
||||
GDREGISTER_CLASS(CylinderShape3D);
|
||||
GDREGISTER_CLASS(HeightMapShape3D);
|
||||
GDREGISTER_CLASS(WorldMarginShape3D);
|
||||
GDREGISTER_CLASS(WorldBoundaryShape3D);
|
||||
GDREGISTER_CLASS(ConvexPolygonShape3D);
|
||||
GDREGISTER_CLASS(ConcavePolygonShape3D);
|
||||
|
||||
|
@ -829,7 +829,7 @@ void register_scene_types() {
|
|||
OS::get_singleton()->yield(); //may take time to init
|
||||
|
||||
GDREGISTER_VIRTUAL_CLASS(Shape2D);
|
||||
GDREGISTER_CLASS(WorldMarginShape2D);
|
||||
GDREGISTER_CLASS(WorldBoundaryShape2D);
|
||||
GDREGISTER_CLASS(SegmentShape2D);
|
||||
GDREGISTER_CLASS(SeparationRayShape2D);
|
||||
GDREGISTER_CLASS(CircleShape2D);
|
||||
|
@ -917,7 +917,7 @@ void register_scene_types() {
|
|||
ClassDB::add_compatibility_class("KinematicBody2D", "CharacterBody2D");
|
||||
ClassDB::add_compatibility_class("KinematicCollision", "KinematicCollision3D");
|
||||
ClassDB::add_compatibility_class("Light", "Light3D");
|
||||
ClassDB::add_compatibility_class("LineShape2D", "WorldMarginShape2D");
|
||||
ClassDB::add_compatibility_class("LineShape2D", "WorldBoundaryShape2D");
|
||||
ClassDB::add_compatibility_class("Listener", "Listener3D");
|
||||
ClassDB::add_compatibility_class("MeshInstance", "MeshInstance3D");
|
||||
ClassDB::add_compatibility_class("MultiMeshInstance", "MultiMeshInstance3D");
|
||||
|
@ -948,7 +948,7 @@ void register_scene_types() {
|
|||
ClassDB::add_compatibility_class("PhysicsServer", "PhysicsServer3D");
|
||||
ClassDB::add_compatibility_class("PhysicsShapeQueryParameters", "PhysicsShapeQueryParameters3D");
|
||||
ClassDB::add_compatibility_class("PinJoint", "PinJoint3D");
|
||||
ClassDB::add_compatibility_class("PlaneShape", "WorldMarginShape3D");
|
||||
ClassDB::add_compatibility_class("PlaneShape", "WorldBoundaryShape3D");
|
||||
ClassDB::add_compatibility_class("ProceduralSky", "Sky");
|
||||
ClassDB::add_compatibility_class("ProximityGroup", "ProximityGroup3D");
|
||||
ClassDB::add_compatibility_class("RayCast", "RayCast3D");
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*************************************************************************/
|
||||
/* world_margin_shape_2d.cpp */
|
||||
/* world_boundary_shape_2d.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
|
@ -28,13 +28,13 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "world_margin_shape_2d.h"
|
||||
#include "world_boundary_shape_2d.h"
|
||||
|
||||
#include "core/math/geometry_2d.h"
|
||||
#include "servers/physics_server_2d.h"
|
||||
#include "servers/rendering_server.h"
|
||||
|
||||
bool WorldMarginShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
|
||||
bool WorldBoundaryShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
|
||||
Vector2 point = get_distance() * get_normal();
|
||||
Vector2 l[2][2] = { { point - get_normal().orthogonal() * 100, point + get_normal().orthogonal() * 100 }, { point, point + get_normal() * 30 } };
|
||||
|
||||
|
@ -48,7 +48,7 @@ bool WorldMarginShape2D::_edit_is_selected_on_click(const Point2 &p_point, doubl
|
|||
return false;
|
||||
}
|
||||
|
||||
void WorldMarginShape2D::_update_shape() {
|
||||
void WorldBoundaryShape2D::_update_shape() {
|
||||
Array arr;
|
||||
arr.push_back(normal);
|
||||
arr.push_back(distance);
|
||||
|
@ -56,25 +56,25 @@ void WorldMarginShape2D::_update_shape() {
|
|||
emit_changed();
|
||||
}
|
||||
|
||||
void WorldMarginShape2D::set_normal(const Vector2 &p_normal) {
|
||||
void WorldBoundaryShape2D::set_normal(const Vector2 &p_normal) {
|
||||
normal = p_normal;
|
||||
_update_shape();
|
||||
}
|
||||
|
||||
void WorldMarginShape2D::set_distance(real_t p_distance) {
|
||||
void WorldBoundaryShape2D::set_distance(real_t p_distance) {
|
||||
distance = p_distance;
|
||||
_update_shape();
|
||||
}
|
||||
|
||||
Vector2 WorldMarginShape2D::get_normal() const {
|
||||
Vector2 WorldBoundaryShape2D::get_normal() const {
|
||||
return normal;
|
||||
}
|
||||
|
||||
real_t WorldMarginShape2D::get_distance() const {
|
||||
real_t WorldBoundaryShape2D::get_distance() const {
|
||||
return distance;
|
||||
}
|
||||
|
||||
void WorldMarginShape2D::draw(const RID &p_to_rid, const Color &p_color) {
|
||||
void WorldBoundaryShape2D::draw(const RID &p_to_rid, const Color &p_color) {
|
||||
Vector2 point = get_distance() * get_normal();
|
||||
|
||||
Vector2 l1[2] = { point - get_normal().orthogonal() * 100, point + get_normal().orthogonal() * 100 };
|
||||
|
@ -83,7 +83,7 @@ void WorldMarginShape2D::draw(const RID &p_to_rid, const Color &p_color) {
|
|||
RS::get_singleton()->canvas_item_add_line(p_to_rid, l2[0], l2[1], p_color, 3);
|
||||
}
|
||||
|
||||
Rect2 WorldMarginShape2D::get_rect() const {
|
||||
Rect2 WorldBoundaryShape2D::get_rect() const {
|
||||
Vector2 point = get_distance() * get_normal();
|
||||
|
||||
Vector2 l1[2] = { point - get_normal().orthogonal() * 100, point + get_normal().orthogonal() * 100 };
|
||||
|
@ -96,22 +96,22 @@ Rect2 WorldMarginShape2D::get_rect() const {
|
|||
return rect;
|
||||
}
|
||||
|
||||
real_t WorldMarginShape2D::get_enclosing_radius() const {
|
||||
real_t WorldBoundaryShape2D::get_enclosing_radius() const {
|
||||
return distance;
|
||||
}
|
||||
|
||||
void WorldMarginShape2D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_normal", "normal"), &WorldMarginShape2D::set_normal);
|
||||
ClassDB::bind_method(D_METHOD("get_normal"), &WorldMarginShape2D::get_normal);
|
||||
void WorldBoundaryShape2D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_normal", "normal"), &WorldBoundaryShape2D::set_normal);
|
||||
ClassDB::bind_method(D_METHOD("get_normal"), &WorldBoundaryShape2D::get_normal);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_distance", "distance"), &WorldMarginShape2D::set_distance);
|
||||
ClassDB::bind_method(D_METHOD("get_distance"), &WorldMarginShape2D::get_distance);
|
||||
ClassDB::bind_method(D_METHOD("set_distance", "distance"), &WorldBoundaryShape2D::set_distance);
|
||||
ClassDB::bind_method(D_METHOD("get_distance"), &WorldBoundaryShape2D::get_distance);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "normal"), "set_normal", "get_normal");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "distance"), "set_distance", "get_distance");
|
||||
}
|
||||
|
||||
WorldMarginShape2D::WorldMarginShape2D() :
|
||||
Shape2D(PhysicsServer2D::get_singleton()->world_margin_shape_create()) {
|
||||
WorldBoundaryShape2D::WorldBoundaryShape2D() :
|
||||
Shape2D(PhysicsServer2D::get_singleton()->world_boundary_shape_create()) {
|
||||
_update_shape();
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*************************************************************************/
|
||||
/* world_margin_shape_2d.h */
|
||||
/* world_boundary_shape_2d.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
|
@ -28,15 +28,15 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef WORLD_MARGIN_SHAPE_2D_H
|
||||
#define WORLD_MARGIN_SHAPE_2D_H
|
||||
#ifndef WORLD_BOUNDARY_SHAPE_2D_H
|
||||
#define WORLD_BOUNDARY_SHAPE_2D_H
|
||||
|
||||
#include "scene/resources/shape_2d.h"
|
||||
|
||||
class WorldMarginShape2D : public Shape2D {
|
||||
GDCLASS(WorldMarginShape2D, Shape2D);
|
||||
class WorldBoundaryShape2D : public Shape2D {
|
||||
GDCLASS(WorldBoundaryShape2D, Shape2D);
|
||||
|
||||
// WorldMarginShape2D is often used for one-way platforms, where the normal pointing up makes sense.
|
||||
// WorldBoundaryShape2D is often used for one-way platforms, where the normal pointing up makes sense.
|
||||
Vector2 normal = Vector2(0, -1);
|
||||
real_t distance = 0.0;
|
||||
|
||||
|
@ -58,7 +58,7 @@ public:
|
|||
virtual Rect2 get_rect() const override;
|
||||
virtual real_t get_enclosing_radius() const override;
|
||||
|
||||
WorldMarginShape2D();
|
||||
WorldBoundaryShape2D();
|
||||
};
|
||||
|
||||
#endif // WORLD_MARGIN_SHAPE_2D_H
|
||||
#endif // WORLD_BOUNDARY_SHAPE_2D_H
|
|
@ -1,5 +1,5 @@
|
|||
/*************************************************************************/
|
||||
/* world_margin_shape_3d.cpp */
|
||||
/* world_boundary_shape_3d.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
|
@ -28,11 +28,11 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "world_margin_shape_3d.h"
|
||||
#include "world_boundary_shape_3d.h"
|
||||
|
||||
#include "servers/physics_server_3d.h"
|
||||
|
||||
Vector<Vector3> WorldMarginShape3D::get_debug_mesh_lines() const {
|
||||
Vector<Vector3> WorldBoundaryShape3D::get_debug_mesh_lines() const {
|
||||
Plane p = get_plane();
|
||||
Vector<Vector3> points;
|
||||
|
||||
|
@ -60,29 +60,29 @@ Vector<Vector3> WorldMarginShape3D::get_debug_mesh_lines() const {
|
|||
return points;
|
||||
}
|
||||
|
||||
void WorldMarginShape3D::_update_shape() {
|
||||
void WorldBoundaryShape3D::_update_shape() {
|
||||
PhysicsServer3D::get_singleton()->shape_set_data(get_shape(), plane);
|
||||
Shape3D::_update_shape();
|
||||
}
|
||||
|
||||
void WorldMarginShape3D::set_plane(Plane p_plane) {
|
||||
void WorldBoundaryShape3D::set_plane(const Plane &p_plane) {
|
||||
plane = p_plane;
|
||||
_update_shape();
|
||||
notify_change_to_owners();
|
||||
}
|
||||
|
||||
Plane WorldMarginShape3D::get_plane() const {
|
||||
const Plane &WorldBoundaryShape3D::get_plane() const {
|
||||
return plane;
|
||||
}
|
||||
|
||||
void WorldMarginShape3D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_plane", "plane"), &WorldMarginShape3D::set_plane);
|
||||
ClassDB::bind_method(D_METHOD("get_plane"), &WorldMarginShape3D::get_plane);
|
||||
void WorldBoundaryShape3D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_plane", "plane"), &WorldBoundaryShape3D::set_plane);
|
||||
ClassDB::bind_method(D_METHOD("get_plane"), &WorldBoundaryShape3D::get_plane);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::PLANE, "plane"), "set_plane", "get_plane");
|
||||
}
|
||||
|
||||
WorldMarginShape3D::WorldMarginShape3D() :
|
||||
Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_PLANE)) {
|
||||
WorldBoundaryShape3D::WorldBoundaryShape3D() :
|
||||
Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_WORLD_BOUNDARY)) {
|
||||
set_plane(Plane(0, 1, 0, 0));
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*************************************************************************/
|
||||
/* world_margin_shape_3d.h */
|
||||
/* world_boundary_shape_3d.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
|
@ -28,13 +28,13 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef WORLD_MARGIN_SHAPE_3D_H
|
||||
#define WORLD_MARGIN_SHAPE_3D_H
|
||||
#ifndef WORLD_BOUNDARY_SHAPE_3D_H
|
||||
#define WORLD_BOUNDARY_SHAPE_3D_H
|
||||
|
||||
#include "scene/resources/shape_3d.h"
|
||||
|
||||
class WorldMarginShape3D : public Shape3D {
|
||||
GDCLASS(WorldMarginShape3D, Shape3D);
|
||||
class WorldBoundaryShape3D : public Shape3D {
|
||||
GDCLASS(WorldBoundaryShape3D, Shape3D);
|
||||
Plane plane;
|
||||
|
||||
protected:
|
||||
|
@ -42,8 +42,8 @@ protected:
|
|||
virtual void _update_shape() override;
|
||||
|
||||
public:
|
||||
void set_plane(Plane p_plane);
|
||||
Plane get_plane() const;
|
||||
void set_plane(const Plane &p_plane);
|
||||
const Plane &get_plane() const;
|
||||
|
||||
virtual Vector<Vector3> get_debug_mesh_lines() const override;
|
||||
virtual real_t get_enclosing_radius() const override {
|
||||
|
@ -51,6 +51,6 @@ public:
|
|||
return 0;
|
||||
}
|
||||
|
||||
WorldMarginShape3D();
|
||||
WorldBoundaryShape3D();
|
||||
};
|
||||
#endif // WORLD_MARGIN_SHAPE_H
|
||||
#endif // WORLD_BOUNDARY_SHAPE_H
|
|
@ -1114,13 +1114,13 @@ static void _collision_convex_polygon_convex_polygon(const Shape2DSW *p_a, const
|
|||
bool sat_2d_calculate_penetration(const Shape2DSW *p_shape_A, const Transform2D &p_transform_A, const Vector2 &p_motion_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, const Vector2 &p_motion_B, CollisionSolver2DSW::CallbackResult p_result_callback, void *p_userdata, bool p_swap, Vector2 *sep_axis, real_t p_margin_A, real_t p_margin_B) {
|
||||
PhysicsServer2D::ShapeType type_A = p_shape_A->get_type();
|
||||
|
||||
ERR_FAIL_COND_V(type_A == PhysicsServer2D::SHAPE_WORLD_MARGIN, false);
|
||||
ERR_FAIL_COND_V(type_A == PhysicsServer2D::SHAPE_WORLD_BOUNDARY, false);
|
||||
ERR_FAIL_COND_V(type_A == PhysicsServer2D::SHAPE_SEPARATION_RAY, false);
|
||||
ERR_FAIL_COND_V(p_shape_A->is_concave(), false);
|
||||
|
||||
PhysicsServer2D::ShapeType type_B = p_shape_B->get_type();
|
||||
|
||||
ERR_FAIL_COND_V(type_B == PhysicsServer2D::SHAPE_WORLD_MARGIN, false);
|
||||
ERR_FAIL_COND_V(type_B == PhysicsServer2D::SHAPE_WORLD_BOUNDARY, false);
|
||||
ERR_FAIL_COND_V(type_B == PhysicsServer2D::SHAPE_SEPARATION_RAY, false);
|
||||
ERR_FAIL_COND_V(p_shape_B->is_concave(), false);
|
||||
|
||||
|
|
|
@ -34,14 +34,14 @@
|
|||
#define collision_solver sat_2d_calculate_penetration
|
||||
//#define collision_solver gjk_epa_calculate_penetration
|
||||
|
||||
bool CollisionSolver2DSW::solve_static_world_margin(const Shape2DSW *p_shape_A, const Transform2D &p_transform_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result) {
|
||||
const WorldMarginShape2DSW *world_margin = static_cast<const WorldMarginShape2DSW *>(p_shape_A);
|
||||
if (p_shape_B->get_type() == PhysicsServer2D::SHAPE_WORLD_MARGIN) {
|
||||
bool CollisionSolver2DSW::solve_static_world_boundary(const Shape2DSW *p_shape_A, const Transform2D &p_transform_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result) {
|
||||
const WorldBoundaryShape2DSW *world_boundary = static_cast<const WorldBoundaryShape2DSW *>(p_shape_A);
|
||||
if (p_shape_B->get_type() == PhysicsServer2D::SHAPE_WORLD_BOUNDARY) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector2 n = p_transform_A.basis_xform(world_margin->get_normal()).normalized();
|
||||
Vector2 p = p_transform_A.xform(world_margin->get_normal() * world_margin->get_d());
|
||||
Vector2 n = p_transform_A.basis_xform(world_boundary->get_normal()).normalized();
|
||||
Vector2 p = p_transform_A.xform(world_boundary->get_normal() * world_boundary->get_d());
|
||||
real_t d = n.dot(p);
|
||||
|
||||
Vector2 supports[2];
|
||||
|
@ -225,15 +225,15 @@ bool CollisionSolver2DSW::solve(const Shape2DSW *p_shape_A, const Transform2D &p
|
|||
swap = true;
|
||||
}
|
||||
|
||||
if (type_A == PhysicsServer2D::SHAPE_WORLD_MARGIN) {
|
||||
if (type_B == PhysicsServer2D::SHAPE_WORLD_MARGIN) {
|
||||
if (type_A == PhysicsServer2D::SHAPE_WORLD_BOUNDARY) {
|
||||
if (type_B == PhysicsServer2D::SHAPE_WORLD_BOUNDARY) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (swap) {
|
||||
return solve_static_world_margin(p_shape_B, p_transform_B, p_shape_A, p_transform_A, p_result_callback, p_userdata, true);
|
||||
return solve_static_world_boundary(p_shape_B, p_transform_B, p_shape_A, p_transform_A, p_result_callback, p_userdata, true);
|
||||
} else {
|
||||
return solve_static_world_margin(p_shape_A, p_transform_A, p_shape_B, p_transform_B, p_result_callback, p_userdata, false);
|
||||
return solve_static_world_boundary(p_shape_A, p_transform_A, p_shape_B, p_transform_B, p_result_callback, p_userdata, false);
|
||||
}
|
||||
|
||||
} else if (type_A == PhysicsServer2D::SHAPE_SEPARATION_RAY) {
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
typedef void (*CallbackResult)(const Vector2 &p_point_A, const Vector2 &p_point_B, void *p_userdata);
|
||||
|
||||
private:
|
||||
static bool solve_static_world_margin(const Shape2DSW *p_shape_A, const Transform2D &p_transform_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result);
|
||||
static bool solve_static_world_boundary(const Shape2DSW *p_shape_A, const Transform2D &p_transform_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result);
|
||||
static bool concave_callback(void *p_userdata, Shape2DSW *p_convex);
|
||||
static bool solve_concave(const Shape2DSW *p_shape_A, const Transform2D &p_transform_A, const Vector2 &p_motion_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, const Vector2 &p_motion_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result, Vector2 *r_sep_axis = nullptr, real_t p_margin_A = 0, real_t p_margin_B = 0);
|
||||
static bool solve_separation_ray(const Shape2DSW *p_shape_A, const Vector2 &p_motion_A, const Transform2D &p_transform_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result, Vector2 *r_sep_axis = nullptr, real_t p_margin = 0);
|
||||
|
|
|
@ -43,8 +43,8 @@
|
|||
RID PhysicsServer2DSW::_shape_create(ShapeType p_shape) {
|
||||
Shape2DSW *shape = nullptr;
|
||||
switch (p_shape) {
|
||||
case SHAPE_WORLD_MARGIN: {
|
||||
shape = memnew(WorldMarginShape2DSW);
|
||||
case SHAPE_WORLD_BOUNDARY: {
|
||||
shape = memnew(WorldBoundaryShape2DSW);
|
||||
} break;
|
||||
case SHAPE_SEPARATION_RAY: {
|
||||
shape = memnew(SeparationRayShape2DSW);
|
||||
|
@ -79,8 +79,8 @@ RID PhysicsServer2DSW::_shape_create(ShapeType p_shape) {
|
|||
return id;
|
||||
}
|
||||
|
||||
RID PhysicsServer2DSW::world_margin_shape_create() {
|
||||
return _shape_create(SHAPE_WORLD_MARGIN);
|
||||
RID PhysicsServer2DSW::world_boundary_shape_create() {
|
||||
return _shape_create(SHAPE_WORLD_BOUNDARY);
|
||||
}
|
||||
|
||||
RID PhysicsServer2DSW::separation_ray_shape_create() {
|
||||
|
|
|
@ -84,7 +84,7 @@ public:
|
|||
Vector2 *ptr;
|
||||
};
|
||||
|
||||
virtual RID world_margin_shape_create() override;
|
||||
virtual RID world_boundary_shape_create() override;
|
||||
virtual RID separation_ray_shape_create() override;
|
||||
virtual RID segment_shape_create() override;
|
||||
virtual RID circle_shape_create() override;
|
||||
|
|
|
@ -79,7 +79,7 @@ public:
|
|||
#include "servers/server_wrap_mt_common.h"
|
||||
|
||||
//FUNC1RID(shape,ShapeType); todo fix
|
||||
FUNCRID(world_margin_shape)
|
||||
FUNCRID(world_boundary_shape)
|
||||
FUNCRID(separation_ray_shape)
|
||||
FUNCRID(segment_shape)
|
||||
FUNCRID(circle_shape)
|
||||
|
|
|
@ -88,15 +88,15 @@ Shape2DSW::~Shape2DSW() {
|
|||
/*********************************************************/
|
||||
/*********************************************************/
|
||||
|
||||
void WorldMarginShape2DSW::get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const {
|
||||
void WorldBoundaryShape2DSW::get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const {
|
||||
r_amount = 0;
|
||||
}
|
||||
|
||||
bool WorldMarginShape2DSW::contains_point(const Vector2 &p_point) const {
|
||||
bool WorldBoundaryShape2DSW::contains_point(const Vector2 &p_point) const {
|
||||
return normal.dot(p_point) < d;
|
||||
}
|
||||
|
||||
bool WorldMarginShape2DSW::intersect_segment(const Vector2 &p_begin, const Vector2 &p_end, Vector2 &r_point, Vector2 &r_normal) const {
|
||||
bool WorldBoundaryShape2DSW::intersect_segment(const Vector2 &p_begin, const Vector2 &p_end, Vector2 &r_point, Vector2 &r_normal) const {
|
||||
Vector2 segment = p_begin - p_end;
|
||||
real_t den = normal.dot(segment);
|
||||
|
||||
|
@ -118,11 +118,11 @@ bool WorldMarginShape2DSW::intersect_segment(const Vector2 &p_begin, const Vecto
|
|||
return true;
|
||||
}
|
||||
|
||||
real_t WorldMarginShape2DSW::get_moment_of_inertia(real_t p_mass, const Size2 &p_scale) const {
|
||||
real_t WorldBoundaryShape2DSW::get_moment_of_inertia(real_t p_mass, const Size2 &p_scale) const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void WorldMarginShape2DSW::set_data(const Variant &p_data) {
|
||||
void WorldBoundaryShape2DSW::set_data(const Variant &p_data) {
|
||||
ERR_FAIL_COND(p_data.get_type() != Variant::ARRAY);
|
||||
Array arr = p_data;
|
||||
ERR_FAIL_COND(arr.size() != 2);
|
||||
|
@ -131,7 +131,7 @@ void WorldMarginShape2DSW::set_data(const Variant &p_data) {
|
|||
configure(Rect2(Vector2(-1e4, -1e4), Vector2(1e4 * 2, 1e4 * 2)));
|
||||
}
|
||||
|
||||
Variant WorldMarginShape2DSW::get_data() const {
|
||||
Variant WorldBoundaryShape2DSW::get_data() const {
|
||||
Array arr;
|
||||
arr.resize(2);
|
||||
arr[0] = normal;
|
||||
|
|
|
@ -142,7 +142,7 @@ public:
|
|||
r_max = MAX(maxa, maxb); \
|
||||
}
|
||||
|
||||
class WorldMarginShape2DSW : public Shape2DSW {
|
||||
class WorldBoundaryShape2DSW : public Shape2DSW {
|
||||
Vector2 normal;
|
||||
real_t d;
|
||||
|
||||
|
@ -150,7 +150,7 @@ public:
|
|||
_FORCE_INLINE_ Vector2 get_normal() const { return normal; }
|
||||
_FORCE_INLINE_ real_t get_d() const { return d; }
|
||||
|
||||
virtual PhysicsServer2D::ShapeType get_type() const override { return PhysicsServer2D::SHAPE_WORLD_MARGIN; }
|
||||
virtual PhysicsServer2D::ShapeType get_type() const override { return PhysicsServer2D::SHAPE_WORLD_BOUNDARY; }
|
||||
|
||||
virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const override { project_range(p_normal, p_transform, r_min, r_max); }
|
||||
virtual void get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const override;
|
||||
|
|
|
@ -2272,13 +2272,13 @@ static void _collision_convex_polygon_face(const Shape3DSW *p_a, const Transform
|
|||
bool sat_calculate_penetration(const Shape3DSW *p_shape_A, const Transform3D &p_transform_A, const Shape3DSW *p_shape_B, const Transform3D &p_transform_B, CollisionSolver3DSW::CallbackResult p_result_callback, void *p_userdata, bool p_swap, Vector3 *r_prev_axis, real_t p_margin_a, real_t p_margin_b) {
|
||||
PhysicsServer3D::ShapeType type_A = p_shape_A->get_type();
|
||||
|
||||
ERR_FAIL_COND_V(type_A == PhysicsServer3D::SHAPE_PLANE, false);
|
||||
ERR_FAIL_COND_V(type_A == PhysicsServer3D::SHAPE_WORLD_BOUNDARY, false);
|
||||
ERR_FAIL_COND_V(type_A == PhysicsServer3D::SHAPE_SEPARATION_RAY, false);
|
||||
ERR_FAIL_COND_V(p_shape_A->is_concave(), false);
|
||||
|
||||
PhysicsServer3D::ShapeType type_B = p_shape_B->get_type();
|
||||
|
||||
ERR_FAIL_COND_V(type_B == PhysicsServer3D::SHAPE_PLANE, false);
|
||||
ERR_FAIL_COND_V(type_B == PhysicsServer3D::SHAPE_WORLD_BOUNDARY, false);
|
||||
ERR_FAIL_COND_V(type_B == PhysicsServer3D::SHAPE_SEPARATION_RAY, false);
|
||||
ERR_FAIL_COND_V(p_shape_B->is_concave(), false);
|
||||
|
||||
|
|
|
@ -37,12 +37,12 @@
|
|||
#define collision_solver sat_calculate_penetration
|
||||
//#define collision_solver gjk_epa_calculate_penetration
|
||||
|
||||
bool CollisionSolver3DSW::solve_static_plane(const Shape3DSW *p_shape_A, const Transform3D &p_transform_A, const Shape3DSW *p_shape_B, const Transform3D &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result) {
|
||||
const PlaneShape3DSW *plane = static_cast<const PlaneShape3DSW *>(p_shape_A);
|
||||
if (p_shape_B->get_type() == PhysicsServer3D::SHAPE_PLANE) {
|
||||
bool CollisionSolver3DSW::solve_static_world_boundary(const Shape3DSW *p_shape_A, const Transform3D &p_transform_A, const Shape3DSW *p_shape_B, const Transform3D &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result) {
|
||||
const WorldBoundaryShape3DSW *world_boundary = static_cast<const WorldBoundaryShape3DSW *>(p_shape_A);
|
||||
if (p_shape_B->get_type() == PhysicsServer3D::SHAPE_WORLD_BOUNDARY) {
|
||||
return false;
|
||||
}
|
||||
Plane p = p_transform_A.xform(plane->get_plane());
|
||||
Plane p = p_transform_A.xform(world_boundary->get_plane());
|
||||
|
||||
static const int max_supports = 16;
|
||||
Vector3 supports[max_supports];
|
||||
|
@ -365,8 +365,8 @@ bool CollisionSolver3DSW::solve_static(const Shape3DSW *p_shape_A, const Transfo
|
|||
swap = true;
|
||||
}
|
||||
|
||||
if (type_A == PhysicsServer3D::SHAPE_PLANE) {
|
||||
if (type_B == PhysicsServer3D::SHAPE_PLANE) {
|
||||
if (type_A == PhysicsServer3D::SHAPE_WORLD_BOUNDARY) {
|
||||
if (type_B == PhysicsServer3D::SHAPE_WORLD_BOUNDARY) {
|
||||
return false;
|
||||
}
|
||||
if (type_B == PhysicsServer3D::SHAPE_SEPARATION_RAY) {
|
||||
|
@ -377,9 +377,9 @@ bool CollisionSolver3DSW::solve_static(const Shape3DSW *p_shape_A, const Transfo
|
|||
}
|
||||
|
||||
if (swap) {
|
||||
return solve_static_plane(p_shape_B, p_transform_B, p_shape_A, p_transform_A, p_result_callback, p_userdata, true);
|
||||
return solve_static_world_boundary(p_shape_B, p_transform_B, p_shape_A, p_transform_A, p_result_callback, p_userdata, true);
|
||||
} else {
|
||||
return solve_static_plane(p_shape_A, p_transform_A, p_shape_B, p_transform_B, p_result_callback, p_userdata, false);
|
||||
return solve_static_world_boundary(p_shape_A, p_transform_A, p_shape_B, p_transform_B, p_result_callback, p_userdata, false);
|
||||
}
|
||||
|
||||
} else if (type_A == PhysicsServer3D::SHAPE_SEPARATION_RAY) {
|
||||
|
@ -443,12 +443,12 @@ bool CollisionSolver3DSW::concave_distance_callback(void *p_userdata, Shape3DSW
|
|||
return false;
|
||||
}
|
||||
|
||||
bool CollisionSolver3DSW::solve_distance_plane(const Shape3DSW *p_shape_A, const Transform3D &p_transform_A, const Shape3DSW *p_shape_B, const Transform3D &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B) {
|
||||
const PlaneShape3DSW *plane = static_cast<const PlaneShape3DSW *>(p_shape_A);
|
||||
if (p_shape_B->get_type() == PhysicsServer3D::SHAPE_PLANE) {
|
||||
bool CollisionSolver3DSW::solve_distance_world_boundary(const Shape3DSW *p_shape_A, const Transform3D &p_transform_A, const Shape3DSW *p_shape_B, const Transform3D &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B) {
|
||||
const WorldBoundaryShape3DSW *world_boundary = static_cast<const WorldBoundaryShape3DSW *>(p_shape_A);
|
||||
if (p_shape_B->get_type() == PhysicsServer3D::SHAPE_WORLD_BOUNDARY) {
|
||||
return false;
|
||||
}
|
||||
Plane p = p_transform_A.xform(plane->get_plane());
|
||||
Plane p = p_transform_A.xform(world_boundary->get_plane());
|
||||
|
||||
static const int max_supports = 16;
|
||||
Vector3 supports[max_supports];
|
||||
|
@ -500,9 +500,9 @@ bool CollisionSolver3DSW::solve_distance(const Shape3DSW *p_shape_A, const Trans
|
|||
return false;
|
||||
}
|
||||
|
||||
if (p_shape_B->get_type() == PhysicsServer3D::SHAPE_PLANE) {
|
||||
if (p_shape_B->get_type() == PhysicsServer3D::SHAPE_WORLD_BOUNDARY) {
|
||||
Vector3 a, b;
|
||||
bool col = solve_distance_plane(p_shape_B, p_transform_B, p_shape_A, p_transform_A, a, b);
|
||||
bool col = solve_distance_world_boundary(p_shape_B, p_transform_B, p_shape_A, p_transform_A, a, b);
|
||||
r_point_A = b;
|
||||
r_point_B = a;
|
||||
return !col;
|
||||
|
|
|
@ -42,12 +42,12 @@ private:
|
|||
static void soft_body_contact_callback(const Vector3 &p_point_A, int p_index_A, const Vector3 &p_point_B, int p_index_B, void *p_userdata);
|
||||
static bool soft_body_concave_callback(void *p_userdata, Shape3DSW *p_convex);
|
||||
static bool concave_callback(void *p_userdata, Shape3DSW *p_convex);
|
||||
static bool solve_static_plane(const Shape3DSW *p_shape_A, const Transform3D &p_transform_A, const Shape3DSW *p_shape_B, const Transform3D &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result);
|
||||
static bool solve_static_world_boundary(const Shape3DSW *p_shape_A, const Transform3D &p_transform_A, const Shape3DSW *p_shape_B, const Transform3D &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result);
|
||||
static bool solve_separation_ray(const Shape3DSW *p_shape_A, const Transform3D &p_transform_A, const Shape3DSW *p_shape_B, const Transform3D &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result, real_t p_margin = 0);
|
||||
static bool solve_soft_body(const Shape3DSW *p_shape_A, const Transform3D &p_transform_A, const Shape3DSW *p_shape_B, const Transform3D &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result);
|
||||
static bool solve_concave(const Shape3DSW *p_shape_A, const Transform3D &p_transform_A, const Shape3DSW *p_shape_B, const Transform3D &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result, real_t p_margin_A = 0, real_t p_margin_B = 0);
|
||||
static bool concave_distance_callback(void *p_userdata, Shape3DSW *p_convex);
|
||||
static bool solve_distance_plane(const Shape3DSW *p_shape_A, const Transform3D &p_transform_A, const Shape3DSW *p_shape_B, const Transform3D &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B);
|
||||
static bool solve_distance_world_boundary(const Shape3DSW *p_shape_A, const Transform3D &p_transform_A, const Shape3DSW *p_shape_B, const Transform3D &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B);
|
||||
|
||||
public:
|
||||
static bool solve_static(const Shape3DSW *p_shape_A, const Transform3D &p_transform_A, const Shape3DSW *p_shape_B, const Transform3D &p_transform_B, CallbackResult p_result_callback, void *p_userdata, Vector3 *r_sep_axis = nullptr, real_t p_margin_A = 0, real_t p_margin_B = 0);
|
||||
|
|
|
@ -43,8 +43,8 @@
|
|||
#define FLUSH_QUERY_CHECK(m_object) \
|
||||
ERR_FAIL_COND_MSG(m_object->get_space() && flushing_queries, "Can't change this state while flushing queries. Use call_deferred() or set_deferred() to change monitoring state instead.");
|
||||
|
||||
RID PhysicsServer3DSW::plane_shape_create() {
|
||||
Shape3DSW *shape = memnew(PlaneShape3DSW);
|
||||
RID PhysicsServer3DSW::world_boundary_shape_create() {
|
||||
Shape3DSW *shape = memnew(WorldBoundaryShape3DSW);
|
||||
RID rid = shape_owner.make_rid(shape);
|
||||
shape->set_self(rid);
|
||||
return rid;
|
||||
|
|
|
@ -79,7 +79,7 @@ public:
|
|||
|
||||
static void _shape_col_cbk(const Vector3 &p_point_A, int p_index_A, const Vector3 &p_point_B, int p_index_B, void *p_userdata);
|
||||
|
||||
virtual RID plane_shape_create() override;
|
||||
virtual RID world_boundary_shape_create() override;
|
||||
virtual RID separation_ray_shape_create() override;
|
||||
virtual RID sphere_shape_create() override;
|
||||
virtual RID box_shape_create() override;
|
||||
|
|
|
@ -78,7 +78,7 @@ public:
|
|||
#include "servers/server_wrap_mt_common.h"
|
||||
|
||||
//FUNC1RID(shape,ShapeType); todo fix
|
||||
FUNCRID(plane_shape)
|
||||
FUNCRID(world_boundary_shape)
|
||||
FUNCRID(separation_ray_shape)
|
||||
FUNCRID(sphere_shape)
|
||||
FUNCRID(box_shape)
|
||||
|
|
|
@ -110,21 +110,21 @@ Shape3DSW::~Shape3DSW() {
|
|||
ERR_FAIL_COND(owners.size());
|
||||
}
|
||||
|
||||
Plane PlaneShape3DSW::get_plane() const {
|
||||
Plane WorldBoundaryShape3DSW::get_plane() const {
|
||||
return plane;
|
||||
}
|
||||
|
||||
void PlaneShape3DSW::project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const {
|
||||
void WorldBoundaryShape3DSW::project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const {
|
||||
// gibberish, a plane is infinity
|
||||
r_min = -1e7;
|
||||
r_max = 1e7;
|
||||
}
|
||||
|
||||
Vector3 PlaneShape3DSW::get_support(const Vector3 &p_normal) const {
|
||||
Vector3 WorldBoundaryShape3DSW::get_support(const Vector3 &p_normal) const {
|
||||
return p_normal * 1e15;
|
||||
}
|
||||
|
||||
bool PlaneShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const {
|
||||
bool WorldBoundaryShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const {
|
||||
bool inters = plane.intersects_segment(p_begin, p_end, &r_result);
|
||||
if (inters) {
|
||||
r_normal = plane.normal;
|
||||
|
@ -132,11 +132,11 @@ bool PlaneShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_
|
|||
return inters;
|
||||
}
|
||||
|
||||
bool PlaneShape3DSW::intersect_point(const Vector3 &p_point) const {
|
||||
bool WorldBoundaryShape3DSW::intersect_point(const Vector3 &p_point) const {
|
||||
return plane.distance_to(p_point) < 0;
|
||||
}
|
||||
|
||||
Vector3 PlaneShape3DSW::get_closest_point_to(const Vector3 &p_point) const {
|
||||
Vector3 WorldBoundaryShape3DSW::get_closest_point_to(const Vector3 &p_point) const {
|
||||
if (plane.is_point_over(p_point)) {
|
||||
return plane.project(p_point);
|
||||
} else {
|
||||
|
@ -144,24 +144,24 @@ Vector3 PlaneShape3DSW::get_closest_point_to(const Vector3 &p_point) const {
|
|||
}
|
||||
}
|
||||
|
||||
Vector3 PlaneShape3DSW::get_moment_of_inertia(real_t p_mass) const {
|
||||
return Vector3(); //wtf
|
||||
Vector3 WorldBoundaryShape3DSW::get_moment_of_inertia(real_t p_mass) const {
|
||||
return Vector3(); // not applicable.
|
||||
}
|
||||
|
||||
void PlaneShape3DSW::_setup(const Plane &p_plane) {
|
||||
void WorldBoundaryShape3DSW::_setup(const Plane &p_plane) {
|
||||
plane = p_plane;
|
||||
configure(AABB(Vector3(-1e4, -1e4, -1e4), Vector3(1e4 * 2, 1e4 * 2, 1e4 * 2)));
|
||||
}
|
||||
|
||||
void PlaneShape3DSW::set_data(const Variant &p_data) {
|
||||
void WorldBoundaryShape3DSW::set_data(const Variant &p_data) {
|
||||
_setup(p_data);
|
||||
}
|
||||
|
||||
Variant PlaneShape3DSW::get_data() const {
|
||||
Variant WorldBoundaryShape3DSW::get_data() const {
|
||||
return plane;
|
||||
}
|
||||
|
||||
PlaneShape3DSW::PlaneShape3DSW() {
|
||||
WorldBoundaryShape3DSW::WorldBoundaryShape3DSW() {
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -112,7 +112,7 @@ public:
|
|||
ConcaveShape3DSW() {}
|
||||
};
|
||||
|
||||
class PlaneShape3DSW : public Shape3DSW {
|
||||
class WorldBoundaryShape3DSW : public Shape3DSW {
|
||||
Plane plane;
|
||||
|
||||
void _setup(const Plane &p_plane);
|
||||
|
@ -121,7 +121,7 @@ public:
|
|||
Plane get_plane() const;
|
||||
|
||||
virtual real_t get_area() const override { return INFINITY; }
|
||||
virtual PhysicsServer3D::ShapeType get_type() const override { return PhysicsServer3D::SHAPE_PLANE; }
|
||||
virtual PhysicsServer3D::ShapeType get_type() const override { return PhysicsServer3D::SHAPE_WORLD_BOUNDARY; }
|
||||
virtual void project_range(const Vector3 &p_normal, const Transform3D &p_transform, real_t &r_min, real_t &r_max) const override;
|
||||
virtual Vector3 get_support(const Vector3 &p_normal) const override;
|
||||
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount, FeatureType &r_type) const override { r_amount = 0; }
|
||||
|
@ -134,7 +134,7 @@ public:
|
|||
virtual void set_data(const Variant &p_data) override;
|
||||
virtual Variant get_data() const override;
|
||||
|
||||
PlaneShape3DSW();
|
||||
WorldBoundaryShape3DSW();
|
||||
};
|
||||
|
||||
class SeparationRayShape3DSW : public Shape3DSW {
|
||||
|
|
|
@ -508,7 +508,7 @@ bool PhysicsServer2D::_body_test_motion(RID p_body, const Transform2D &p_from, c
|
|||
}
|
||||
|
||||
void PhysicsServer2D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("world_margin_shape_create"), &PhysicsServer2D::world_margin_shape_create);
|
||||
ClassDB::bind_method(D_METHOD("world_boundary_shape_create"), &PhysicsServer2D::world_boundary_shape_create);
|
||||
ClassDB::bind_method(D_METHOD("separation_ray_shape_create"), &PhysicsServer2D::separation_ray_shape_create);
|
||||
ClassDB::bind_method(D_METHOD("segment_shape_create"), &PhysicsServer2D::segment_shape_create);
|
||||
ClassDB::bind_method(D_METHOD("circle_shape_create"), &PhysicsServer2D::circle_shape_create);
|
||||
|
@ -672,7 +672,7 @@ void PhysicsServer2D::_bind_methods() {
|
|||
BIND_ENUM_CONSTANT(SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS);
|
||||
BIND_ENUM_CONSTANT(SPACE_PARAM_TEST_MOTION_MIN_CONTACT_DEPTH);
|
||||
|
||||
BIND_ENUM_CONSTANT(SHAPE_WORLD_MARGIN);
|
||||
BIND_ENUM_CONSTANT(SHAPE_WORLD_BOUNDARY);
|
||||
BIND_ENUM_CONSTANT(SHAPE_SEPARATION_RAY);
|
||||
BIND_ENUM_CONSTANT(SHAPE_SEGMENT);
|
||||
BIND_ENUM_CONSTANT(SHAPE_CIRCLE);
|
||||
|
|
|
@ -218,7 +218,7 @@ public:
|
|||
static PhysicsServer2D *get_singleton();
|
||||
|
||||
enum ShapeType {
|
||||
SHAPE_WORLD_MARGIN, ///< plane:"plane"
|
||||
SHAPE_WORLD_BOUNDARY, ///< plane:"plane"
|
||||
SHAPE_SEPARATION_RAY, ///< float:"length"
|
||||
SHAPE_SEGMENT, ///< float:"length"
|
||||
SHAPE_CIRCLE, ///< float:"radius"
|
||||
|
@ -229,7 +229,7 @@ public:
|
|||
SHAPE_CUSTOM, ///< Server-Implementation based custom shape, calling shape_create() with this value will result in an error
|
||||
};
|
||||
|
||||
virtual RID world_margin_shape_create() = 0;
|
||||
virtual RID world_boundary_shape_create() = 0;
|
||||
virtual RID separation_ray_shape_create() = 0;
|
||||
virtual RID segment_shape_create() = 0;
|
||||
virtual RID circle_shape_create() = 0;
|
||||
|
|
|
@ -454,8 +454,8 @@ bool PhysicsServer3D::_body_test_motion(RID p_body, const Transform3D &p_from, c
|
|||
|
||||
RID PhysicsServer3D::shape_create(ShapeType p_shape) {
|
||||
switch (p_shape) {
|
||||
case SHAPE_PLANE:
|
||||
return plane_shape_create();
|
||||
case SHAPE_WORLD_BOUNDARY:
|
||||
return world_boundary_shape_create();
|
||||
case SHAPE_SEPARATION_RAY:
|
||||
return separation_ray_shape_create();
|
||||
case SHAPE_SPHERE:
|
||||
|
@ -482,7 +482,7 @@ RID PhysicsServer3D::shape_create(ShapeType p_shape) {
|
|||
void PhysicsServer3D::_bind_methods() {
|
||||
#ifndef _3D_DISABLED
|
||||
|
||||
ClassDB::bind_method(D_METHOD("plane_shape_create"), &PhysicsServer3D::plane_shape_create);
|
||||
ClassDB::bind_method(D_METHOD("world_boundary_shape_create"), &PhysicsServer3D::world_boundary_shape_create);
|
||||
ClassDB::bind_method(D_METHOD("separation_ray_shape_create"), &PhysicsServer3D::separation_ray_shape_create);
|
||||
ClassDB::bind_method(D_METHOD("sphere_shape_create"), &PhysicsServer3D::sphere_shape_create);
|
||||
ClassDB::bind_method(D_METHOD("box_shape_create"), &PhysicsServer3D::box_shape_create);
|
||||
|
@ -745,7 +745,7 @@ void PhysicsServer3D::_bind_methods() {
|
|||
|
||||
ClassDB::bind_method(D_METHOD("get_process_info", "process_info"), &PhysicsServer3D::get_process_info);
|
||||
|
||||
BIND_ENUM_CONSTANT(SHAPE_PLANE);
|
||||
BIND_ENUM_CONSTANT(SHAPE_WORLD_BOUNDARY);
|
||||
BIND_ENUM_CONSTANT(SHAPE_SEPARATION_RAY);
|
||||
BIND_ENUM_CONSTANT(SHAPE_SPHERE);
|
||||
BIND_ENUM_CONSTANT(SHAPE_BOX);
|
||||
|
|
|
@ -219,7 +219,7 @@ public:
|
|||
static PhysicsServer3D *get_singleton();
|
||||
|
||||
enum ShapeType {
|
||||
SHAPE_PLANE, ///< plane:"plane"
|
||||
SHAPE_WORLD_BOUNDARY, ///< plane:"plane"
|
||||
SHAPE_SEPARATION_RAY, ///< float:"length"
|
||||
SHAPE_SPHERE, ///< float:"radius"
|
||||
SHAPE_BOX, ///< vec3:"extents"
|
||||
|
@ -234,7 +234,7 @@ public:
|
|||
|
||||
RID shape_create(ShapeType p_shape);
|
||||
|
||||
virtual RID plane_shape_create() = 0;
|
||||
virtual RID world_boundary_shape_create() = 0;
|
||||
virtual RID separation_ray_shape_create() = 0;
|
||||
virtual RID sphere_shape_create() = 0;
|
||||
virtual RID box_shape_create() = 0;
|
||||
|
|
|
@ -248,20 +248,20 @@ protected:
|
|||
return body;
|
||||
}
|
||||
|
||||
void _add_plane(const Vector2 &p_normal, real_t p_d) {
|
||||
void _add_world_boundary(const Vector2 &p_normal, real_t p_d) {
|
||||
PhysicsServer2D *ps = PhysicsServer2D::get_singleton();
|
||||
|
||||
Array arr;
|
||||
arr.push_back(p_normal);
|
||||
arr.push_back(p_d);
|
||||
|
||||
RID plane = ps->world_margin_shape_create();
|
||||
ps->shape_set_data(plane, arr);
|
||||
RID world_boundary = ps->world_boundary_shape_create();
|
||||
ps->shape_set_data(world_boundary, arr);
|
||||
|
||||
RID plane_body = ps->body_create();
|
||||
ps->body_set_mode(plane_body, PhysicsServer2D::BODY_MODE_STATIC);
|
||||
ps->body_set_space(plane_body, space);
|
||||
ps->body_add_shape(plane_body, plane);
|
||||
ps->body_add_shape(plane_body, world_boundary);
|
||||
}
|
||||
|
||||
void _add_concave(const Vector<Vector2> &p_points, const Transform2D &p_xform = Transform2D()) {
|
||||
|
@ -381,9 +381,9 @@ public:
|
|||
}
|
||||
|
||||
_add_concave(parr);
|
||||
//_add_plane(Vector2(0.0,-1).normalized(),-300);
|
||||
//_add_plane(Vector2(1,0).normalized(),50);
|
||||
//_add_plane(Vector2(-1,0).normalized(),-600);
|
||||
//_add_world_boundary(Vector2(0.0,-1).normalized(),-300);
|
||||
//_add_world_boundary(Vector2(1,0).normalized(),50);
|
||||
//_add_world_boundary(Vector2(-1,0).normalized(),-600);
|
||||
}
|
||||
|
||||
virtual bool process(double p_time) override {
|
||||
|
|
|
@ -100,18 +100,17 @@ protected:
|
|||
return body;
|
||||
}
|
||||
|
||||
RID create_static_plane(const Plane &p_plane) {
|
||||
RID create_world_boundary(const Plane &p_plane) {
|
||||
PhysicsServer3D *ps = PhysicsServer3D::get_singleton();
|
||||
|
||||
RID world_margin_shape = ps->shape_create(PhysicsServer3D::SHAPE_PLANE);
|
||||
ps->shape_set_data(world_margin_shape, p_plane);
|
||||
RID world_boundary_shape = ps->shape_create(PhysicsServer3D::SHAPE_WORLD_BOUNDARY);
|
||||
ps->shape_set_data(world_boundary_shape, p_plane);
|
||||
|
||||
RID b = ps->body_create();
|
||||
ps->body_set_mode(b, PhysicsServer3D::BODY_MODE_STATIC);
|
||||
|
||||
ps->body_set_space(b, space);
|
||||
//todo set space
|
||||
ps->body_add_shape(b, world_margin_shape);
|
||||
ps->body_add_shape(b, world_boundary_shape);
|
||||
return b;
|
||||
}
|
||||
|
||||
|
@ -391,12 +390,12 @@ public:
|
|||
create_body(type, PhysicsServer3D::BODY_MODE_DYNAMIC, t);
|
||||
}
|
||||
|
||||
create_static_plane(Plane(Vector3(0, 1, 0), -1));
|
||||
create_world_boundary(Plane(Vector3(0, 1, 0), -1));
|
||||
}
|
||||
|
||||
void test_activate() {
|
||||
create_body(PhysicsServer3D::SHAPE_BOX, PhysicsServer3D::BODY_MODE_DYNAMIC, Transform3D(Basis(), Vector3(0, 2, 0)), true);
|
||||
create_static_plane(Plane(Vector3(0, 1, 0), -1));
|
||||
create_world_boundary(Plane(Vector3(0, 1, 0), -1));
|
||||
}
|
||||
|
||||
virtual bool process(double p_time) override {
|
||||
|
|
Loading…
Reference in New Issue