diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-05-04 15:19:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-04 15:19:30 +0200 |
commit | 0bc07f8ff39deaf8621858f0033fd39d62c0426b (patch) | |
tree | cb65ce4177d5f41f97bd259a0c9ec9a1c8e3efd9 /scene | |
parent | bd54ff78d995f84ce1684b85ac8137130fa1e57a (diff) | |
parent | 1ee40206d49736d57d97c37f738c961ab0bda28c (diff) |
Merge pull request #18480 from BastiaanOlij/add_custom_aabb_to_primitives
Added custom aabb to primitives
Diffstat (limited to 'scene')
-rw-r--r-- | scene/resources/primitive_meshes.cpp | 16 | ||||
-rw-r--r-- | scene/resources/primitive_meshes.h | 4 |
2 files changed, 20 insertions, 0 deletions
diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp index 056ac2772b..ad63422aad 100644 --- a/scene/resources/primitive_meshes.cpp +++ b/scene/resources/primitive_meshes.cpp @@ -166,7 +166,11 @@ void PrimitiveMesh::_bind_methods() { ClassDB::bind_method(D_METHOD("get_mesh_arrays"), &PrimitiveMesh::get_mesh_arrays); + ClassDB::bind_method(D_METHOD("set_custom_aabb", "aabb"), &PrimitiveMesh::set_custom_aabb); + ClassDB::bind_method(D_METHOD("get_custom_aabb"), &PrimitiveMesh::get_custom_aabb); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ShaderMaterial"), "set_material", "get_material"); + ADD_PROPERTY(PropertyInfo(Variant::AABB, "custom_aabb", PROPERTY_HINT_NONE, ""), "set_custom_aabb", "get_custom_aabb"); } void PrimitiveMesh::set_material(const Ref<Material> &p_material) { @@ -187,6 +191,18 @@ Array PrimitiveMesh::get_mesh_arrays() const { return surface_get_arrays(0); } +void PrimitiveMesh::set_custom_aabb(const AABB &p_custom) { + + custom_aabb = p_custom; + VS::get_singleton()->mesh_set_custom_aabb(mesh, custom_aabb); + emit_changed(); +} + +AABB PrimitiveMesh::get_custom_aabb() const { + + return custom_aabb; +} + PrimitiveMesh::PrimitiveMesh() { // defaults mesh = VisualServer::get_singleton()->mesh_create(); diff --git a/scene/resources/primitive_meshes.h b/scene/resources/primitive_meshes.h index 94a7a055a3..23d1671d5c 100644 --- a/scene/resources/primitive_meshes.h +++ b/scene/resources/primitive_meshes.h @@ -48,6 +48,7 @@ class PrimitiveMesh : public Mesh { private: RID mesh; mutable AABB aabb; + AABB custom_aabb; Ref<Material> material; @@ -81,6 +82,9 @@ public: Array get_mesh_arrays() const; + void set_custom_aabb(const AABB &p_custom); + AABB get_custom_aabb() const; + PrimitiveMesh(); ~PrimitiveMesh(); }; |