Merge pull request #1362 from not-surt/tile_map_body_mode

Added body mode property for TileMap as kinematic body
This commit is contained in:
Juan Linietsky 2015-02-14 19:25:35 -03:00
commit 7ebb224ec1
7 changed files with 280 additions and 161 deletions

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 9.8 KiB

View file

@ -1,134 +1,191 @@
<?xml version="1.0" encoding="UTF-8" ?>
<resource_file type="TileSet" subresource_count="12" version="0.99" version_name="Godot Engine v0.99.3037-pre-beta">
<resource_file type="TileSet" subresource_count="14" version="1.0" version_name="Godot Engine v1.0.stable.custom_build">
<ext_resource path="res://tiles_demo.png" type="Texture"></ext_resource>
<resource type="ConvexPolygonShape2D" path="local://0">
<string name="resource/name"> "" </string>
<real name="custom_solver_bias"> 0 </real>
<vector2_array name="points" len="4"> 0, 8, 64, 8, 64, 64, 0, 64 </vector2_array>
<resource name="script/script"></resource>
</resource>
<resource type="ConvexPolygonShape2D" path="local://1">
<string name="resource/name"> "" </string>
<real name="custom_solver_bias"> 0 </real>
<vector2_array name="points" len="4"> 0, 64, 0, 8, 56, 8, 56, 64 </vector2_array>
<resource name="script/script"></resource>
<vector2_array name="points" len="4"> -32, -24, 32, -24, 32, 32, -32, 32 </vector2_array>
</resource>
<resource type="ConvexPolygonShape2D" path="local://2">
<string name="resource/name"> "" </string>
<real name="custom_solver_bias"> 0 </real>
<vector2_array name="points" len="4"> 0, 64, 0, 0, 56, 0, 56, 64 </vector2_array>
<resource name="script/script"></resource>
<vector2_array name="points" len="4"> -32, 32, -32, -24, 24, -24, 24, 32 </vector2_array>
</resource>
<resource type="ConvexPolygonShape2D" path="local://3">
<string name="resource/name"> "" </string>
<real name="custom_solver_bias"> 0 </real>
<vector2_array name="points" len="4"> 0, 64, 0, 0, 56, 0, 56, 64 </vector2_array>
<resource name="script/script"></resource>
<vector2_array name="points" len="4"> -32, 32, -32, -32, 24, -32, 24, 32 </vector2_array>
</resource>
<resource type="ConvexPolygonShape2D" path="local://4">
<string name="resource/name"> "" </string>
<real name="custom_solver_bias"> 0 </real>
<vector2_array name="points" len="5"> 0, 64, 0, 0, 56, 0, 64, 8, 64, 64 </vector2_array>
<resource name="script/script"></resource>
<vector2_array name="points" len="4"> -64, 32, -64, -32, -8, -32, -8, 32 </vector2_array>
</resource>
<resource type="ConvexPolygonShape2D" path="local://5">
<string name="resource/name"> "" </string>
<real name="custom_solver_bias"> 0 </real>
<vector2_array name="points" len="4"> 0, 64, 0, 8, 64, 8, 64, 64 </vector2_array>
<resource name="script/script"></resource>
<vector2_array name="points" len="5"> -32, 32, -32, -32, 24, -32, 32, -24, 32, 32 </vector2_array>
</resource>
<resource type="ConvexPolygonShape2D" path="local://6">
<string name="resource/name"> "" </string>
<real name="custom_solver_bias"> 0 </real>
<vector2_array name="points" len="4"> 0, 64, 0, 8, 64, 8, 64, 64 </vector2_array>
<resource name="script/script"></resource>
<vector2_array name="points" len="4"> -32, 32, -32, -24, 32, -24, 32, 32 </vector2_array>
</resource>
<resource type="ConvexPolygonShape2D" path="local://7">
<string name="resource/name"> "" </string>
<real name="custom_solver_bias"> 0 </real>
<vector2_array name="points" len="4"> 0, 0, 64, 0, 64, 64, 0, 64 </vector2_array>
<resource name="script/script"></resource>
<vector2_array name="points" len="4"> -32, 32, -32, -24, 32, -24, 32, 32 </vector2_array>
</resource>
<resource type="ConvexPolygonShape2D" path="local://8">
<string name="resource/name"> "" </string>
<real name="custom_solver_bias"> 0 </real>
<vector2_array name="points" len="4"> 0, 8, 64, 72, 64, 128, 0, 128 </vector2_array>
<resource name="script/script"></resource>
<vector2_array name="points" len="4"> -32, -32, 32, -32, 32, 32, -32, 32 </vector2_array>
</resource>
<resource type="ConvexPolygonShape2D" path="local://9">
<string name="resource/name"> "" </string>
<real name="custom_solver_bias"> 0 </real>
<vector2_array name="points" len="4"> 0, 64, 0, 0, 56, 0, 56, 64 </vector2_array>
<resource name="script/script"></resource>
<vector2_array name="points" len="4"> -32, -56, 32, 8, 32, 64, -32, 64 </vector2_array>
</resource>
<resource type="ConvexPolygonShape2D" path="local://10">
<real name="custom_solver_bias"> 0 </real>
<vector2_array name="points" len="4"> -32, 32, -32, -32, 24, -32, 24, 32 </vector2_array>
</resource>
<resource type="ConvexPolygonShape2D" path="local://11">
<real name="custom_solver_bias"> 0 </real>
<vector2_array name="points" len="4"> -32, -24, 32, -24, 32, 24, -32, 24 </vector2_array>
</resource>
<resource type="ConvexPolygonShape2D" path="local://12">
<real name="custom_solver_bias"> 0 </real>
<vector2_array name="points" len="4"> -32, -24, 24, -24, 24, 24, -32, 24 </vector2_array>
</resource>
<main_resource>
<string name="resource/name"> "" </string>
<string name="0/name"> "floor" </string>
<resource name="0/texture" resource_type="Texture" path="res://tiles_demo.png"> </resource>
<vector2 name="0/offset"> 0, 0 </vector2>
<vector2 name="0/tex_offset"> 0, 0 </vector2>
<vector2 name="0/shape_offset"> 32, 32 </vector2>
<rect2 name="0/region"> 0, 0, 64, 64 </rect2>
<resource name="0/shape" resource_type="ConvexPolygonShape2D" path="local://0"> </resource>
<array name="0/shapes" len="1" shared="false">
<resource resource_type="Shape2D" path="local://1"> </resource>
</array>
<string name="1/name"> "edge" </string>
<resource name="1/texture" resource_type="Texture" path="res://tiles_demo.png"> </resource>
<vector2 name="1/offset"> 0, 0 </vector2>
<vector2 name="1/tex_offset"> 0, 0 </vector2>
<vector2 name="1/shape_offset"> 32, 32 </vector2>
<rect2 name="1/region"> 64, 0, 64, 64 </rect2>
<resource name="1/shape" resource_type="ConvexPolygonShape2D" path="local://1"> </resource>
<array name="1/shapes" len="1" shared="false">
<resource resource_type="Shape2D" path="local://2"> </resource>
</array>
<string name="2/name"> "wall" </string>
<resource name="2/texture" resource_type="Texture" path="res://tiles_demo.png"> </resource>
<vector2 name="2/offset"> 0, 0 </vector2>
<vector2 name="2/tex_offset"> 0, 0 </vector2>
<vector2 name="2/shape_offset"> 32, 32 </vector2>
<rect2 name="2/region"> 64, 64, 64, 64 </rect2>
<resource name="2/shape" resource_type="ConvexPolygonShape2D" path="local://2"> </resource>
<array name="2/shapes" len="1" shared="false">
<resource resource_type="Shape2D" path="local://3"> </resource>
</array>
<string name="3/name"> "wall_deco" </string>
<resource name="3/texture" resource_type="Texture" path="res://tiles_demo.png"> </resource>
<vector2 name="3/offset"> 0, 0 </vector2>
<vector2 name="3/tex_offset"> 0, 0 </vector2>
<vector2 name="3/shape_offset"> 64, 32 </vector2>
<rect2 name="3/region"> 320, 128, 128, 64 </rect2>
<resource name="3/shape" resource_type="ConvexPolygonShape2D" path="local://3"> </resource>
<array name="3/shapes" len="1" shared="false">
<resource resource_type="Shape2D" path="local://4"> </resource>
</array>
<string name="4/name"> "corner" </string>
<resource name="4/texture" resource_type="Texture" path="res://tiles_demo.png"> </resource>
<vector2 name="4/offset"> 0, 0 </vector2>
<vector2 name="4/tex_offset"> 0, 0 </vector2>
<vector2 name="4/shape_offset"> 32, 32 </vector2>
<rect2 name="4/region"> 64, 128, 64, 64 </rect2>
<resource name="4/shape" resource_type="ConvexPolygonShape2D" path="local://4"> </resource>
<array name="4/shapes" len="1" shared="false">
<resource resource_type="Shape2D" path="local://5"> </resource>
</array>
<string name="5/name"> "flowers" </string>
<resource name="5/texture" resource_type="Texture" path="res://tiles_demo.png"> </resource>
<vector2 name="5/offset"> 0, 0 </vector2>
<vector2 name="5/tex_offset"> 0, 0 </vector2>
<vector2 name="5/shape_offset"> 32, 32 </vector2>
<rect2 name="5/region"> 192, 192, 64, 64 </rect2>
<resource name="5/shape" resource_type="ConvexPolygonShape2D" path="local://5"> </resource>
<array name="5/shapes" len="1" shared="false">
<resource resource_type="Shape2D" path="local://6"> </resource>
</array>
<string name="6/name"> "tree_base" </string>
<resource name="6/texture" resource_type="Texture" path="res://tiles_demo.png"> </resource>
<vector2 name="6/offset"> 0, 0 </vector2>
<vector2 name="6/tex_offset"> 0, 0 </vector2>
<vector2 name="6/shape_offset"> 32, 32 </vector2>
<rect2 name="6/region"> 256, 192, 64, 64 </rect2>
<resource name="6/shape" resource_type="ConvexPolygonShape2D" path="local://6"> </resource>
<array name="6/shapes" len="1" shared="false">
<resource resource_type="Shape2D" path="local://7"> </resource>
</array>
<string name="7/name"> "tree_mid" </string>
<resource name="7/texture" resource_type="Texture" path="res://tiles_demo.png"> </resource>
<vector2 name="7/offset"> 0, 0 </vector2>
<vector2 name="7/tex_offset"> 0, 0 </vector2>
<vector2 name="7/shape_offset"> 0, 0 </vector2>
<rect2 name="7/region"> 256, 128, 64, 64 </rect2>
<resource name="7/shape"></resource> <string name="8/name"> "tree_mid 2" </string>
<array name="7/shapes" len="0" shared="false">
</array>
<string name="8/name"> "tree_mid 2" </string>
<resource name="8/texture" resource_type="Texture" path="res://tiles_demo.png"> </resource>
<vector2 name="8/offset"> 0, 0 </vector2>
<vector2 name="8/tex_offset"> 0, 0 </vector2>
<vector2 name="8/shape_offset"> 0, 0 </vector2>
<rect2 name="8/region"> 256, 64, 64, 64 </rect2>
<resource name="8/shape"></resource> <string name="9/name"> "tree_top" </string>
<array name="8/shapes" len="0" shared="false">
</array>
<string name="9/name"> "tree_top" </string>
<resource name="9/texture" resource_type="Texture" path="res://tiles_demo.png"> </resource>
<vector2 name="9/offset"> 0, 0 </vector2>
<vector2 name="9/tex_offset"> 0, 0 </vector2>
<vector2 name="9/shape_offset"> 0, 0 </vector2>
<rect2 name="9/region"> 256, 0, 64, 64 </rect2>
<resource name="9/shape"></resource> <string name="10/name"> "solid" </string>
<array name="9/shapes" len="0" shared="false">
</array>
<string name="10/name"> "solid" </string>
<resource name="10/texture" resource_type="Texture" path="res://tiles_demo.png"> </resource>
<vector2 name="10/offset"> 0, 0 </vector2>
<vector2 name="10/tex_offset"> 0, 0 </vector2>
<vector2 name="10/shape_offset"> 0, 0 </vector2>
<rect2 name="10/region"> 0, 64, 64, 64 </rect2>
<resource name="10/shape"></resource> <string name="11/name"> "ceiling" </string>
<array name="10/shapes" len="0" shared="false">
</array>
<string name="11/name"> "ceiling" </string>
<resource name="11/texture" resource_type="Texture" path="res://tiles_demo.png"> </resource>
<vector2 name="11/offset"> 0, 0 </vector2>
<vector2 name="11/tex_offset"> 0, 0 </vector2>
<vector2 name="11/shape_offset"> 32, 32 </vector2>
<rect2 name="11/region"> 384, 64, 64, 64 </rect2>
<resource name="11/shape" resource_type="ConvexPolygonShape2D" path="local://7"> </resource>
<array name="11/shapes" len="1" shared="false">
<resource resource_type="Shape2D" path="local://8"> </resource>
</array>
<string name="12/name"> "ramp" </string>
<resource name="12/texture" resource_type="Texture" path="res://tiles_demo.png"> </resource>
<vector2 name="12/offset"> 0, 0 </vector2>
<vector2 name="12/tex_offset"> 0, 0 </vector2>
<vector2 name="12/shape_offset"> 32, 64 </vector2>
<rect2 name="12/region"> 128, 128, 64, 128 </rect2>
<resource name="12/shape" resource_type="ConvexPolygonShape2D" path="local://8"> </resource>
<array name="12/shapes" len="1" shared="false">
<resource resource_type="Shape2D" path="local://9"> </resource>
</array>
<string name="13/name"> "ceiling2wall" </string>
<resource name="13/texture" resource_type="Texture" path="res://tiles_demo.png"> </resource>
<vector2 name="13/offset"> 0, 0 </vector2>
<vector2 name="13/tex_offset"> 0, 0 </vector2>
<vector2 name="13/shape_offset"> 32, 32 </vector2>
<rect2 name="13/region"> 448, 64, 64, 64 </rect2>
<resource name="13/shape" resource_type="ConvexPolygonShape2D" path="local://9"> </resource>
<resource name="script/script"></resource>
<array name="13/shapes" len="1" shared="false">
<resource resource_type="Shape2D" path="local://10"> </resource>
</array>
<string name="14/name"> "platform_floor" </string>
<resource name="14/texture" resource_type="Texture" path="res://tiles_demo.png"> </resource>
<vector2 name="14/tex_offset"> 0, 0 </vector2>
<vector2 name="14/shape_offset"> 32, 32 </vector2>
<rect2 name="14/region"> 128, 0, 64, 64 </rect2>
<array name="14/shapes" len="1" shared="false">
<resource resource_type="Shape2D" path="local://11"> </resource>
</array>
<string name="15/name"> "platform_edge" </string>
<resource name="15/texture" resource_type="Texture" path="res://tiles_demo.png"> </resource>
<vector2 name="15/tex_offset"> 0, 0 </vector2>
<vector2 name="15/shape_offset"> 32, 32 </vector2>
<rect2 name="15/region"> 192, 0, 64, 64 </rect2>
<array name="15/shapes" len="1" shared="false">
<resource resource_type="Shape2D" path="local://12"> </resource>
</array>
</main_resource>
</resource_file>

File diff suppressed because one or more lines are too long

View file

@ -29,6 +29,7 @@
#include "tile_map.h"
#include "io/marshalls.h"
#include "servers/physics_2d_server.h"
void TileMap::_notification(int p_what) {
switch(p_what) {
@ -62,7 +63,7 @@ void TileMap::_update_quadrant_space(const RID& p_space) {
for (Map<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) {
Quadrant &q=E->get();
Physics2DServer::get_singleton()->body_set_space(q.static_body,p_space);
Physics2DServer::get_singleton()->body_set_space(q.body,p_space);
}
}
@ -79,7 +80,7 @@ void TileMap::_update_quadrant_transform() {
Matrix32 xform;
xform.set_origin( q.pos );
xform = global_transform * xform;
Physics2DServer::get_singleton()->body_set_state(q.static_body,Physics2DServer::BODY_STATE_TRANSFORM,xform);
Physics2DServer::get_singleton()->body_set_state(q.body,Physics2DServer::BODY_STATE_TRANSFORM,xform);
}
}
@ -178,7 +179,7 @@ void TileMap::_update_dirty_quadrants() {
Quadrant &q = *dirty_quadrant_list.first()->self();
vs->canvas_item_clear(q.canvas_item);
ps->body_clear_shapes(q.static_body);
ps->body_clear_shapes(q.body);
int shape_idx=0;
for(int i=0;i<q.cells.size();i++) {
@ -259,8 +260,8 @@ void TileMap::_update_dirty_quadrants() {
}
ps->body_add_shape(q.static_body,shape->get_rid(),xform);
ps->body_set_shape_metadata(q.static_body,shape_idx++,Vector2(E->key().x,E->key().y));
ps->body_add_shape(q.body,shape->get_rid(),xform);
ps->body_set_shape_metadata(q.body,shape_idx++,Vector2(E->key().x,E->key().y));
}
}
@ -339,19 +340,19 @@ Map<TileMap::PosKey,TileMap::Quadrant>::Element *TileMap::_create_quadrant(const
q.canvas_item = VisualServer::get_singleton()->canvas_item_create();
VisualServer::get_singleton()->canvas_item_set_parent( q.canvas_item, get_canvas_item() );
VisualServer::get_singleton()->canvas_item_set_transform( q.canvas_item, xform );
q.static_body=Physics2DServer::get_singleton()->body_create(Physics2DServer::BODY_MODE_STATIC);
Physics2DServer::get_singleton()->body_attach_object_instance_ID(q.static_body,get_instance_ID());
Physics2DServer::get_singleton()->body_set_layer_mask(q.static_body,collision_layer);
Physics2DServer::get_singleton()->body_set_param(q.static_body,Physics2DServer::BODY_PARAM_FRICTION,friction);
Physics2DServer::get_singleton()->body_set_param(q.static_body,Physics2DServer::BODY_PARAM_BOUNCE,bounce);
q.body=Physics2DServer::get_singleton()->body_create(use_kinematic?Physics2DServer::BODY_MODE_KINEMATIC:Physics2DServer::BODY_MODE_STATIC);
Physics2DServer::get_singleton()->body_attach_object_instance_ID(q.body,get_instance_ID());
Physics2DServer::get_singleton()->body_set_layer_mask(q.body,collision_layer);
Physics2DServer::get_singleton()->body_set_param(q.body,Physics2DServer::BODY_PARAM_FRICTION,friction);
Physics2DServer::get_singleton()->body_set_param(q.body,Physics2DServer::BODY_PARAM_BOUNCE,bounce);
if (is_inside_tree()) {
xform = get_global_transform() * xform;
RID space = get_world_2d()->get_space();
Physics2DServer::get_singleton()->body_set_space(q.static_body,space);
Physics2DServer::get_singleton()->body_set_space(q.body,space);
}
Physics2DServer::get_singleton()->body_set_state(q.static_body,Physics2DServer::BODY_STATE_TRANSFORM,xform);
Physics2DServer::get_singleton()->body_set_state(q.body,Physics2DServer::BODY_STATE_TRANSFORM,xform);
rect_cache_dirty=true;
quadrant_order_dirty=true;
@ -361,7 +362,7 @@ Map<TileMap::PosKey,TileMap::Quadrant>::Element *TileMap::_create_quadrant(const
void TileMap::_erase_quadrant(Map<PosKey,Quadrant>::Element *Q) {
Quadrant &q=Q->get();
Physics2DServer::get_singleton()->free(q.static_body);
Physics2DServer::get_singleton()->free(q.body);
VisualServer::get_singleton()->free(q.canvas_item);
if (q.dirty_list.in_list())
dirty_quadrant_list.remove(&q.dirty_list);
@ -586,17 +587,29 @@ void TileMap::set_collision_layer_mask(uint32_t p_layer) {
for (Map<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) {
Quadrant &q=E->get();
Physics2DServer::get_singleton()->body_set_layer_mask(q.static_body,collision_layer);
Physics2DServer::get_singleton()->body_set_layer_mask(q.body,collision_layer);
}
}
bool TileMap::get_collision_use_kinematic() const{
return use_kinematic;
}
void TileMap::set_collision_use_kinematic(bool p_use_kinematic) {
_clear_quadrants();
use_kinematic=p_use_kinematic;
_recreate_quadrants();
}
void TileMap::set_collision_friction(float p_friction) {
friction=p_friction;
for (Map<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) {
Quadrant &q=E->get();
Physics2DServer::get_singleton()->body_set_param(q.static_body,Physics2DServer::BODY_PARAM_FRICTION,p_friction);
Physics2DServer::get_singleton()->body_set_param(q.body,Physics2DServer::BODY_PARAM_FRICTION,p_friction);
}
}
@ -612,7 +625,7 @@ void TileMap::set_collision_bounce(float p_bounce){
for (Map<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) {
Quadrant &q=E->get();
Physics2DServer::get_singleton()->body_set_param(q.static_body,Physics2DServer::BODY_PARAM_BOUNCE,p_bounce);
Physics2DServer::get_singleton()->body_set_param(q.body,Physics2DServer::BODY_PARAM_BOUNCE,p_bounce);
}
}
@ -804,6 +817,9 @@ void TileMap::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_center_y","enable"),&TileMap::set_center_y);
ObjectTypeDB::bind_method(_MD("get_center_y"),&TileMap::get_center_y);
ObjectTypeDB::bind_method(_MD("set_collision_use_kinematic","use_kinematic"),&TileMap::set_collision_use_kinematic);
ObjectTypeDB::bind_method(_MD("get_collision_use_kinematic"),&TileMap::get_collision_use_kinematic);
ObjectTypeDB::bind_method(_MD("set_collision_layer_mask","mask"),&TileMap::set_collision_layer_mask);
ObjectTypeDB::bind_method(_MD("get_collision_layer_mask"),&TileMap::get_collision_layer_mask);
@ -837,6 +853,7 @@ void TileMap::_bind_methods() {
ADD_PROPERTY( PropertyInfo(Variant::INT,"cell/quadrant_size",PROPERTY_HINT_RANGE,"1,128,1"),_SCS("set_quadrant_size"),_SCS("get_quadrant_size"));
ADD_PROPERTY( PropertyInfo(Variant::MATRIX32,"cell/custom_transform"),_SCS("set_custom_transform"),_SCS("get_custom_transform"));
ADD_PROPERTY( PropertyInfo(Variant::INT,"cell/half_offset",PROPERTY_HINT_ENUM,"Offset X,Offset Y,Disabled"),_SCS("set_half_offset"),_SCS("get_half_offset"));
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"collision/use_kinematic",PROPERTY_HINT_NONE,""),_SCS("set_collision_use_kinematic"),_SCS("get_collision_use_kinematic"));
ADD_PROPERTY( PropertyInfo(Variant::REAL,"collision/friction",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_collision_friction"),_SCS("get_collision_friction"));
ADD_PROPERTY( PropertyInfo(Variant::REAL,"collision/bounce",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_collision_bounce"),_SCS("get_collision_bounce"));
ADD_PROPERTY( PropertyInfo(Variant::INT,"collision/layers",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_layer_mask"),_SCS("get_collision_layer_mask"));
@ -870,6 +887,7 @@ TileMap::TileMap() {
bounce=0;
mode=MODE_SQUARE;
half_offset=HALF_OFFSET_DISABLED;
use_kinematic=false;
fp_adjust=0.01;
fp_adjust=0.01;

View file

@ -60,6 +60,7 @@ private:
Mode mode;
Matrix32 custom_transform;
HalfOffset half_offset;
bool use_kinematic;
union PosKey {
@ -97,14 +98,14 @@ private:
Vector2 pos;
RID canvas_item;
RID static_body;
RID body;
SelfList<Quadrant> dirty_list;
VSet<PosKey> cells;
void operator=(const Quadrant& q) { pos=q.pos; canvas_item=q.canvas_item; static_body=q.static_body; cells=q.cells; }
Quadrant(const Quadrant& q) : dirty_list(this) { pos=q.pos; canvas_item=q.canvas_item; static_body=q.static_body; cells=q.cells;}
void operator=(const Quadrant& q) { pos=q.pos; canvas_item=q.canvas_item; body=q.body; cells=q.cells; }
Quadrant(const Quadrant& q) : dirty_list(this) { pos=q.pos; canvas_item=q.canvas_item; body=q.body; cells=q.cells;}
Quadrant() : dirty_list(this) {}
};
@ -177,6 +178,9 @@ public:
void set_collision_layer_mask(uint32_t p_layer);
uint32_t get_collision_layer_mask() const;
void set_collision_use_kinematic(bool p_use_kinematic);
bool get_collision_use_kinematic() const;
void set_collision_friction(float p_friction);
float get_collision_friction() const;

View file

@ -31,6 +31,8 @@
#include "os/file_access.h"
#include "tools/editor/editor_settings.h"
#include "scene/3d/camera.h"
#include "canvas_item_editor_plugin.h"
void CollisionPolygonEditor::_notification(int p_what) {
switch(p_what) {
@ -71,14 +73,14 @@ void CollisionPolygonEditor::_node_removed(Node *p_node) {
Vector2 CollisionPolygonEditor::snap_point(const Vector2& p_point) const {
return p_point;
/*
if (canvas_item_editor->is_snap_active()) {
if (CanvasItemEditor::get_singleton()->is_snap_active()) {
return p_point.snapped(Vector2(1,1)*canvas_item_editor->get_snap());
return p_point.snapped(Vector2(1,1)*CanvasItemEditor::get_singleton()->get_snap());
} else {
return p_point;
} ??? */
}
}
void CollisionPolygonEditor::_menu_option(int p_option) {
@ -148,7 +150,7 @@ bool CollisionPolygonEditor::forward_spatial_input_event(Camera* p_camera,const
Vector2 cpoint(spoint.x,spoint.y);
//cpoint=snap_point(cpoint); snap?
cpoint=snap_point(cpoint);
Vector<Vector2> poly = node->get_polygon();
@ -362,7 +364,7 @@ bool CollisionPolygonEditor::forward_spatial_input_event(Camera* p_camera,const
Vector2 cpoint(spoint.x,spoint.y);
//cpoint=snap_point(cpoint);
cpoint=snap_point(cpoint);
edited_point_pos = cpoint;
_polygon_draw();