summaryrefslogtreecommitdiff
path: root/scene/3d/room_instance.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/3d/room_instance.cpp')
-rw-r--r--scene/3d/room_instance.cpp92
1 files changed, 32 insertions, 60 deletions
diff --git a/scene/3d/room_instance.cpp b/scene/3d/room_instance.cpp
index b363c05ef7..3b6ae32d16 100644
--- a/scene/3d/room_instance.cpp
+++ b/scene/3d/room_instance.cpp
@@ -34,44 +34,35 @@
#include "global_config.h"
#include "scene/resources/surface_tool.h"
-
void Room::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_WORLD: {
// go find parent level
- Node *parent_room=get_parent();
- level=0;
+ Node *parent_room = get_parent();
+ level = 0;
- while(parent_room) {
+ while (parent_room) {
Room *r = parent_room->cast_to<Room>();
if (r) {
- level=r->level+1;
+ level = r->level + 1;
break;
}
- parent_room=parent_room->get_parent();
+ parent_room = parent_room->get_parent();
}
-
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
} break;
case NOTIFICATION_EXIT_WORLD: {
-
-
- } break;
+ } break;
}
-
}
-
-
-
-
Rect3 Room::get_aabb() const {
if (room.is_null())
@@ -83,12 +74,11 @@ Rect3 Room::get_aabb() const {
PoolVector<Face3> Room::get_faces(uint32_t p_usage_flags) const {
return PoolVector<Face3>();
-
}
-void Room::set_room( const Ref<RoomBounds>& p_room ) {
+void Room::set_room(const Ref<RoomBounds> &p_room) {
- room=p_room;
+ room = p_room;
update_gizmo();
if (room.is_valid()) {
@@ -101,11 +91,8 @@ void Room::set_room( const Ref<RoomBounds>& p_room ) {
if (!is_inside_tree())
return;
-
propagate_notification(NOTIFICATION_AREA_CHANGED);
update_gizmo();
-
-
}
Ref<RoomBounds> Room::get_room() const {
@@ -113,75 +100,60 @@ Ref<RoomBounds> Room::get_room() const {
return room;
}
-void Room::_parse_node_faces(PoolVector<Face3> &all_faces,const Node *p_node) const {
+void Room::_parse_node_faces(PoolVector<Face3> &all_faces, const Node *p_node) const {
- const VisualInstance *vi=p_node->cast_to<VisualInstance>();
+ const VisualInstance *vi = p_node->cast_to<VisualInstance>();
if (vi) {
- PoolVector<Face3> faces=vi->get_faces(FACES_ENCLOSING);
+ PoolVector<Face3> faces = vi->get_faces(FACES_ENCLOSING);
if (faces.size()) {
- int old_len=all_faces.size();
- all_faces.resize( all_faces.size() + faces.size() );
- int new_len=all_faces.size();
- PoolVector<Face3>::Write all_facesw=all_faces.write();
- Face3 * all_facesptr=all_facesw.ptr();
+ int old_len = all_faces.size();
+ all_faces.resize(all_faces.size() + faces.size());
+ int new_len = all_faces.size();
+ PoolVector<Face3>::Write all_facesw = all_faces.write();
+ Face3 *all_facesptr = all_facesw.ptr();
- PoolVector<Face3>::Read facesr=faces.read();
- const Face3 * facesptr=facesr.ptr();
+ PoolVector<Face3>::Read facesr = faces.read();
+ const Face3 *facesptr = facesr.ptr();
- Transform tr=vi->get_relative_transform(this);
+ Transform tr = vi->get_relative_transform(this);
- for(int i=old_len;i<new_len;i++) {
+ for (int i = old_len; i < new_len; i++) {
- Face3 f=facesptr[i-old_len];
- for (int j=0;j<3;j++)
- f.vertex[j]=tr.xform(f.vertex[j]);
- all_facesptr[i]=f;
+ Face3 f = facesptr[i - old_len];
+ for (int j = 0; j < 3; j++)
+ f.vertex[j] = tr.xform(f.vertex[j]);
+ all_facesptr[i] = f;
}
}
}
+ for (int i = 0; i < p_node->get_child_count(); i++) {
- for (int i=0;i<p_node->get_child_count();i++) {
-
- _parse_node_faces(all_faces,p_node->get_child(i));
+ _parse_node_faces(all_faces, p_node->get_child(i));
}
-
}
-
-
void Room::_bounds_changed() {
update_gizmo();
}
-
-
void Room::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_room","room:Room"),&Room::set_room );
- ClassDB::bind_method(D_METHOD("get_room:Room"),&Room::get_room );
-
-
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "room/room", PROPERTY_HINT_RESOURCE_TYPE, "Area" ), "set_room", "get_room") ;
+ ClassDB::bind_method(D_METHOD("set_room", "room:Room"), &Room::set_room);
+ ClassDB::bind_method(D_METHOD("get_room:Room"), &Room::get_room);
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "room/room", PROPERTY_HINT_RESOURCE_TYPE, "Area"), "set_room", "get_room");
}
-
Room::Room() {
-// sound_enabled=false;
-
- level=0;
-
+ // sound_enabled=false;
+ level = 0;
}
-
Room::~Room() {
-
-
}
-