Renamed PlaneShape to WorldMarginShape

This commit is contained in:
Andrea Catania 2020-02-21 12:19:24 +01:00
parent 3b64ecbc4b
commit 2e0fb66c6f
12 changed files with 37 additions and 41 deletions

View file

@ -1467,7 +1467,7 @@
If [code]set[/code] there is a linear motor on this axis that targets a specific velocity. If [code]set[/code] there is a linear motor on this axis that targets a specific velocity.
</constant> </constant>
<constant name="SHAPE_PLANE" value="0" enum="ShapeType"> <constant name="SHAPE_PLANE" value="0" enum="ShapeType">
The [Shape] is a [PlaneShape]. The [Shape] is a [WorldMarginShape].
</constant> </constant>
<constant name="SHAPE_RAY" value="1" enum="ShapeType"> <constant name="SHAPE_RAY" value="1" enum="ShapeType">
The [Shape] is a [RayShape]. The [Shape] is a [RayShape].

View file

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="PlaneShape" inherits="Shape" version="4.0"> <class name="WorldMarginShape" inherits="Shape" version="4.0">
<brief_description> <brief_description>
Infinite plane shape for 3D collisions. Infinite plane shape for 3D collisions.
</brief_description> </brief_description>
<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 [PlaneShape] is used in a [PhysicsBody], it will cause colliding objects placed "below" it to teleport "above" the plane. An infinite plane shape for 3D collisions. Note that the [Plane]'s normal matters; anything "below" the plane will collide with it. If the [WorldMarginShape] is used in a [PhysicsBody], it will cause colliding objects placed "below" it to teleport "above" the plane.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@ -12,7 +12,7 @@
</methods> </methods>
<members> <members>
<member name="plane" type="Plane" setter="set_plane" getter="get_plane" default="Plane( 0, 1, 0, 0 )"> <member name="plane" type="Plane" setter="set_plane" getter="get_plane" default="Plane( 0, 1, 0, 0 )">
The [Plane] used by the [PlaneShape] for collision. The [Plane] used by the [WorldMarginShape] for collision.
</member> </member>
</members> </members>
<constants> <constants>

View file

@ -1 +0,0 @@
<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m2 12h12l-3-8h-6z" fill="none" stroke="#ffd684" stroke-linejoin="round" stroke-width="2"/></svg>

Before

Width:  |  Height:  |  Size: 188 B

View file

@ -0,0 +1 @@
<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m1 1044.4 7 3 7-3-7-3z" fill="#a2d2ff" fill-rule="evenodd" transform="translate(0 -1036.4)"/></svg>

After

Width:  |  Height:  |  Size: 191 B

View file

@ -41,10 +41,10 @@
#include "scene/resources/animation.h" #include "scene/resources/animation.h"
#include "scene/resources/box_shape.h" #include "scene/resources/box_shape.h"
#include "scene/resources/packed_scene.h" #include "scene/resources/packed_scene.h"
#include "scene/resources/plane_shape.h"
#include "scene/resources/ray_shape.h" #include "scene/resources/ray_shape.h"
#include "scene/resources/resource_format_text.h" #include "scene/resources/resource_format_text.h"
#include "scene/resources/sphere_shape.h" #include "scene/resources/sphere_shape.h"
#include "scene/resources/world_margin_shape.h"
uint32_t EditorSceneImporter::get_import_flags() const { uint32_t EditorSceneImporter::get_import_flags() const {
@ -446,9 +446,9 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
colshape->set_name("RayShape"); colshape->set_name("RayShape");
Object::cast_to<Spatial>(sb)->rotate_x(Math_PI / 2); Object::cast_to<Spatial>(sb)->rotate_x(Math_PI / 2);
} else if (empty_draw_type == "IMAGE") { } else if (empty_draw_type == "IMAGE") {
PlaneShape *planeShape = memnew(PlaneShape); WorldMarginShape *world_margin_shape = memnew(WorldMarginShape);
colshape->set_shape(planeShape); colshape->set_shape(world_margin_shape);
colshape->set_name("PlaneShape"); colshape->set_name("WorldMarginShape");
} else { } else {
SphereShape *sphereShape = memnew(SphereShape); SphereShape *sphereShape = memnew(SphereShape);
sphereShape->set_radius(1); sphereShape->set_radius(1);

View file

@ -58,11 +58,11 @@
#include "scene/resources/convex_polygon_shape.h" #include "scene/resources/convex_polygon_shape.h"
#include "scene/resources/cylinder_shape.h" #include "scene/resources/cylinder_shape.h"
#include "scene/resources/height_map_shape.h" #include "scene/resources/height_map_shape.h"
#include "scene/resources/plane_shape.h"
#include "scene/resources/primitive_meshes.h" #include "scene/resources/primitive_meshes.h"
#include "scene/resources/ray_shape.h" #include "scene/resources/ray_shape.h"
#include "scene/resources/sphere_shape.h" #include "scene/resources/sphere_shape.h"
#include "scene/resources/surface_tool.h" #include "scene/resources/surface_tool.h"
#include "scene/resources/world_margin_shape.h"
#define HANDLE_HALF_SIZE 9.5 #define HANDLE_HALF_SIZE 9.5
@ -3575,9 +3575,9 @@ void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
p_gizmo->add_handles(handles, handles_material); p_gizmo->add_handles(handles, handles_material);
} }
if (Object::cast_to<PlaneShape>(*s)) { if (Object::cast_to<WorldMarginShape>(*s)) {
Ref<PlaneShape> ps = s; Ref<WorldMarginShape> ps = s;
Plane p = ps->get_plane(); Plane p = ps->get_plane();
Vector<Vector3> points; Vector<Vector3> points;

View file

@ -110,13 +110,13 @@ protected:
PhysicsServer *ps = PhysicsServer::get_singleton(); PhysicsServer *ps = PhysicsServer::get_singleton();
RID plane_shape = ps->shape_create(PhysicsServer::SHAPE_PLANE); RID world_margin_shape = ps->shape_create(PhysicsServer::SHAPE_PLANE);
ps->shape_set_data(plane_shape, p_plane); ps->shape_set_data(world_margin_shape, p_plane);
RID b = ps->body_create(PhysicsServer::BODY_MODE_STATIC); RID b = ps->body_create(PhysicsServer::BODY_MODE_STATIC);
ps->body_set_space(b, space); ps->body_set_space(b, space);
//todo set space //todo set space
ps->body_add_shape(b, plane_shape); ps->body_add_shape(b, world_margin_shape);
return b; return b;
} }

View file

@ -42,10 +42,10 @@
#include "scene/resources/concave_polygon_shape.h" #include "scene/resources/concave_polygon_shape.h"
#include "scene/resources/convex_polygon_shape.h" #include "scene/resources/convex_polygon_shape.h"
#include "scene/resources/cylinder_shape.h" #include "scene/resources/cylinder_shape.h"
#include "scene/resources/plane_shape.h"
#include "scene/resources/primitive_meshes.h" #include "scene/resources/primitive_meshes.h"
#include "scene/resources/shape.h" #include "scene/resources/shape.h"
#include "scene/resources/sphere_shape.h" #include "scene/resources/sphere_shape.h"
#include "scene/resources/world_margin_shape.h"
#include "modules/modules_enabled.gen.h" #include "modules/modules_enabled.gen.h"
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED

View file

@ -33,9 +33,9 @@
#include "scene/resources/capsule_shape.h" #include "scene/resources/capsule_shape.h"
#include "scene/resources/concave_polygon_shape.h" #include "scene/resources/concave_polygon_shape.h"
#include "scene/resources/convex_polygon_shape.h" #include "scene/resources/convex_polygon_shape.h"
#include "scene/resources/plane_shape.h"
#include "scene/resources/ray_shape.h" #include "scene/resources/ray_shape.h"
#include "scene/resources/sphere_shape.h" #include "scene/resources/sphere_shape.h"
#include "scene/resources/world_margin_shape.h"
#include "servers/visual_server.h" #include "servers/visual_server.h"
//TODO: Implement CylinderShape and HeightMapShape? //TODO: Implement CylinderShape and HeightMapShape?
#include "core/math/quick_hull.h" #include "core/math/quick_hull.h"
@ -123,10 +123,6 @@ String CollisionShape::get_configuration_warning() const {
return TTR("A shape must be provided for CollisionShape to function. Please create a shape resource for it."); return TTR("A shape must be provided for CollisionShape to function. Please create a shape resource for it.");
} }
if (shape->is_class("PlaneShape")) {
return TTR("Plane shapes don't work well and will be removed in future versions. Please don't use them.");
}
return String(); return String();
} }

View file

@ -151,7 +151,6 @@
#include "scene/resources/packed_scene.h" #include "scene/resources/packed_scene.h"
#include "scene/resources/particles_material.h" #include "scene/resources/particles_material.h"
#include "scene/resources/physics_material.h" #include "scene/resources/physics_material.h"
#include "scene/resources/plane_shape.h"
#include "scene/resources/polygon_path_finder.h" #include "scene/resources/polygon_path_finder.h"
#include "scene/resources/primitive_meshes.h" #include "scene/resources/primitive_meshes.h"
#include "scene/resources/ray_shape.h" #include "scene/resources/ray_shape.h"
@ -169,6 +168,7 @@
#include "scene/resources/visual_shader_nodes.h" #include "scene/resources/visual_shader_nodes.h"
#include "scene/resources/world.h" #include "scene/resources/world.h"
#include "scene/resources/world_2d.h" #include "scene/resources/world_2d.h"
#include "scene/resources/world_margin_shape.h"
#include "scene/scene_string_names.h" #include "scene/scene_string_names.h"
#ifndef _3D_DISABLED #ifndef _3D_DISABLED
@ -190,8 +190,8 @@
#include "scene/3d/multimesh_instance.h" #include "scene/3d/multimesh_instance.h"
#include "scene/3d/navigation.h" #include "scene/3d/navigation.h"
#include "scene/3d/navigation_agent.h" #include "scene/3d/navigation_agent.h"
#include "scene/3d/navigation_region.h"
#include "scene/3d/navigation_obstacle.h" #include "scene/3d/navigation_obstacle.h"
#include "scene/3d/navigation_region.h"
#include "scene/3d/particles.h" #include "scene/3d/particles.h"
#include "scene/3d/path.h" #include "scene/3d/path.h"
#include "scene/3d/physics_body.h" #include "scene/3d/physics_body.h"
@ -643,7 +643,7 @@ void register_scene_types() {
ClassDB::register_class<CapsuleShape>(); ClassDB::register_class<CapsuleShape>();
ClassDB::register_class<CylinderShape>(); ClassDB::register_class<CylinderShape>();
ClassDB::register_class<HeightMapShape>(); ClassDB::register_class<HeightMapShape>();
ClassDB::register_class<PlaneShape>(); ClassDB::register_class<WorldMarginShape>();
ClassDB::register_class<ConvexPolygonShape>(); ClassDB::register_class<ConvexPolygonShape>();
ClassDB::register_class<ConcavePolygonShape>(); ClassDB::register_class<ConcavePolygonShape>();

View file

@ -1,5 +1,5 @@
/*************************************************************************/ /*************************************************************************/
/* plane_shape.cpp */ /* world_margin_shape.cpp */
/*************************************************************************/ /*************************************************************************/
/* This file is part of: */ /* This file is part of: */
/* GODOT ENGINE */ /* GODOT ENGINE */
@ -28,11 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#include "plane_shape.h" #include "world_margin_shape.h"
#include "servers/physics_server.h" #include "servers/physics_server.h"
Vector<Vector3> PlaneShape::get_debug_mesh_lines() { Vector<Vector3> WorldMarginShape::get_debug_mesh_lines() {
Plane p = get_plane(); Plane p = get_plane();
Vector<Vector3> points; Vector<Vector3> points;
@ -61,13 +61,13 @@ Vector<Vector3> PlaneShape::get_debug_mesh_lines() {
return points; return points;
} }
void PlaneShape::_update_shape() { void WorldMarginShape::_update_shape() {
PhysicsServer::get_singleton()->shape_set_data(get_shape(), plane); PhysicsServer::get_singleton()->shape_set_data(get_shape(), plane);
Shape::_update_shape(); Shape::_update_shape();
} }
void PlaneShape::set_plane(Plane p_plane) { void WorldMarginShape::set_plane(Plane p_plane) {
plane = p_plane; plane = p_plane;
_update_shape(); _update_shape();
@ -75,20 +75,20 @@ void PlaneShape::set_plane(Plane p_plane) {
_change_notify("plane"); _change_notify("plane");
} }
Plane PlaneShape::get_plane() const { Plane WorldMarginShape::get_plane() const {
return plane; return plane;
} }
void PlaneShape::_bind_methods() { void WorldMarginShape::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_plane", "plane"), &PlaneShape::set_plane); ClassDB::bind_method(D_METHOD("set_plane", "plane"), &WorldMarginShape::set_plane);
ClassDB::bind_method(D_METHOD("get_plane"), &PlaneShape::get_plane); ClassDB::bind_method(D_METHOD("get_plane"), &WorldMarginShape::get_plane);
ADD_PROPERTY(PropertyInfo(Variant::PLANE, "plane"), "set_plane", "get_plane"); ADD_PROPERTY(PropertyInfo(Variant::PLANE, "plane"), "set_plane", "get_plane");
} }
PlaneShape::PlaneShape() : WorldMarginShape::WorldMarginShape() :
Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_PLANE)) { Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_PLANE)) {
set_plane(Plane(0, 1, 0, 0)); set_plane(Plane(0, 1, 0, 0));

View file

@ -1,5 +1,5 @@
/*************************************************************************/ /*************************************************************************/
/* plane_shape.h */ /* world_margin_shape.h */
/*************************************************************************/ /*************************************************************************/
/* This file is part of: */ /* This file is part of: */
/* GODOT ENGINE */ /* GODOT ENGINE */
@ -28,14 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef PLANE_SHAPE_H #ifndef world_margin_shape_H
#define PLANE_SHAPE_H #define world_margin_shape_H
#include "scene/resources/shape.h" #include "scene/resources/shape.h"
class PlaneShape : public Shape { class WorldMarginShape : public Shape {
GDCLASS(PlaneShape, Shape); GDCLASS(WorldMarginShape, Shape);
Plane plane; Plane plane;
protected: protected:
@ -52,6 +52,6 @@ public:
return 0; return 0;
} }
PlaneShape(); WorldMarginShape();
}; };
#endif // PLANE_SHAPE_H #endif // world_margin_shape_H