parent
73f7d29c26
commit
9b149d5848
|
@ -183,6 +183,9 @@
|
||||||
<member name="mesh_library" type="MeshLibrary" setter="set_mesh_library" getter="get_mesh_library">
|
<member name="mesh_library" type="MeshLibrary" setter="set_mesh_library" getter="get_mesh_library">
|
||||||
The assigned [MeshLibrary].
|
The assigned [MeshLibrary].
|
||||||
</member>
|
</member>
|
||||||
|
<member name="physics_material" type="PhysicsMaterial" setter="set_physics_material" getter="get_physics_material">
|
||||||
|
Overrides the default friction and bounce physics properties for the whole [GridMap].
|
||||||
|
</member>
|
||||||
<member name="use_in_baked_light" type="bool" setter="set_use_in_baked_light" getter="get_use_in_baked_light" default="false">
|
<member name="use_in_baked_light" type="bool" setter="set_use_in_baked_light" getter="get_use_in_baked_light" default="false">
|
||||||
Controls whether this GridMap will be baked in a [BakedLightmap] or not.
|
Controls whether this GridMap will be baked in a [BakedLightmap] or not.
|
||||||
</member>
|
</member>
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "core/message_queue.h"
|
#include "core/message_queue.h"
|
||||||
#include "scene/3d/light.h"
|
#include "scene/3d/light.h"
|
||||||
#include "scene/resources/mesh_library.h"
|
#include "scene/resources/mesh_library.h"
|
||||||
|
#include "scene/resources/physics_material.h"
|
||||||
#include "scene/resources/surface_tool.h"
|
#include "scene/resources/surface_tool.h"
|
||||||
#include "scene/scene_string_names.h"
|
#include "scene/scene_string_names.h"
|
||||||
#include "servers/navigation_server.h"
|
#include "servers/navigation_server.h"
|
||||||
|
@ -183,6 +184,15 @@ bool GridMap::get_collision_layer_bit(int p_bit) const {
|
||||||
return get_collision_layer() & (1 << p_bit);
|
return get_collision_layer() & (1 << p_bit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GridMap::set_physics_material(Ref<PhysicsMaterial> p_material) {
|
||||||
|
physics_material = p_material;
|
||||||
|
_recreate_octant_data();
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<PhysicsMaterial> GridMap::get_physics_material() const {
|
||||||
|
return physics_material;
|
||||||
|
}
|
||||||
|
|
||||||
void GridMap::set_mesh_library(const Ref<MeshLibrary> &p_mesh_library) {
|
void GridMap::set_mesh_library(const Ref<MeshLibrary> &p_mesh_library) {
|
||||||
if (!mesh_library.is_null()) {
|
if (!mesh_library.is_null()) {
|
||||||
mesh_library->unregister_owner(this);
|
mesh_library->unregister_owner(this);
|
||||||
|
@ -300,6 +310,10 @@ void GridMap::set_cell_item(int p_x, int p_y, int p_z, int p_item, int p_rot) {
|
||||||
PhysicsServer::get_singleton()->body_attach_object_instance_id(g->static_body, get_instance_id());
|
PhysicsServer::get_singleton()->body_attach_object_instance_id(g->static_body, get_instance_id());
|
||||||
PhysicsServer::get_singleton()->body_set_collision_layer(g->static_body, collision_layer);
|
PhysicsServer::get_singleton()->body_set_collision_layer(g->static_body, collision_layer);
|
||||||
PhysicsServer::get_singleton()->body_set_collision_mask(g->static_body, collision_mask);
|
PhysicsServer::get_singleton()->body_set_collision_mask(g->static_body, collision_mask);
|
||||||
|
if (physics_material.is_valid()) {
|
||||||
|
PhysicsServer::get_singleton()->body_set_param(g->static_body, PhysicsServer::BODY_PARAM_FRICTION, physics_material->get_friction());
|
||||||
|
PhysicsServer::get_singleton()->body_set_param(g->static_body, PhysicsServer::BODY_PARAM_BOUNCE, physics_material->get_bounce());
|
||||||
|
}
|
||||||
SceneTree *st = SceneTree::get_singleton();
|
SceneTree *st = SceneTree::get_singleton();
|
||||||
|
|
||||||
if (st && st->is_debugging_collisions_hint()) {
|
if (st && st->is_debugging_collisions_hint()) {
|
||||||
|
@ -815,6 +829,9 @@ void GridMap::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("set_collision_layer_bit", "bit", "value"), &GridMap::set_collision_layer_bit);
|
ClassDB::bind_method(D_METHOD("set_collision_layer_bit", "bit", "value"), &GridMap::set_collision_layer_bit);
|
||||||
ClassDB::bind_method(D_METHOD("get_collision_layer_bit", "bit"), &GridMap::get_collision_layer_bit);
|
ClassDB::bind_method(D_METHOD("get_collision_layer_bit", "bit"), &GridMap::get_collision_layer_bit);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("set_physics_material", "material"), &GridMap::set_physics_material);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_physics_material"), &GridMap::get_physics_material);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("set_mesh_library", "mesh_library"), &GridMap::set_mesh_library);
|
ClassDB::bind_method(D_METHOD("set_mesh_library", "mesh_library"), &GridMap::set_mesh_library);
|
||||||
ClassDB::bind_method(D_METHOD("get_mesh_library"), &GridMap::get_mesh_library);
|
ClassDB::bind_method(D_METHOD("get_mesh_library"), &GridMap::get_mesh_library);
|
||||||
|
|
||||||
|
@ -861,6 +878,7 @@ void GridMap::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("get_use_in_baked_light"), &GridMap::get_use_in_baked_light);
|
ClassDB::bind_method(D_METHOD("get_use_in_baked_light"), &GridMap::get_use_in_baked_light);
|
||||||
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh_library", PROPERTY_HINT_RESOURCE_TYPE, "MeshLibrary"), "set_mesh_library", "get_mesh_library");
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh_library", PROPERTY_HINT_RESOURCE_TYPE, "MeshLibrary"), "set_mesh_library", "get_mesh_library");
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "physics_material", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsMaterial"), "set_physics_material", "get_physics_material");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_in_baked_light"), "set_use_in_baked_light", "get_use_in_baked_light");
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_in_baked_light"), "set_use_in_baked_light", "get_use_in_baked_light");
|
||||||
ADD_GROUP("Cell", "cell_");
|
ADD_GROUP("Cell", "cell_");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "cell_size"), "set_cell_size", "get_cell_size");
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "cell_size"), "set_cell_size", "get_cell_size");
|
||||||
|
|
|
@ -39,6 +39,8 @@
|
||||||
//heh heh, godotsphir!! this shares no code and the design is completely different with previous projects i've done..
|
//heh heh, godotsphir!! this shares no code and the design is completely different with previous projects i've done..
|
||||||
//should scale better with hardware that supports instancing
|
//should scale better with hardware that supports instancing
|
||||||
|
|
||||||
|
class PhysicsMaterial;
|
||||||
|
|
||||||
class GridMap : public Spatial {
|
class GridMap : public Spatial {
|
||||||
GDCLASS(GridMap, Spatial);
|
GDCLASS(GridMap, Spatial);
|
||||||
|
|
||||||
|
@ -132,6 +134,7 @@ class GridMap : public Spatial {
|
||||||
|
|
||||||
uint32_t collision_layer;
|
uint32_t collision_layer;
|
||||||
uint32_t collision_mask;
|
uint32_t collision_mask;
|
||||||
|
Ref<PhysicsMaterial> physics_material;
|
||||||
|
|
||||||
Transform last_transform;
|
Transform last_transform;
|
||||||
|
|
||||||
|
@ -219,6 +222,9 @@ public:
|
||||||
void set_collision_mask_bit(int p_bit, bool p_value);
|
void set_collision_mask_bit(int p_bit, bool p_value);
|
||||||
bool get_collision_mask_bit(int p_bit) const;
|
bool get_collision_mask_bit(int p_bit) const;
|
||||||
|
|
||||||
|
void set_physics_material(Ref<PhysicsMaterial> p_material);
|
||||||
|
Ref<PhysicsMaterial> get_physics_material() const;
|
||||||
|
|
||||||
void set_mesh_library(const Ref<MeshLibrary> &p_mesh_library);
|
void set_mesh_library(const Ref<MeshLibrary> &p_mesh_library);
|
||||||
Ref<MeshLibrary> get_mesh_library() const;
|
Ref<MeshLibrary> get_mesh_library() const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue