summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.cpp29
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.h17
-rw-r--r--editor/editor_settings.cpp6
-rw-r--r--editor/editor_settings.h3
-rw-r--r--editor/import/resource_importer_scene.cpp4
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp94
-rw-r--r--editor/plugins/spatial_editor_plugin.h3
-rw-r--r--editor/spatial_editor_gizmos.cpp362
-rw-r--r--editor/spatial_editor_gizmos.h65
-rw-r--r--modules/gridmap/grid_map.cpp427
-rw-r--r--modules/gridmap/grid_map.h48
-rw-r--r--modules/gridmap/grid_map_editor_plugin.cpp360
-rw-r--r--modules/gridmap/grid_map_editor_plugin.h13
-rw-r--r--scene/3d/portal.cpp2
-rw-r--r--scene/3d/portal.h4
-rw-r--r--scene/3d/room_instance.cpp2
-rw-r--r--scene/3d/room_instance.h5
-rw-r--r--scene/3d/spatial.cpp23
-rw-r--r--scene/3d/spatial.h1
-rw-r--r--scene/3d/visual_instance.cpp27
-rw-r--r--scene/3d/visual_instance.h1
-rw-r--r--scene/main/viewport.cpp2
-rw-r--r--scene/register_scene_types.cpp7
-rw-r--r--scene/resources/room.cpp3
-rw-r--r--scene/resources/room.h4
-rw-r--r--servers/visual/rasterizer.h17
-rw-r--r--servers/visual/visual_server_raster.h18
-rw-r--r--servers/visual/visual_server_scene.cpp584
-rw-r--r--servers/visual/visual_server_scene.h42
-rw-r--r--servers/visual/visual_server_wrap_mt.h18
-rw-r--r--servers/visual_server.h21
31 files changed, 489 insertions, 1723 deletions
diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp
index 68731308a9..dcf8ef2277 100644
--- a/drivers/gles3/rasterizer_storage_gles3.cpp
+++ b/drivers/gles3/rasterizer_storage_gles3.cpp
@@ -4854,35 +4854,6 @@ float RasterizerStorageGLES3::reflection_probe_get_origin_max_distance(RID p_pro
return reflection_probe->max_distance;
}
-/* ROOM API */
-
-RID RasterizerStorageGLES3::room_create() {
-
- return RID();
-}
-void RasterizerStorageGLES3::room_add_bounds(RID p_room, const PoolVector<Vector2> &p_convex_polygon, float p_height, const Transform &p_transform) {
-}
-void RasterizerStorageGLES3::room_clear_bounds(RID p_room) {
-}
-
-/* PORTAL API */
-
-// portals are only (x/y) points, forming a convex shape, which its clockwise
-// order points outside. (z is 0);
-
-RID RasterizerStorageGLES3::portal_create() {
-
- return RID();
-}
-void RasterizerStorageGLES3::portal_set_shape(RID p_portal, const Vector<Point2> &p_shape) {
-}
-void RasterizerStorageGLES3::portal_set_enabled(RID p_portal, bool p_enabled) {
-}
-void RasterizerStorageGLES3::portal_set_disable_distance(RID p_portal, float p_distance) {
-}
-void RasterizerStorageGLES3::portal_set_disabled_color(RID p_portal, const Color &p_color) {
-}
-
RID RasterizerStorageGLES3::gi_probe_create() {
GIProbe *gip = memnew(GIProbe);
diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h
index f612d9e879..b0cb04569e 100644
--- a/drivers/gles3/rasterizer_storage_gles3.h
+++ b/drivers/gles3/rasterizer_storage_gles3.h
@@ -953,23 +953,6 @@ public:
virtual float reflection_probe_get_origin_max_distance(RID p_probe) const;
virtual bool reflection_probe_renders_shadows(RID p_probe) const;
- /* ROOM API */
-
- virtual RID room_create();
- virtual void room_add_bounds(RID p_room, const PoolVector<Vector2> &p_convex_polygon, float p_height, const Transform &p_transform);
- virtual void room_clear_bounds(RID p_room);
-
- /* PORTAL API */
-
- // portals are only (x/y) points, forming a convex shape, which its clockwise
- // order points outside. (z is 0);
-
- virtual RID portal_create();
- virtual void portal_set_shape(RID p_portal, const Vector<Point2> &p_shape);
- virtual void portal_set_enabled(RID p_portal, bool p_enabled);
- virtual void portal_set_disable_distance(RID p_portal, float p_distance);
- virtual void portal_set_disabled_color(RID p_portal, const Color &p_color);
-
/* GI PROBE API */
struct GIProbe : public Instantiable {
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 88c8c368d4..08ee8c3c9e 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -216,6 +216,12 @@ Variant _EDITOR_DEF(const String &p_var, const Variant &p_default) {
return p_default;
}
+Variant _EDITOR_GET(const String &p_var) {
+
+ ERR_FAIL_COND_V(!EditorSettings::get_singleton()->has(p_var), Variant())
+ return EditorSettings::get_singleton()->get(p_var);
+}
+
static Dictionary _get_builtin_script_templates() {
Dictionary templates;
diff --git a/editor/editor_settings.h b/editor/editor_settings.h
index a99d7e0ad5..b479d21dfb 100644
--- a/editor/editor_settings.h
+++ b/editor/editor_settings.h
@@ -180,6 +180,9 @@ public:
#define EDITOR_DEF(m_var, m_val) _EDITOR_DEF(m_var, Variant(m_val))
Variant _EDITOR_DEF(const String &p_var, const Variant &p_default);
+#define EDITOR_GET(m_var) _EDITOR_GET(m_var)
+Variant _EDITOR_GET(const String &p_var);
+
#define ED_IS_SHORTCUT(p_name, p_ev) (EditorSettings::get_singleton()->is_shortcut(p_name, p_ev))
Ref<ShortCut> ED_SHORTCUT(const String &p_path, const String &p_name, uint32_t p_keycode = 0);
Ref<ShortCut> ED_GET_SHORTCUT(const String &p_path);
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index 5bba289492..59cd16c0b8 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -537,7 +537,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
s->set_transform(Transform());
p_node = bv;
-
+#if 0
} else if (_teststr(name, "room") && Object::cast_to<MeshInstance>(p_node)) {
if (isroot)
@@ -657,7 +657,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
p_node->replace_by(portal);
memdelete(p_node);
p_node = portal;
-
+#endif
} else if (Object::cast_to<MeshInstance>(p_node)) {
//last attempt, maybe collision insde the mesh data
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index b269f29036..e2c8caae1f 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -63,17 +63,45 @@
#define MIN_FOV 0.01
#define MAX_FOV 179
-void SpatialEditorViewport::_update_camera() {
+void SpatialEditorViewport::_update_camera(float p_interp_delta) {
if (orthogonal) {
//camera->set_orthogonal(size.width*cursor.distance,get_znear(),get_zfar());
camera->set_orthogonal(2 * cursor.distance, 0.1, 8192);
} else
camera->set_perspective(get_fov(), get_znear(), get_zfar());
- Transform camera_transform = to_camera_transform(cursor);
+ Transform new_transform = to_camera_transform(cursor);
+ Transform old_transform = camera->get_global_transform();
+ Transform transform;
- if (camera->get_global_transform() != camera_transform) {
- camera->set_global_transform(camera_transform);
+ if (p_interp_delta && Input::get_singleton()->get_mouse_button_mask() == 0) {
+ //interpolate
+ float interp_speed = 14; //maybe should be made configuration
+ transform = old_transform.interpolate_with(new_transform, MIN(1.0, p_interp_delta * interp_speed));
+ } else {
+ transform = new_transform;
+ }
+
+ float tolerance = 0.0001;
+ bool equal = true;
+ for (int i = 0; i < 3; i++) {
+ if (transform.basis[i].distance_to(old_transform.basis[i]) > tolerance) {
+ equal = false;
+ break;
+ }
+ }
+
+ if (equal && transform.origin.distance_to(old_transform.origin) > tolerance) {
+ equal = false;
+ }
+
+ if (equal) {
+ transform = new_transform;
+ }
+
+ if (!equal || p_interp_delta == 0) {
+ //print_line(transform);
+ camera->set_global_transform(transform);
update_transform_gizmo_view();
}
}
@@ -257,14 +285,12 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append,
Vector<ObjectID> instances = VisualServer::get_singleton()->instances_cull_ray(pos, ray, get_tree()->get_root()->get_world()->get_scenario());
Set<Ref<SpatialEditorGizmo> > found_gizmos;
+ Node *edited_scene = get_tree()->get_edited_scene_root();
ObjectID closest = 0;
Spatial *item = NULL;
float closest_dist = 1e20;
int selected_handle = -1;
- Vector<Spatial *> subscenes = Vector<Spatial *>();
- Vector<Vector3> subscenes_positions = Vector<Vector3>();
-
for (int i = 0; i < instances.size(); i++) {
Spatial *spat = Object::cast_to<Spatial>(ObjectDB::get_instance(instances[i]));
@@ -275,19 +301,6 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append,
Ref<SpatialEditorGizmo> seg = spat->get_gizmo();
if ((!seg.is_valid()) || found_gizmos.has(seg)) {
-
- Node *subscene_candidate = spat;
- Vector3 source_click_spatial_pos = spat->get_global_transform().origin;
-
- while ((subscene_candidate->get_owner() != NULL) && (subscene_candidate->get_owner() != editor->get_edited_scene()))
- subscene_candidate = subscene_candidate->get_owner();
-
- spat = Object::cast_to<Spatial>(subscene_candidate);
- if (spat && (spat->get_filename() != "") && (subscene_candidate->get_owner() != NULL)) {
- subscenes.push_back(spat);
- subscenes_positions.push_back(source_click_spatial_pos);
- }
-
continue;
}
@@ -307,32 +320,26 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append,
continue;
if (dist < closest_dist) {
- closest = instances[i];
- closest_dist = dist;
- selected_handle = handle;
- item = spat;
+ //make sure that whathever is selected is editable
+ while (spat && spat != edited_scene && spat->get_owner() != edited_scene && !edited_scene->is_editable_instance(spat->get_owner())) {
+
+ spat = Object::cast_to<Spatial>(spat->get_owner());
+ }
+
+ if (spat) {
+ item = spat;
+ closest = spat->get_instance_id();
+ closest_dist = dist;
+ selected_handle = handle;
+ } else {
+ ERR_PRINT("Bug?");
+ }
}
// if (editor_selection->is_selected(spat))
// r_includes_current=true;
}
- for (int idx_subscene = 0; idx_subscene < subscenes.size(); idx_subscene++) {
-
- Spatial *subscene = subscenes.get(idx_subscene);
- float dist = ray.cross(subscenes_positions.get(idx_subscene) - pos).length();
-
- if ((dist < 0) || (dist > 1.2))
- continue;
-
- if (dist < closest_dist) {
- closest = subscene->get_instance_id();
- closest_dist = dist;
- item = subscene;
- selected_handle = -1;
- }
- }
-
if (!item)
return 0;
@@ -1678,7 +1685,7 @@ void SpatialEditorViewport::_notification(int p_what) {
set_process(visible);
if (visible)
- _update_camera();
+ _update_camera(0);
call_deferred("update_transform_gizmo_view");
}
@@ -1710,7 +1717,7 @@ void SpatialEditorViewport::_notification(int p_what) {
_update_freelook(delta);
- _update_camera();
+ _update_camera(get_process_delta_time());
Map<Node *, Object *> &selection = editor_selection->get_selection();
@@ -3677,7 +3684,7 @@ void SpatialEditor::_request_gizmo(Object *p_obj) {
Spatial *sp = Object::cast_to<Spatial>(p_obj);
if (!sp)
return;
- if (editor->get_edited_scene() && (sp == editor->get_edited_scene() || sp->get_owner() == editor->get_edited_scene() || editor->get_edited_scene()->is_editable_instance(sp->get_owner()))) {
+ if (editor->get_edited_scene() && (sp == editor->get_edited_scene() || (sp->get_owner() && editor->get_edited_scene()->is_a_parent_of(sp)))) {
Ref<SpatialEditorGizmo> seg;
@@ -3691,7 +3698,6 @@ void SpatialEditor::_request_gizmo(Object *p_obj) {
if (!seg.is_valid()) {
seg = gizmos->get_gizmo(sp);
}
-
if (seg.is_valid()) {
sp->set_gizmo(seg);
}
diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h
index 2fd72739df..7797a657c0 100644
--- a/editor/plugins/spatial_editor_plugin.h
+++ b/editor/plugins/spatial_editor_plugin.h
@@ -49,6 +49,7 @@ class SpatialEditorGizmo : public SpatialGizmo {
GDCLASS(SpatialEditorGizmo, SpatialGizmo);
bool selected;
+ bool instanced;
public:
void set_selected(bool p_selected) { selected = p_selected; }
@@ -240,7 +241,7 @@ private:
void set_message(String p_message, float p_time = 5);
//
- void _update_camera();
+ void _update_camera(float p_interp_delta);
Transform to_camera_transform(const Cursor &p_cursor) const;
void _draw();
diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp
index e80fa603ce..45d622c9d2 100644
--- a/editor/spatial_editor_gizmos.cpp
+++ b/editor/spatial_editor_gizmos.cpp
@@ -45,6 +45,24 @@
#define HANDLE_HALF_SIZE 0.05
+bool EditorSpatialGizmo::can_draw() const {
+ return is_editable();
+}
+bool EditorSpatialGizmo::is_editable() const {
+
+ ERR_FAIL_COND_V(!spatial_node, false);
+ Node *edited_root = spatial_node->get_tree()->get_edited_scene_root();
+ if (spatial_node == edited_root)
+ return true;
+ if (spatial_node->get_owner() == edited_root)
+ return true;
+
+ if (edited_root->is_editable_instance(spatial_node->get_owner()))
+ return true;
+
+ return false;
+}
+
void EditorSpatialGizmo::clear() {
for (int i = 0; i < instances.size(); i++) {
@@ -211,7 +229,7 @@ void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, bool p_bi
billboard_handle = p_billboard;
- if (!is_selected())
+ if (!is_selected() || !is_editable())
return;
ERR_FAIL_COND(!spatial_node);
@@ -560,6 +578,94 @@ void EditorSpatialGizmo::free() {
valid = false;
}
+Ref<SpatialMaterial> EditorSpatialGizmo::create_material(const String &p_name, const Color &p_color, bool p_billboard, bool p_on_top, bool p_use_vertex_color) {
+
+ String name = p_name;
+
+ if (!is_editable()) {
+ name += "@readonly";
+ } else if (is_selected()) {
+ name += "@selected";
+ }
+
+ if (SpatialEditorGizmos::singleton->material_cache.has(name)) {
+ return SpatialEditorGizmos::singleton->material_cache[name];
+ }
+
+ Color color = p_color;
+
+ if (!is_editable()) {
+ color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/instanced");
+ } else if (!is_selected()) {
+ color.a *= 0.5;
+ }
+
+ Ref<SpatialMaterial> line_material;
+ line_material.instance();
+ line_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
+ line_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
+ if (p_use_vertex_color) {
+ line_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ line_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
+ }
+
+ if (p_billboard) {
+ line_material->set_billboard_mode(SpatialMaterial::BILLBOARD_ENABLED);
+ }
+
+ if (p_on_top && is_selected()) {
+ line_material->set_flag(SpatialMaterial::FLAG_ONTOP, true);
+ }
+
+ line_material->set_albedo(color);
+
+ SpatialEditorGizmos::singleton->material_cache[name] = line_material;
+
+ return line_material;
+}
+
+Ref<SpatialMaterial> EditorSpatialGizmo::create_icon_material(const String &p_name, const Ref<Texture> &p_texture, bool p_on_top, const Color &p_albedo) {
+
+ String name = p_name;
+
+ if (!is_editable()) {
+ name += "@readonly";
+ } else if (is_selected()) {
+ name += "@selected";
+ }
+
+ if (SpatialEditorGizmos::singleton->material_cache.has(name)) {
+ return SpatialEditorGizmos::singleton->material_cache[name];
+ }
+
+ Color color = p_albedo;
+
+ if (!is_editable()) {
+ color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/instanced");
+ } else if (!is_selected()) {
+ color.a *= 0.5;
+ }
+
+ Ref<SpatialMaterial> icon;
+ icon.instance();
+ icon->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
+ icon->set_cull_mode(SpatialMaterial::CULL_DISABLED);
+ icon->set_depth_draw_mode(SpatialMaterial::DEPTH_DRAW_DISABLED);
+ icon->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
+ icon->set_albedo(color);
+ icon->set_texture(SpatialMaterial::TEXTURE_ALBEDO, p_texture);
+ icon->set_flag(SpatialMaterial::FLAG_FIXED_SIZE, true);
+ icon->set_billboard_mode(SpatialMaterial::BILLBOARD_ENABLED);
+
+ if (p_on_top && is_selected()) {
+ icon->set_flag(SpatialMaterial::FLAG_ONTOP, true);
+ }
+
+ SpatialEditorGizmos::singleton->material_cache[name] = icon;
+
+ return icon;
+}
+
void EditorSpatialGizmo::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_lines", "lines", "material", "billboard"), &EditorSpatialGizmo::add_lines, DEFVAL(false));
@@ -713,8 +819,13 @@ void LightSpatialGizmo::commit_handle(int p_idx, const Variant &p_restore, bool
void LightSpatialGizmo::redraw() {
+ Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/light");
+
if (Object::cast_to<DirectionalLight>(light)) {
+ Ref<Material> material = create_material("light_directional_material", gizmo_color);
+ Ref<Material> icon = create_icon_material("light_directional_icon", SpatialEditor::get_singleton()->get_icon("GizmoDirectionalLight", "EditorIcons"));
+
const int arrow_points = 5;
Vector3 arrow[arrow_points] = {
Vector3(0, 0, 2),
@@ -746,13 +857,15 @@ void LightSpatialGizmo::redraw() {
}
}
- add_lines(lines, SpatialEditorGizmos::singleton->light_material);
+ add_lines(lines, material);
add_collision_segments(lines);
- add_unscaled_billboard(SpatialEditorGizmos::singleton->light_material_directional_icon, 0.05);
+ add_unscaled_billboard(icon, 0.05);
}
if (Object::cast_to<OmniLight>(light)) {
+ Ref<Material> material = create_material("light_omni_material", gizmo_color, true);
+ Ref<Material> icon = create_icon_material("light_omni_icon", SpatialEditor::get_singleton()->get_icon("GizmoLight", "EditorIcons"));
clear();
OmniLight *on = Object::cast_to<OmniLight>(light);
@@ -776,10 +889,10 @@ void LightSpatialGizmo::redraw() {
points.push_back(Vector3(b.x, b.y, 0));
}
- add_lines(points, SpatialEditorGizmos::singleton->light_material_omni, true);
+ add_lines(points, material, true);
add_collision_segments(points);
- add_unscaled_billboard(SpatialEditorGizmos::singleton->light_material_omni_icon, 0.05);
+ add_unscaled_billboard(icon, 0.05);
Vector<Vector3> handles;
handles.push_back(Vector3(r, 0, 0));
@@ -788,6 +901,9 @@ void LightSpatialGizmo::redraw() {
if (Object::cast_to<SpotLight>(light)) {
+ Ref<Material> material = create_material("light_spot_material", gizmo_color, true);
+ Ref<Material> icon = create_icon_material("light_spot_icon", SpatialEditor::get_singleton()->get_icon("GizmoLight", "EditorIcons"));
+
clear();
Vector<Vector3> points;
@@ -821,7 +937,7 @@ void LightSpatialGizmo::redraw() {
points.push_back(Vector3(0, 0, -r));
points.push_back(Vector3());
- add_lines(points, SpatialEditorGizmos::singleton->light_material);
+ add_lines(points, material);
Vector<Vector3> handles;
handles.push_back(Vector3(0, 0, -r));
@@ -855,7 +971,7 @@ void LightSpatialGizmo::redraw() {
add_handles(handles);
add_collision_segments(collision_segments);
- add_unscaled_billboard(SpatialEditorGizmos::singleton->light_material_omni_icon, 0.05);
+ add_unscaled_billboard(icon, 0.05);
}
}
@@ -937,7 +1053,13 @@ void AudioStreamPlayer3DSpatialGizmo::redraw() {
clear();
+ Ref<Material> icon = create_icon_material("stream_player_3d_material", SpatialEditor::get_singleton()->get_icon("GizmoSpatialSamplePlayer", "EditorIcons"));
+
if (player->is_emission_angle_enabled()) {
+
+ Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/stream_player_3d");
+ Ref<Material> material = create_material("stream_player_3d_material", gizmo_color);
+
float pc = player->get_emission_angle();
Vector<Vector3> points;
@@ -968,7 +1090,7 @@ void AudioStreamPlayer3DSpatialGizmo::redraw() {
points[200 + i * 2 + 1] = Vector3();
}
- add_lines(points, SpatialEditorGizmos::singleton->car_wheel_material);
+ add_lines(points, material);
add_collision_segments(points);
Vector<Vector3> handles;
@@ -977,7 +1099,7 @@ void AudioStreamPlayer3DSpatialGizmo::redraw() {
add_handles(handles);
}
- add_unscaled_billboard(SpatialEditorGizmos::singleton->sample_player_icon, 0.05);
+ add_unscaled_billboard(icon, 0.05);
}
AudioStreamPlayer3DSpatialGizmo::AudioStreamPlayer3DSpatialGizmo(AudioStreamPlayer3D *p_player) {
@@ -1068,6 +1190,9 @@ void CameraSpatialGizmo::redraw() {
Vector<Vector3> lines;
Vector<Vector3> handles;
+ Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/camera");
+ Ref<Material> material = create_material("camera_material", gizmo_color);
+
switch (camera->get_projection()) {
case Camera::PROJECTION_PERSPECTIVE: {
@@ -1135,7 +1260,7 @@ void CameraSpatialGizmo::redraw() {
} break;
}
- add_lines(lines, SpatialEditorGizmos::singleton->camera_material);
+ add_lines(lines, material);
add_collision_segments(lines);
add_handles(handles);
}
@@ -1148,6 +1273,9 @@ CameraSpatialGizmo::CameraSpatialGizmo(Camera *p_camera) {
//////
+bool MeshInstanceSpatialGizmo::can_draw() const {
+ return true; //mesh can always draw (even though nothing is displayed)
+}
void MeshInstanceSpatialGizmo::redraw() {
Ref<Mesh> m = mesh->get_mesh();
@@ -1194,10 +1322,13 @@ void SkeletonSpatialGizmo::redraw() {
clear();
+ Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/skeleton");
+ Ref<Material> material = create_material("skeleton_material", gizmo_color);
+
Ref<SurfaceTool> surface_tool(memnew(SurfaceTool));
surface_tool->begin(Mesh::PRIMITIVE_LINES);
- surface_tool->set_material(SpatialEditorGizmos::singleton->skeleton_material);
+ surface_tool->set_material(material);
Vector<Transform> grests;
grests.resize(skel->get_bone_count());
@@ -1378,7 +1509,7 @@ SkeletonSpatialGizmo::SkeletonSpatialGizmo(Skeleton *p_skel) {
skel = p_skel;
set_spatial_node(p_skel);
}
-
+#if 0
void RoomSpatialGizmo::redraw() {
clear();
@@ -1481,6 +1612,7 @@ PortalSpatialGizmo::PortalSpatialGizmo(Portal *p_portal) {
portal = p_portal;
}
+#endif
/////
void RayCastSpatialGizmo::redraw() {
@@ -1492,7 +1624,10 @@ void RayCastSpatialGizmo::redraw() {
lines.push_back(Vector3());
lines.push_back(raycast->get_cast_to());
- add_lines(lines, SpatialEditorGizmos::singleton->raycast_material);
+ Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/shape");
+ Ref<Material> material = create_material("shape_material", gizmo_color);
+
+ add_lines(lines, material);
add_collision_segments(lines);
}
@@ -1550,7 +1685,10 @@ void VehicleWheelSpatialGizmo::redraw() {
points.push_back(Vector3(0, -r, r * 2));
points.push_back(Vector3(-r * 2 * 0.2, -r, r * 2 * 0.8));
- add_lines(points, SpatialEditorGizmos::singleton->car_wheel_material);
+ Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/shape");
+ Ref<Material> material = create_material("shape_material", gizmo_color);
+
+ add_lines(points, material);
add_collision_segments(points);
}
@@ -1778,6 +1916,9 @@ void CollisionShapeSpatialGizmo::redraw() {
if (s.is_null())
return;
+ Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/shape");
+ Ref<Material> material = create_material("shape_material", gizmo_color);
+
if (Object::cast_to<SphereShape>(*s)) {
Ref<SphereShape> sp = s;
@@ -1817,7 +1958,7 @@ void CollisionShapeSpatialGizmo::redraw() {
collision_segments.push_back(Vector3(b.x, b.y, 0));
}
- add_lines(points, SpatialEditorGizmos::singleton->shape_material);
+ add_lines(points, material);
add_collision_segments(collision_segments);
Vector<Vector3> handles;
handles.push_back(Vector3(r, 0, 0));
@@ -1848,7 +1989,7 @@ void CollisionShapeSpatialGizmo::redraw() {
handles.push_back(ax);
}
- add_lines(lines, SpatialEditorGizmos::singleton->shape_material);
+ add_lines(lines, material);
add_collision_segments(lines);
add_handles(handles);
}
@@ -1889,7 +2030,7 @@ void CollisionShapeSpatialGizmo::redraw() {
points.push_back(Vector3(b.y, 0, b.x) + dud);
}
- add_lines(points, SpatialEditorGizmos::singleton->shape_material);
+ add_lines(points, material);
Vector<Vector3> collision_segments;
@@ -1955,7 +2096,7 @@ void CollisionShapeSpatialGizmo::redraw() {
points.push_back(p.normal * p.d);
points.push_back(p.normal * p.d + p.normal * 3);
- add_lines(points, SpatialEditorGizmos::singleton->shape_material);
+ add_lines(points, material);
add_collision_segments(points);
}
@@ -1977,7 +2118,7 @@ void CollisionShapeSpatialGizmo::redraw() {
points[i * 2 + 1] = md.vertices[md.edges[i].b];
}
- add_lines(points, SpatialEditorGizmos::singleton->shape_material);
+ add_lines(points, material);
add_collision_segments(points);
}
}
@@ -1990,7 +2131,7 @@ void CollisionShapeSpatialGizmo::redraw() {
Vector<Vector3> points;
points.push_back(Vector3());
points.push_back(Vector3(0, 0, rs->get_length()));
- add_lines(points, SpatialEditorGizmos::singleton->shape_material);
+ add_lines(points, material);
add_collision_segments(points);
Vector<Vector3> handles;
handles.push_back(Vector3(0, 0, rs->get_length()));
@@ -2024,7 +2165,10 @@ void CollisionPolygonSpatialGizmo::redraw() {
lines.push_back(Vector3(points[i].x, points[i].y, -depth));
}
- add_lines(lines, SpatialEditorGizmos::singleton->shape_material);
+ Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/shape");
+ Ref<Material> material = create_material("shape_material", gizmo_color);
+
+ add_lines(lines, material);
add_collision_segments(lines);
}
@@ -2092,6 +2236,9 @@ void VisibilityNotifierGizmo::commit_handle(int p_idx, const Variant &p_restore,
void VisibilityNotifierGizmo::redraw() {
+ Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/visibility_notifier");
+ Ref<Material> material = create_material("visibility_notifier_material", gizmo_color);
+
clear();
Vector<Vector3> lines;
@@ -2113,7 +2260,7 @@ void VisibilityNotifierGizmo::redraw() {
handles.push_back(ax);
}
- add_lines(lines, SpatialEditorGizmos::singleton->visibility_notifier_material);
+ add_lines(lines, material);
//add_unscaled_billboard(SpatialEditorGizmos::singleton->visi,0.05);
add_collision_segments(lines);
add_handles(handles);
@@ -2238,7 +2385,10 @@ void ParticlesGizmo::redraw() {
lines.push_back(center + ax);
}
- add_lines(lines, SpatialEditorGizmos::singleton->particles_material);
+ Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/particles");
+ Ref<Material> material = create_material("particles_material", gizmo_color);
+
+ add_lines(lines, material);
add_collision_segments(lines);
//add_unscaled_billboard(SpatialEditorGizmos::singleton->visi,0.05);
add_handles(handles);
@@ -2384,8 +2534,15 @@ void ReflectionProbeGizmo::redraw() {
lines.push_back(orig_handle);
}
- add_lines(lines, SpatialEditorGizmos::singleton->reflection_probe_material);
- add_lines(internal_lines, SpatialEditorGizmos::singleton->reflection_probe_material_internal);
+ Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/reflection_probe");
+ Ref<Material> material = create_material("reflection_probe_material", gizmo_color);
+
+ Color gizmo_color_internal = gizmo_color;
+ gizmo_color_internal.a = 0.5;
+ Ref<Material> material_internal = create_material("reflection_internal_material", gizmo_color_internal);
+
+ add_lines(lines, material);
+ add_lines(internal_lines, material_internal);
//add_unscaled_billboard(SpatialEditorGizmos::singleton->visi,0.05);
add_collision_segments(lines);
add_handles(handles);
@@ -2458,6 +2615,12 @@ void GIProbeGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_can
void GIProbeGizmo::redraw() {
+ Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/gi_probe");
+ Ref<Material> material = create_material("gi_probe_material", gizmo_color);
+ Color gizmo_color_internal = gizmo_color;
+ gizmo_color_internal.a = 0.1;
+ Ref<Material> material_internal = create_material("gi_probe_internal_material", gizmo_color_internal);
+
clear();
Vector<Vector3> lines;
@@ -2476,7 +2639,7 @@ void GIProbeGizmo::redraw() {
lines.push_back(b);
}
- add_lines(lines, SpatialEditorGizmos::singleton->gi_probe_material);
+ add_lines(lines, material);
add_collision_segments(lines);
lines.clear();
@@ -2521,7 +2684,7 @@ void GIProbeGizmo::redraw() {
}
}
- add_lines(lines, SpatialEditorGizmos::singleton->gi_probe_material_internal);
+ add_lines(lines, material_internal);
Vector<Vector3> handles;
@@ -2544,6 +2707,11 @@ GIProbeGizmo::GIProbeGizmo(GIProbe *p_probe) {
void NavigationMeshSpatialGizmo::redraw() {
+ Ref<Material> edge_material = create_material("navigation_material", EDITOR_GET("editors/3d_gizmos/gizmo_colors/navigation_edge"));
+ Ref<Material> edge_material_disabled = create_material("navigation_material", EDITOR_GET("editors/3d_gizmos/gizmo_colors/navigation_edge_disabled"));
+ Ref<Material> solid_material = create_material("navigation_material", EDITOR_GET("editors/3d_gizmos/gizmo_colors/navigation_solid"));
+ Ref<Material> solid_material_disabled = create_material("navigation_material", EDITOR_GET("editors/3d_gizmos/gizmo_colors/navigation_solid_disabled"));
+
clear();
Ref<NavigationMesh> navmeshie = navmesh->get_navigation_mesh();
if (navmeshie.is_null())
@@ -2616,14 +2784,14 @@ void NavigationMeshSpatialGizmo::redraw() {
tmesh->create(tmeshfaces);
if (lines.size())
- add_lines(lines, navmesh->is_enabled() ? SpatialEditorGizmos::singleton->navmesh_edge_material : SpatialEditorGizmos::singleton->navmesh_edge_material_disabled);
+ add_lines(lines, navmesh->is_enabled() ? edge_material : edge_material_disabled);
add_collision_triangles(tmesh);
Ref<ArrayMesh> m = memnew(ArrayMesh);
Array a;
a.resize(Mesh::ARRAY_MAX);
a[0] = tmeshfaces;
m->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, a);
- m->surface_set_material(0, navmesh->is_enabled() ? SpatialEditorGizmos::singleton->navmesh_solid_material : SpatialEditorGizmos::singleton->navmesh_solid_material_disabled);
+ m->surface_set_material(0, navmesh->is_enabled() ? solid_material : solid_material_disabled);
add_mesh(m);
add_collision_segments(lines);
}
@@ -2650,7 +2818,10 @@ void PinJointSpatialGizmo::redraw() {
cursor_points.push_back(Vector3(0, 0, +cs));
cursor_points.push_back(Vector3(0, 0, -cs));
add_collision_segments(cursor_points);
- add_lines(cursor_points, SpatialEditorGizmos::singleton->joint_material);
+
+ Ref<Material> material = create_material("joint_material", EDITOR_GET("editors/3d_gizmos/gizmo_colors/joint"));
+
+ add_lines(cursor_points, material);
}
PinJointSpatialGizmo::PinJointSpatialGizmo(PinJoint *p_p3d) {
@@ -2720,8 +2891,11 @@ void HingeJointSpatialGizmo::redraw() {
cursor_points.push_back(to);
}
}
+
+ Ref<Material> material = create_material("joint_material", EDITOR_GET("editors/3d_gizmos/gizmo_colors/joint"));
+
add_collision_segments(cursor_points);
- add_lines(cursor_points, SpatialEditorGizmos::singleton->joint_material);
+ add_lines(cursor_points, material);
}
HingeJointSpatialGizmo::HingeJointSpatialGizmo(HingeJoint *p_p3d) {
@@ -2824,8 +2998,11 @@ void SliderJointSpatialGizmo::redraw() {
cursor_points.push_back(to);
}
}
+
+ Ref<Material> material = create_material("joint_material", EDITOR_GET("editors/3d_gizmos/gizmo_colors/joint"));
+
add_collision_segments(cursor_points);
- add_lines(cursor_points, SpatialEditorGizmos::singleton->joint_material);
+ add_lines(cursor_points, material);
}
SliderJointSpatialGizmo::SliderJointSpatialGizmo(SliderJoint *p_p3d) {
@@ -2896,8 +3073,9 @@ void ConeTwistJointSpatialGizmo::redraw() {
points.push_back(Vector3(cn, b.x, b.y));
}
+ Ref<Material> material = create_material("joint_material", EDITOR_GET("editors/3d_gizmos/gizmo_colors/joint"));
add_collision_segments(points);
- add_lines(points, SpatialEditorGizmos::singleton->joint_material);
+ add_lines(points, material);
}
ConeTwistJointSpatialGizmo::ConeTwistJointSpatialGizmo(ConeTwistJoint *p_p3d) {
@@ -3080,8 +3258,9 @@ void Generic6DOFJointSpatialGizmo::redraw() {
#undef ADD_VTX
#undef SET_VTX
+ Ref<Material> material = create_material("joint_material", EDITOR_GET("editors/3d_gizmos/gizmo_colors/joint"));
add_collision_segments(cursor_points);
- add_lines(cursor_points, SpatialEditorGizmos::singleton->joint_material);
+ add_lines(cursor_points, material);
}
Generic6DOFJointSpatialGizmo::Generic6DOFJointSpatialGizmo(Generic6DOFJoint *p_p3d) {
@@ -3128,11 +3307,11 @@ Ref<SpatialEditorGizmo> SpatialEditorGizmos::get_gizmo(Spatial *p_spatial) {
return misg;
}
- if (Object::cast_to<Room>(p_spatial)) {
+ /*if (Object::cast_to<Room>(p_spatial)) {
Ref<RoomSpatialGizmo> misg = memnew(RoomSpatialGizmo(Object::cast_to<Room>(p_spatial)));
return misg;
- }
+ }*/
if (Object::cast_to<NavigationMeshInstance>(p_spatial)) {
@@ -3145,13 +3324,13 @@ Ref<SpatialEditorGizmo> SpatialEditorGizmos::get_gizmo(Spatial *p_spatial) {
Ref<RayCastSpatialGizmo> misg = memnew(RayCastSpatialGizmo(Object::cast_to<RayCast>(p_spatial)));
return misg;
}
-
+ /*
if (Object::cast_to<Portal>(p_spatial)) {
Ref<PortalSpatialGizmo> misg = memnew(PortalSpatialGizmo(Object::cast_to<Portal>(p_spatial)));
return misg;
}
-
+*/
if (Object::cast_to<CollisionShape>(p_spatial)) {
Ref<CollisionShapeSpatialGizmo> misg = memnew(CollisionShapeSpatialGizmo(Object::cast_to<CollisionShape>(p_spatial)));
@@ -3231,35 +3410,13 @@ Ref<SpatialEditorGizmo> SpatialEditorGizmos::get_gizmo(Spatial *p_spatial) {
return Ref<SpatialEditorGizmo>();
}
-Ref<SpatialMaterial> SpatialEditorGizmos::create_line_material(const Color &p_base_color) {
-
- Ref<SpatialMaterial> line_material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
- line_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
- line_material->set_line_width(3.0);
- line_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
- //line_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
- //->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
- line_material->set_albedo(p_base_color);
-
- return line_material;
-}
-
-Ref<SpatialMaterial> SpatialEditorGizmos::create_solid_material(const Color &p_base_color) {
-
- Ref<SpatialMaterial> line_material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
- line_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
- line_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
- line_material->set_albedo(p_base_color);
-
- return line_material;
-}
-
SpatialEditorGizmos::SpatialEditorGizmos() {
singleton = this;
handle_material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
handle_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
+ handle_material->set_flag(SpatialMaterial::FLAG_ONTOP, true);
handle_material->set_albedo(Color(0.8, 0.8, 0.8));
handle_material_billboard = handle_material->duplicate();
handle_material_billboard->set_billboard_mode(SpatialMaterial::BILLBOARD_ENABLED);
@@ -3274,9 +3431,29 @@ SpatialEditorGizmos::SpatialEditorGizmos() {
handle2_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
handle2_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
handle2_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
+ handle2_material->set_flag(SpatialMaterial::FLAG_ONTOP, true);
handle2_material_billboard = handle2_material->duplicate();
handle2_material_billboard->set_billboard_mode(SpatialMaterial::BILLBOARD_ENABLED);
-
+ handle2_material_billboard->set_billboard_mode(SpatialMaterial::BILLBOARD_ENABLED);
+ handle2_material_billboard->set_flag(SpatialMaterial::FLAG_ONTOP, true);
+
+ EDITOR_DEF("editors/3d_gizmos/gizmo_colors/light", Color(1, 1, 0.2));
+ EDITOR_DEF("editors/3d_gizmos/gizmo_colors/stream_player_3d", Color(0.4, 0.8, 1));
+ EDITOR_DEF("editors/3d_gizmos/gizmo_colors/camera", Color(0.8, 0.4, 0.8));
+ EDITOR_DEF("editors/3d_gizmos/gizmo_colors/skeleton", Color(1, 0.8, 0.4));
+ EDITOR_DEF("editors/3d_gizmos/gizmo_colors/visibility_notifier", Color(0.8, 0.5, 0.7));
+ EDITOR_DEF("editors/3d_gizmos/gizmo_colors/particles", Color(0.8, 0.7, 0.4));
+ EDITOR_DEF("editors/3d_gizmos/gizmo_colors/reflection_probe", Color(0.6, 1, 0.5));
+ EDITOR_DEF("editors/3d_gizmos/gizmo_colors/gi_probe", Color(0.5, 1, 0.6));
+ EDITOR_DEF("editors/3d_gizmos/gizmo_colors/shape", Color(0.5, 0.7, 1));
+ EDITOR_DEF("editors/3d_gizmos/gizmo_colors/joint", Color(0.5, 0.8, 1));
+ EDITOR_DEF("editors/3d_gizmos/gizmo_colors/navigation_edge", Color(0.5, 1, 1));
+ EDITOR_DEF("editors/3d_gizmos/gizmo_colors/navigation_edge_disabled", Color(0.7, 0.7, 0.7));
+ EDITOR_DEF("editors/3d_gizmos/gizmo_colors/navigation_solid", Color(0.5, 1, 1, 0.4));
+ EDITOR_DEF("editors/3d_gizmos/gizmo_colors/navigation_solid_disabled", Color(0.7, 0.7, 0.7, 0.4));
+ EDITOR_DEF("editors/3d_gizmos/gizmo_colors/instanced", Color(0.7, 0.7, 0.7, 0.5));
+
+#if 0
light_material = create_line_material(Color(1, 1, 0.2));
light_material_omni = create_line_material(Color(1, 1, 0.2));
light_material_omni->set_billboard_mode(SpatialMaterial::BILLBOARD_ENABLED);
@@ -3289,6 +3466,7 @@ SpatialEditorGizmos::SpatialEditorGizmos() {
light_material_omni_icon->set_albedo(Color(1, 1, 1, 0.9));
light_material_omni_icon->set_texture(SpatialMaterial::TEXTURE_ALBEDO, SpatialEditor::get_singleton()->get_icon("GizmoLight", "EditorIcons"));
light_material_omni_icon->set_flag(SpatialMaterial::FLAG_FIXED_SIZE, true);
+ light_material_omni_icon->set_billboard_mode(SpatialMaterial::BILLBOARD_ENABLED);
light_material_directional_icon = Ref<SpatialMaterial>(memnew(SpatialMaterial));
light_material_directional_icon->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
@@ -3297,6 +3475,8 @@ SpatialEditorGizmos::SpatialEditorGizmos() {
light_material_directional_icon->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
light_material_directional_icon->set_albedo(Color(1, 1, 1, 0.9));
light_material_directional_icon->set_texture(SpatialMaterial::TEXTURE_ALBEDO, SpatialEditor::get_singleton()->get_icon("GizmoDirectionalLight", "EditorIcons"));
+ light_material_directional_icon->set_billboard_mode(SpatialMaterial::BILLBOARD_ENABLED);
+ light_material_directional_icon->set_depth_scale(1);
camera_material = create_line_material(Color(1.0, 0.5, 1.0));
@@ -3463,4 +3643,62 @@ SpatialEditorGizmos::SpatialEditorGizmos() {
}
shape_material = create_line_material(Color(0.2, 1, 1.0));
+#endif
+
+ pos3d_mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
+ {
+
+ PoolVector<Vector3> cursor_points;
+ PoolVector<Color> cursor_colors;
+ float cs = 0.25;
+ cursor_points.push_back(Vector3(+cs, 0, 0));
+ cursor_points.push_back(Vector3(-cs, 0, 0));
+ cursor_points.push_back(Vector3(0, +cs, 0));
+ cursor_points.push_back(Vector3(0, -cs, 0));
+ cursor_points.push_back(Vector3(0, 0, +cs));
+ cursor_points.push_back(Vector3(0, 0, -cs));
+ cursor_colors.push_back(Color(1, 0.5, 0.5, 0.7));
+ cursor_colors.push_back(Color(1, 0.5, 0.5, 0.7));
+ cursor_colors.push_back(Color(0.5, 1, 0.5, 0.7));
+ cursor_colors.push_back(Color(0.5, 1, 0.5, 0.7));
+ cursor_colors.push_back(Color(0.5, 0.5, 1, 0.7));
+ cursor_colors.push_back(Color(0.5, 0.5, 1, 0.7));
+
+ Ref<SpatialMaterial> mat = memnew(SpatialMaterial);
+ mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
+ mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
+ mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
+ mat->set_line_width(3);
+ Array d;
+ d.resize(VS::ARRAY_MAX);
+ d[Mesh::ARRAY_VERTEX] = cursor_points;
+ d[Mesh::ARRAY_COLOR] = cursor_colors;
+ pos3d_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_LINES, d);
+ pos3d_mesh->surface_set_material(0, mat);
+ }
+
+ listener_line_mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
+ {
+
+ PoolVector<Vector3> cursor_points;
+ PoolVector<Color> cursor_colors;
+ cursor_points.push_back(Vector3(0, 0, 0));
+ cursor_points.push_back(Vector3(0, 0, -1.0));
+ cursor_colors.push_back(Color(0.5, 0.5, 0.5, 0.7));
+ cursor_colors.push_back(Color(0.5, 0.5, 0.5, 0.7));
+
+ Ref<SpatialMaterial> mat = memnew(SpatialMaterial);
+ mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
+ mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
+ mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
+ mat->set_line_width(3);
+ Array d;
+ d.resize(VS::ARRAY_MAX);
+ d[Mesh::ARRAY_VERTEX] = cursor_points;
+ d[Mesh::ARRAY_COLOR] = cursor_colors;
+ listener_line_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_LINES, d);
+ listener_line_mesh->surface_set_material(0, mat);
+ }
}
diff --git a/editor/spatial_editor_gizmos.h b/editor/spatial_editor_gizmos.h
index 4769e5d765..fa5484c3d9 100644
--- a/editor/spatial_editor_gizmos.h
+++ b/editor/spatial_editor_gizmos.h
@@ -107,6 +107,9 @@ protected:
static void _bind_methods();
+ Ref<SpatialMaterial> create_material(const String &p_name, const Color &p_color, bool p_billboard = false, bool p_on_top = false, bool p_use_vertex_color = false);
+ Ref<SpatialMaterial> create_icon_material(const String &p_name, const Ref<Texture> &p_texture, bool p_on_top = false, const Color &p_albedo = Color(1, 1, 1, 1));
+
public:
virtual Vector3 get_handle_pos(int p_idx) const;
virtual bool intersect_frustum(const Camera *p_camera, const Vector<Plane> &p_frustum);
@@ -117,6 +120,8 @@ public:
void transform();
virtual void redraw();
void free();
+ virtual bool is_editable() const;
+ virtual bool can_draw() const;
EditorSpatialGizmo();
~EditorSpatialGizmo();
@@ -177,6 +182,7 @@ class MeshInstanceSpatialGizmo : public EditorSpatialGizmo {
MeshInstance *mesh;
public:
+ virtual bool can_draw() const;
void redraw();
MeshInstanceSpatialGizmo(MeshInstance *p_mesh = NULL);
};
@@ -203,25 +209,7 @@ public:
SkeletonSpatialGizmo(Skeleton *p_skel = NULL);
};
-class RoomSpatialGizmo : public EditorSpatialGizmo {
-
- GDCLASS(RoomSpatialGizmo, EditorSpatialGizmo);
-
- struct _EdgeKey {
-
- Vector3 from;
- Vector3 to;
-
- bool operator<(const _EdgeKey &p_with) const { return from == p_with.from ? to < p_with.to : from < p_with.from; }
- };
-
- Room *room;
-
-public:
- void redraw();
- RoomSpatialGizmo(Room *p_room = NULL);
-};
-
+#if 0
class PortalSpatialGizmo : public EditorSpatialGizmo {
GDCLASS(PortalSpatialGizmo, EditorSpatialGizmo);
@@ -232,6 +220,7 @@ public:
void redraw();
PortalSpatialGizmo(Portal *p_portal = NULL);
};
+#endif
class VisibilityNotifierGizmo : public EditorSpatialGizmo {
@@ -420,51 +409,19 @@ public:
};
class SpatialEditorGizmos {
+
public:
- Ref<SpatialMaterial> create_line_material(const Color &p_base_color);
- Ref<SpatialMaterial> create_solid_material(const Color &p_base_color);
+ HashMap<String, Ref<SpatialMaterial> > material_cache;
+
Ref<SpatialMaterial> handle2_material;
Ref<SpatialMaterial> handle2_material_billboard;
Ref<SpatialMaterial> handle_material;
Ref<SpatialMaterial> handle_material_billboard;
- Ref<SpatialMaterial> light_material;
- Ref<SpatialMaterial> light_material_omni;
- Ref<SpatialMaterial> light_material_omni_icon;
- Ref<SpatialMaterial> light_material_directional_icon;
- Ref<SpatialMaterial> camera_material;
- Ref<SpatialMaterial> skeleton_material;
- Ref<SpatialMaterial> reflection_probe_material;
- Ref<SpatialMaterial> reflection_probe_material_internal;
- Ref<SpatialMaterial> gi_probe_material;
- Ref<SpatialMaterial> gi_probe_material_internal;
- Ref<SpatialMaterial> room_material;
- Ref<SpatialMaterial> portal_material;
- Ref<SpatialMaterial> raycast_material;
- Ref<SpatialMaterial> visibility_notifier_material;
- Ref<SpatialMaterial> particles_material;
- Ref<SpatialMaterial> car_wheel_material;
- Ref<SpatialMaterial> joint_material;
-
- Ref<SpatialMaterial> navmesh_edge_material;
- Ref<SpatialMaterial> navmesh_solid_material;
- Ref<SpatialMaterial> navmesh_edge_material_disabled;
- Ref<SpatialMaterial> navmesh_solid_material_disabled;
-
- Ref<SpatialMaterial> listener_icon;
-
- Ref<SpatialMaterial> sample_player_icon;
- Ref<SpatialMaterial> stream_player_icon;
- Ref<SpatialMaterial> visibility_notifier_icon;
-
- Ref<SpatialMaterial> shape_material;
Ref<Texture> handle_t;
-
Ref<ArrayMesh> pos3d_mesh;
Ref<ArrayMesh> listener_line_mesh;
static SpatialEditorGizmos *singleton;
- Ref<TriangleMesh> test_cube_tm;
-
Ref<SpatialEditorGizmo> get_gizmo(Spatial *p_spatial);
SpatialEditorGizmos();
diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp
index fe5936b715..b444664878 100644
--- a/modules/gridmap/grid_map.cpp
+++ b/modules/gridmap/grid_map.cpp
@@ -96,25 +96,6 @@ bool GridMap::_set(const StringName &p_name, const Variant &p_value) {
}
_recreate_octant_data();
- } else if (name.begins_with("areas/")) {
- int which = name.get_slicec('/', 1).to_int();
- String what = name.get_slicec('/', 2);
- if (what == "bounds") {
- ERR_FAIL_COND_V(area_map.has(which), false);
- create_area(which, p_value);
- return true;
- }
-
- ERR_FAIL_COND_V(!area_map.has(which), false);
-
- if (what == "name")
- area_set_name(which, p_value);
- else if (what == "disable_distance")
- area_set_portal_disable_distance(which, p_value);
- else if (what == "exterior_portal")
- area_set_portal_disable_color(which, p_value);
- else
- return false;
} else
return false;
@@ -158,19 +139,6 @@ bool GridMap::_get(const StringName &p_name, Variant &r_ret) const {
d["cells"] = cells;
r_ret = d;
- } else if (name.begins_with("areas/")) {
- int which = name.get_slicec('/', 1).to_int();
- String what = name.get_slicec('/', 2);
- if (what == "bounds")
- r_ret = area_get_bounds(which);
- else if (what == "name")
- r_ret = area_get_name(which);
- else if (what == "disable_distance")
- r_ret = area_get_portal_disable_distance(which);
- else if (what == "exterior_portal")
- r_ret = area_is_exterior_portal(which);
- else
- return false;
} else
return false;
@@ -189,16 +157,6 @@ void GridMap::_get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::REAL, "cell_scale"));
p_list->push_back(PropertyInfo(Variant::DICTIONARY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE));
-
- for (const Map<int, Area *>::Element *E = area_map.front(); E; E = E->next()) {
-
- String base = "areas/" + itos(E->key()) + "/";
- p_list->push_back(PropertyInfo(Variant::RECT3, base + "bounds", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE));
- p_list->push_back(PropertyInfo(Variant::STRING, base + "name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE));
- p_list->push_back(PropertyInfo(Variant::REAL, base + "disable_distance", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE));
- p_list->push_back(PropertyInfo(Variant::COLOR, base + "disable_color", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE));
- p_list->push_back(PropertyInfo(Variant::BOOL, base + "exterior_portal", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE));
- }
}
void GridMap::set_theme(const Ref<MeshLibrary> &p_theme) {
@@ -268,20 +226,6 @@ bool GridMap::get_center_z() const {
return center_z;
}
-int GridMap::_find_area(const IndexKey &p_pos) const {
-
- for (const Map<int, Area *>::Element *E = area_map.front(); E; E = E->next()) {
- //this should somehow be faster...
- const Area &a = *E->get();
- if (p_pos.x >= a.from.x && p_pos.x < a.to.x &&
- p_pos.y >= a.from.y && p_pos.y < a.to.y &&
- p_pos.z >= a.from.z && p_pos.z < a.to.z) {
- return E->key();
- }
- }
-
- return 0;
-}
void GridMap::set_cell_item(int p_x, int p_y, int p_z, int p_item, int p_rot) {
ERR_FAIL_INDEX(ABS(p_x), 1 << 20);
@@ -297,7 +241,6 @@ void GridMap::set_cell_item(int p_x, int p_y, int p_z, int p_item, int p_rot) {
ok.x = p_x / octant_size;
ok.y = p_y / octant_size;
ok.z = p_z / octant_size;
- ok.area = _find_area(key);
if (cell_map.has(key)) {
@@ -485,19 +428,12 @@ void GridMap::_octant_enter_world(const OctantKey &p_key) {
if (g.collision_debug_instance.is_valid()) {
VS::get_singleton()->instance_set_scenario(g.collision_debug_instance, get_world()->get_scenario());
VS::get_singleton()->instance_set_transform(g.collision_debug_instance, get_global_transform());
- if (area_map.has(p_key.area)) {
- VS::get_singleton()->instance_set_room(g.collision_debug_instance, area_map[p_key.area]->instance);
- }
}
for (Map<int, Octant::ItemInstances>::Element *E = g.items.front(); E; E = E->next()) {
VS::get_singleton()->instance_set_scenario(E->get().multimesh_instance, get_world()->get_scenario());
VS::get_singleton()->instance_set_transform(E->get().multimesh_instance, get_global_transform());
//print_line("INSTANCEPOS: "+get_global_transform());
-
- if (area_map.has(p_key.area)) {
- VS::get_singleton()->instance_set_room(E->get().multimesh_instance, area_map[p_key.area]->instance);
- }
}
}
@@ -655,7 +591,6 @@ void GridMap::_octant_exit_world(const OctantKey &p_key) {
if (g.collision_debug_instance.is_valid()) {
- VS::get_singleton()->instance_set_room(g.collision_debug_instance, RID());
VS::get_singleton()->instance_set_scenario(g.collision_debug_instance, RID());
}
@@ -663,7 +598,6 @@ void GridMap::_octant_exit_world(const OctantKey &p_key) {
VS::get_singleton()->instance_set_scenario(E->get().multimesh_instance, RID());
//VS::get_singleton()->instance_set_transform(E->get().multimesh_instance,get_global_transform());
- VS::get_singleton()->instance_set_room(E->get().multimesh_instance, RID());
}
}
@@ -673,8 +607,6 @@ void GridMap::_notification(int p_what) {
case NOTIFICATION_ENTER_WORLD: {
- _update_area_instances();
-
for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) {
//IndexKey ik;
//ik.key = E->key().indexkey;
@@ -761,14 +693,14 @@ void GridMap::_queue_dirty_map() {
void GridMap::_recreate_octant_data() {
Map<IndexKey, Cell> cell_copy = cell_map;
- _clear_internal(true);
+ _clear_internal();
for (Map<IndexKey, Cell>::Element *E = cell_copy.front(); E; E = E->next()) {
set_cell_item(E->key().x, E->key().y, E->key().z, E->get().item, E->get().rot);
}
}
-void GridMap::_clear_internal(bool p_keep_areas) {
+void GridMap::_clear_internal() {
for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) {
if (is_inside_world())
@@ -790,20 +722,6 @@ void GridMap::_clear_internal(bool p_keep_areas) {
octant_map.clear();
cell_map.clear();
-
- if (p_keep_areas)
- return;
-
- for (Map<int, Area *>::Element *E = area_map.front(); E; E = E->next()) {
-
- VS::get_singleton()->free(E->get()->base_portal);
- VS::get_singleton()->free(E->get()->instance);
- for (int i = 0; i < E->get()->portals.size(); i++) {
- VS::get_singleton()->free(E->get()->portals[i].instance);
- }
-
- memdelete(E->get());
- }
}
void GridMap::clear() {
@@ -856,19 +774,6 @@ void GridMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_clip", "enabled", "clipabove", "floor", "axis"), &GridMap::set_clip, DEFVAL(true), DEFVAL(0), DEFVAL(Vector3::AXIS_X));
- ClassDB::bind_method(D_METHOD("create_area", "id", "area"), &GridMap::create_area);
- ClassDB::bind_method(D_METHOD("area_get_bounds", "area"), &GridMap::area_get_bounds);
- ClassDB::bind_method(D_METHOD("area_set_exterior_portal", "area", "enable"), &GridMap::area_set_exterior_portal);
- ClassDB::bind_method(D_METHOD("area_set_name", "area", "name"), &GridMap::area_set_name);
- ClassDB::bind_method(D_METHOD("area_get_name", "area"), &GridMap::area_get_name);
- ClassDB::bind_method(D_METHOD("area_is_exterior_portal", "area"), &GridMap::area_is_exterior_portal);
- ClassDB::bind_method(D_METHOD("area_set_portal_disable_distance", "area", "distance"), &GridMap::area_set_portal_disable_distance);
- ClassDB::bind_method(D_METHOD("area_get_portal_disable_distance", "area"), &GridMap::area_get_portal_disable_distance);
- ClassDB::bind_method(D_METHOD("area_set_portal_disable_color", "area", "color"), &GridMap::area_set_portal_disable_color);
- ClassDB::bind_method(D_METHOD("area_get_portal_disable_color", "area"), &GridMap::area_get_portal_disable_color);
- ClassDB::bind_method(D_METHOD("erase_area", "area"), &GridMap::erase_area);
- ClassDB::bind_method(D_METHOD("get_unused_area_id"), &GridMap::get_unused_area_id);
-
ClassDB::bind_method(D_METHOD("clear"), &GridMap::clear);
ClassDB::bind_method(D_METHOD("get_meshes"), &GridMap::get_meshes);
@@ -898,334 +803,6 @@ void GridMap::set_clip(bool p_enabled, bool p_clip_above, int p_floor, Vector3::
_update_dirty_map_callback();
}
-void GridMap::_update_areas() {
-
- //clear the portals
- for (Map<int, Area *>::Element *E = area_map.front(); E; E = E->next()) {
- //this should somehow be faster...
- Area &a = *E->get();
- a.portals.clear();
- if (a.instance.is_valid()) {
- VisualServer::get_singleton()->free(a.instance);
- a.instance = RID();
- }
- }
-
- //test all areas against all areas and create portals - this sucks (slow :( )
- for (Map<int, Area *>::Element *E = area_map.front(); E; E = E->next()) {
- Area &a = *E->get();
- if (a.exterior_portal) //that's pretty much all it does... yes it is
- continue;
- Vector3 from_a(a.from.x, a.from.y, a.from.z);
- Vector3 to_a(a.to.x, a.to.y, a.to.z);
-
- for (Map<int, Area *>::Element *F = area_map.front(); F; F = F->next()) {
-
- Area &b = *F->get();
- Vector3 from_b(b.from.x, b.from.y, b.from.z);
- Vector3 to_b(b.to.x, b.to.y, b.to.z);
-
- // initially test intersection and discards
- int axis = -1;
- float sign = 0;
- bool valid = true;
- Vector3 axmin, axmax;
-
- for (int i = 0; i < 3; i++) {
-
- if (from_a[i] == to_b[i]) {
-
- if (axis != -1) {
- valid = false;
- break;
- }
-
- axis = i;
- sign = -1;
- } else if (from_b[i] == to_a[i]) {
-
- if (axis != -1) {
- valid = false;
- break;
- }
- axis = i;
- sign = +1;
- }
-
- if (from_a[i] > to_b[i] || to_a[i] < from_b[i]) {
- valid = false;
- break;
- } else {
-
- axmin[i] = (from_a[i] > from_b[i]) ? from_a[i] : from_b[i];
- axmax[i] = (to_a[i] < to_b[i]) ? to_a[i] : to_b[i];
- }
- }
-
- if (axis == -1 || !valid)
- continue;
-
- Transform xf;
-
- for (int i = 0; i < 3; i++) {
-
- int ax = (axis + i) % 3;
- Vector3 axis_vec;
- float scale = (i == 0) ? sign : ((axmax[ax] - axmin[ax]) * cell_size);
- axis_vec[ax] = scale;
- xf.basis.set_axis((2 + i) % 3, axis_vec);
- xf.origin[i] = axmin[i] * cell_size;
- }
-
- Area::Portal portal;
- portal.xform = xf;
- a.portals.push_back(portal);
- }
- }
-
- _update_area_instances();
-}
-
-void GridMap::_update_area_instances() {
-
- Transform base_xform;
- if (_in_tree)
- base_xform = get_global_transform();
-
- for (Map<int, Area *>::Element *E = area_map.front(); E; E = E->next()) {
- //this should somehow be faster...
- Area &a = *E->get();
- if (a.instance.is_valid() != _in_tree) {
-
- if (!_in_tree) {
-
- for (int i = 0; i < a.portals.size(); i++) {
-
- Area::Portal &p = a.portals[i];
- ERR_CONTINUE(!p.instance.is_valid());
- VisualServer::get_singleton()->free(p.instance);
- p.instance = RID();
- }
-
- VisualServer::get_singleton()->free(a.instance);
- a.instance = RID();
-
- } else {
-
- //a.instance = VisualServer::get_singleton()->instance_create2(base_room,get_world()->get_scenario());
- for (int i = 0; i < a.portals.size(); i++) {
-
- Area::Portal &p = a.portals[i];
- ERR_CONTINUE(p.instance.is_valid());
- p.instance = VisualServer::get_singleton()->instance_create2(a.base_portal, get_world()->get_scenario());
- VisualServer::get_singleton()->instance_set_room(p.instance, a.instance);
- }
- }
- }
-
- if (a.instance.is_valid()) {
- Transform xform;
-
- Vector3 from_a(a.from.x, a.from.y, a.from.z);
- Vector3 to_a(a.to.x, a.to.y, a.to.z);
-
- for (int i = 0; i < 3; i++) {
- xform.origin[i] = from_a[i] * cell_size;
- Vector3 s;
- s[i] = (to_a[i] - from_a[i]) * cell_size;
- xform.basis.set_axis(i, s);
- }
-
- VisualServer::get_singleton()->instance_set_transform(a.instance, base_xform * xform);
-
- for (int i = 0; i < a.portals.size(); i++) {
-
- Area::Portal &p = a.portals[i];
- ERR_CONTINUE(!p.instance.is_valid());
-
- VisualServer::get_singleton()->instance_set_transform(p.instance, base_xform * xform);
- }
- }
- }
-}
-
-Error GridMap::create_area(int p_id, const Rect3 &p_area) {
-
- ERR_FAIL_COND_V(area_map.has(p_id), ERR_ALREADY_EXISTS);
- ERR_EXPLAIN("ID 0 is taken as global area, start from 1");
- ERR_FAIL_COND_V(p_id == 0, ERR_INVALID_PARAMETER);
- ERR_FAIL_COND_V(p_area.has_no_area(), ERR_INVALID_PARAMETER);
-
- // FIRST VALIDATE AREA
- IndexKey from, to;
- from.x = p_area.position.x;
- from.y = p_area.position.y;
- from.z = p_area.position.z;
- to.x = p_area.position.x + p_area.size.x;
- to.y = p_area.position.y + p_area.size.y;
- to.z = p_area.position.z + p_area.size.z;
-
- for (Map<int, Area *>::Element *E = area_map.front(); E; E = E->next()) {
- //this should somehow be faster...
- Area &a = *E->get();
-
- //does it interset with anything else?
-
- if (from.x >= a.to.x ||
- to.x <= a.from.x ||
- from.y >= a.to.y ||
- to.y <= a.from.y ||
- from.z >= a.to.z ||
- to.z <= a.from.z) {
-
- // all good
- } else {
-
- return ERR_INVALID_PARAMETER;
- }
- }
-
- Area *area = memnew(Area);
- area->from = from;
- area->to = to;
- area->portal_disable_distance = 0;
- area->exterior_portal = false;
- area->name = "Area " + itos(p_id);
- area_map[p_id] = area;
- _recreate_octant_data();
- return OK;
-}
-
-Rect3 GridMap::area_get_bounds(int p_area) const {
-
- ERR_FAIL_COND_V(!area_map.has(p_area), Rect3());
-
- const Area *a = area_map[p_area];
- Rect3 aabb;
- aabb.position = Vector3(a->from.x, a->from.y, a->from.z);
- aabb.size = Vector3(a->to.x, a->to.y, a->to.z) - aabb.position;
-
- return aabb;
-}
-
-void GridMap::area_set_name(int p_area, const String &p_name) {
-
- ERR_FAIL_COND(!area_map.has(p_area));
-
- Area *a = area_map[p_area];
- a->name = p_name;
-}
-
-String GridMap::area_get_name(int p_area) const {
-
- ERR_FAIL_COND_V(!area_map.has(p_area), "");
-
- const Area *a = area_map[p_area];
- return a->name;
-}
-
-void GridMap::area_set_exterior_portal(int p_area, bool p_enable) {
-
- ERR_FAIL_COND(!area_map.has(p_area));
-
- Area *a = area_map[p_area];
- if (a->exterior_portal == p_enable)
- return;
- a->exterior_portal = p_enable;
-
- _recreate_octant_data();
-}
-
-bool GridMap::area_is_exterior_portal(int p_area) const {
-
- ERR_FAIL_COND_V(!area_map.has(p_area), false);
-
- const Area *a = area_map[p_area];
- return a->exterior_portal;
-}
-
-void GridMap::area_set_portal_disable_distance(int p_area, float p_distance) {
-
- ERR_FAIL_COND(!area_map.has(p_area));
-
- Area *a = area_map[p_area];
- a->portal_disable_distance = p_distance;
-}
-
-float GridMap::area_get_portal_disable_distance(int p_area) const {
-
- ERR_FAIL_COND_V(!area_map.has(p_area), 0);
-
- const Area *a = area_map[p_area];
- return a->portal_disable_distance;
-}
-
-void GridMap::area_set_portal_disable_color(int p_area, Color p_color) {
-
- ERR_FAIL_COND(!area_map.has(p_area));
-
- Area *a = area_map[p_area];
- a->portal_disable_color = p_color;
-}
-
-Color GridMap::area_get_portal_disable_color(int p_area) const {
-
- ERR_FAIL_COND_V(!area_map.has(p_area), Color());
-
- const Area *a = area_map[p_area];
- return a->portal_disable_color;
-}
-
-void GridMap::get_area_list(List<int> *p_areas) const {
-
- for (const Map<int, Area *>::Element *E = area_map.front(); E; E = E->next()) {
-
- p_areas->push_back(E->key());
- }
-}
-
-GridMap::Area::Portal::~Portal() {
-
- if (instance.is_valid())
- VisualServer::get_singleton()->free(instance);
-}
-
-GridMap::Area::Area() {
-
- base_portal = VisualServer::get_singleton()->portal_create();
- Vector<Point2> points;
- points.push_back(Point2(0, 1));
- points.push_back(Point2(1, 1));
- points.push_back(Point2(1, 0));
- points.push_back(Point2(0, 0));
- VisualServer::get_singleton()->portal_set_shape(base_portal, points);
-}
-
-GridMap::Area::~Area() {
-
- if (instance.is_valid())
- VisualServer::get_singleton()->free(instance);
- VisualServer::get_singleton()->free(base_portal);
-}
-
-void GridMap::erase_area(int p_area) {
-
- ERR_FAIL_COND(!area_map.has(p_area));
-
- Area *a = area_map[p_area];
- memdelete(a);
- area_map.erase(p_area);
- _recreate_octant_data();
-}
-
-int GridMap::get_unused_area_id() const {
-
- if (area_map.empty())
- return 1;
- else
- return area_map.back()->key() + 1;
-}
-
void GridMap::set_cell_scale(float p_scale) {
cell_scale = p_scale;
diff --git a/modules/gridmap/grid_map.h b/modules/gridmap/grid_map.h
index 106bf82dc2..7af1e08eb2 100644
--- a/modules/gridmap/grid_map.h
+++ b/modules/gridmap/grid_map.h
@@ -120,7 +120,7 @@ class GridMap : public Spatial {
int16_t x;
int16_t y;
int16_t z;
- int16_t area;
+ int16_t empty;
};
uint64_t key;
@@ -148,35 +148,10 @@ class GridMap : public Spatial {
int clip_floor;
Vector3::Axis clip_axis;
- /**
- * @brief An Area is something like a room: it has doors, and Octants can choose to belong to it.
- */
- struct Area {
-
- String name;
- RID base_portal;
- RID instance;
- IndexKey from;
- IndexKey to;
- struct Portal {
- Transform xform;
- RID instance;
- ~Portal();
- };
- Vector<Portal> portals;
- float portal_disable_distance;
- Color portal_disable_color;
- bool exterior_portal;
-
- Area();
- ~Area();
- };
-
Ref<MeshLibrary> theme;
Map<OctantKey, Octant *> octant_map;
Map<IndexKey, Cell> cell_map;
- Map<int, Area *> area_map;
void _recreate_octant_data();
@@ -188,8 +163,6 @@ class GridMap : public Spatial {
float param[VS::LIGHT_PARAM_MAX];
};
- _FORCE_INLINE_ int _find_area(const IndexKey &p_pos) const;
-
_FORCE_INLINE_ Vector3 _octant_get_offset(const OctantKey &p_key) const {
return Vector3(p_key.x, p_key.y, p_key.z) * cell_size * octant_size;
@@ -208,10 +181,7 @@ class GridMap : public Spatial {
void resource_changed(const RES &p_res);
- void _update_areas();
- void _update_area_instances();
-
- void _clear_internal(bool p_keep_areas = false);
+ void _clear_internal();
protected:
bool _set(const StringName &p_name, const Variant &p_value);
@@ -248,20 +218,6 @@ public:
void set_clip(bool p_enabled, bool p_clip_above = true, int p_floor = 0, Vector3::Axis p_axis = Vector3::AXIS_X);
- Error create_area(int p_id, const Rect3 &p_area);
- Rect3 area_get_bounds(int p_area) const;
- void area_set_exterior_portal(int p_area, bool p_enable);
- void area_set_name(int p_area, const String &p_name);
- String area_get_name(int p_area) const;
- bool area_is_exterior_portal(int p_area) const;
- void area_set_portal_disable_distance(int p_area, float p_distance);
- float area_get_portal_disable_distance(int p_area) const;
- void area_set_portal_disable_color(int p_area, Color p_color);
- Color area_get_portal_disable_color(int p_area) const;
- void get_area_list(List<int> *p_areas) const;
- void erase_area(int p_area);
- int get_unused_area_id() const;
-
void set_cell_scale(float p_scale);
float get_cell_scale() const;
diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp
index 5d98b0f7a7..561efb9d0f 100644
--- a/modules/gridmap/grid_map_editor_plugin.cpp
+++ b/modules/gridmap/grid_map_editor_plugin.cpp
@@ -178,30 +178,6 @@ void GridMapEditor::_menu_option(int p_option) {
int idx = options->get_popup()->get_item_index(MENU_OPTION_DUPLICATE_SELECTS);
options->get_popup()->set_item_checked(idx, !options->get_popup()->is_item_checked(idx));
} break;
- case MENU_OPTION_SELECTION_MAKE_AREA:
- case MENU_OPTION_SELECTION_MAKE_EXTERIOR_CONNECTOR: {
-
- if (!selection.active)
- break;
- int area = node->get_unused_area_id();
- Error err = node->create_area(area, Rect3(selection.begin, selection.end - selection.begin + Vector3(1, 1, 1)));
- if (err != OK) {
- }
- if (p_option == MENU_OPTION_SELECTION_MAKE_EXTERIOR_CONNECTOR) {
-
- node->area_set_exterior_portal(area, true);
- }
- _update_areas_display();
- update_areas();
-
- } break;
- case MENU_OPTION_REMOVE_AREA: {
- if (selected_area < 1)
- return;
- node->erase_area(selected_area);
- _update_areas_display();
- update_areas();
- } break;
case MENU_OPTION_SELECTION_DUPLICATE:
if (!(selection.active && input_action == INPUT_NONE))
return;
@@ -513,146 +489,96 @@ bool GridMapEditor::forward_spatial_input_event(Camera *p_camera, const Ref<Inpu
return false;
}
- if (edit_mode->get_selected() == 0) { // regular click
-
- Ref<InputEventMouseButton> mb = p_event;
-
- if (mb.is_valid()) {
-
- if (mb->get_button_index() == BUTTON_WHEEL_UP && (mb->get_command() || mb->get_shift())) {
- if (mb->is_pressed())
- floor->set_value(floor->get_value() + mb->get_factor());
-
- return true; //eaten
- } else if (mb->get_button_index() == BUTTON_WHEEL_DOWN && (mb->get_command() || mb->get_shift())) {
- if (mb->is_pressed())
- floor->set_value(floor->get_value() - mb->get_factor());
- return true;
- }
-
- if (mb->is_pressed()) {
-
- if (mb->get_button_index() == BUTTON_LEFT) {
+ Ref<InputEventMouseButton> mb = p_event;
- if (input_action == INPUT_DUPLICATE) {
-
- //paste
- _duplicate_paste();
- input_action = INPUT_NONE;
- _update_duplicate_indicator();
- } else if (mb->get_shift()) {
- input_action = INPUT_SELECT;
- } else if (mb->get_command())
- input_action = INPUT_COPY;
- else {
- input_action = INPUT_PAINT;
- set_items.clear();
- }
- } else if (mb->get_button_index() == BUTTON_RIGHT)
- if (input_action == INPUT_DUPLICATE) {
-
- input_action = INPUT_NONE;
- _update_duplicate_indicator();
- } else {
- input_action = INPUT_ERASE;
- set_items.clear();
- }
- else
- return false;
+ if (mb.is_valid()) {
- return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true);
- } else {
+ if (mb->get_button_index() == BUTTON_WHEEL_UP && (mb->get_command() || mb->get_shift())) {
+ if (mb->is_pressed())
+ floor->set_value(floor->get_value() + mb->get_factor());
- if (
- (mb->get_button_index() == BUTTON_RIGHT && input_action == INPUT_ERASE) ||
- (mb->get_button_index() == BUTTON_LEFT && input_action == INPUT_PAINT)) {
+ return true; //eaten
+ } else if (mb->get_button_index() == BUTTON_WHEEL_DOWN && (mb->get_command() || mb->get_shift())) {
+ if (mb->is_pressed())
+ floor->set_value(floor->get_value() - mb->get_factor());
+ return true;
+ }
- if (set_items.size()) {
- undo_redo->create_action(TTR("GridMap Paint"));
- for (List<SetItem>::Element *E = set_items.front(); E; E = E->next()) {
+ if (mb->is_pressed()) {
- const SetItem &si = E->get();
- undo_redo->add_do_method(node, "set_cell_item", si.pos.x, si.pos.y, si.pos.z, si.new_value, si.new_orientation);
- }
- for (List<SetItem>::Element *E = set_items.back(); E; E = E->prev()) {
+ if (mb->get_button_index() == BUTTON_LEFT) {
- const SetItem &si = E->get();
- undo_redo->add_undo_method(node, "set_cell_item", si.pos.x, si.pos.y, si.pos.z, si.old_value, si.old_orientation);
- }
+ if (input_action == INPUT_DUPLICATE) {
- undo_redo->commit_action();
- }
- set_items.clear();
+ //paste
+ _duplicate_paste();
input_action = INPUT_NONE;
- return true;
- }
-
- if (mb->get_button_index() == BUTTON_LEFT && input_action != INPUT_NONE) {
-
+ _update_duplicate_indicator();
+ } else if (mb->get_shift()) {
+ input_action = INPUT_SELECT;
+ } else if (mb->get_command())
+ input_action = INPUT_COPY;
+ else {
+ input_action = INPUT_PAINT;
set_items.clear();
- input_action = INPUT_NONE;
- return true;
}
- if (mb->get_button_index() == BUTTON_RIGHT && (input_action == INPUT_ERASE || input_action == INPUT_DUPLICATE)) {
+ } else if (mb->get_button_index() == BUTTON_RIGHT)
+ if (input_action == INPUT_DUPLICATE) {
+
input_action = INPUT_NONE;
- return true;
+ _update_duplicate_indicator();
+ } else {
+ input_action = INPUT_ERASE;
+ set_items.clear();
}
- }
- }
-
- Ref<InputEventMouseMotion> mm = p_event;
-
- if (mm.is_valid()) {
-
- return do_input_action(p_camera, mm->get_position(), false);
- }
-
- } else if (edit_mode->get_selected() == 1) {
- //area mode, select an area
+ else
+ return false;
- Ref<InputEventMouseButton> mb = p_event;
+ return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true);
+ } else {
- if (mb.is_valid()) {
+ if (
+ (mb->get_button_index() == BUTTON_RIGHT && input_action == INPUT_ERASE) ||
+ (mb->get_button_index() == BUTTON_LEFT && input_action == INPUT_PAINT)) {
- if (mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) {
+ if (set_items.size()) {
+ undo_redo->create_action("GridMap Paint");
+ for (List<SetItem>::Element *E = set_items.front(); E; E = E->next()) {
- Point2 point = mb->get_position();
-
- Camera *camera = p_camera;
- Vector3 from = camera->project_ray_origin(point);
- Vector3 normal = camera->project_ray_normal(point);
- Transform local_xform = node->get_global_transform().affine_inverse();
- from = local_xform.xform(from);
- normal = local_xform.basis.xform(normal).normalized();
+ const SetItem &si = E->get();
+ undo_redo->add_do_method(node, "set_cell_item", si.pos.x, si.pos.y, si.pos.z, si.new_value, si.new_orientation);
+ }
+ for (List<SetItem>::Element *E = set_items.back(); E; E = E->prev()) {
- List<int> areas;
- node->get_area_list(&areas);
+ const SetItem &si = E->get();
+ undo_redo->add_undo_method(node, "set_cell_item", si.pos.x, si.pos.y, si.pos.z, si.old_value, si.old_orientation);
+ }
- float min_d = 1e10;
- int min_area = -1;
+ undo_redo->commit_action();
+ }
+ set_items.clear();
+ input_action = INPUT_NONE;
+ return true;
+ }
- for (List<int>::Element *E = areas.front(); E; E = E->next()) {
+ if (mb->get_button_index() == BUTTON_LEFT && input_action != INPUT_NONE) {
- int area = E->get();
- Rect3 aabb = node->area_get_bounds(area);
- aabb.position *= node->get_cell_size();
- aabb.size *= node->get_cell_size();
+ set_items.clear();
+ input_action = INPUT_NONE;
+ return true;
+ }
+ if (mb->get_button_index() == BUTTON_RIGHT && (input_action == INPUT_ERASE || input_action == INPUT_DUPLICATE)) {
+ input_action = INPUT_NONE;
+ return true;
+ }
+ }
+ }
- Vector3 rclip, rnormal;
- if (!aabb.intersects_segment(from, from + normal * 10000, &rclip, &rnormal))
- continue;
+ Ref<InputEventMouseMotion> mm = p_event;
- float d = normal.dot(rclip);
- if (d < min_d) {
- min_d = d;
- min_area = area;
- }
- }
+ if (mm.is_valid()) {
- selected_area = min_area;
- update_areas();
- }
- }
+ return do_input_action(p_camera, mm->get_position(), false);
}
return false;
@@ -749,52 +675,6 @@ void GridMapEditor::update_pallete() {
last_theme = theme.operator->();
}
-void GridMapEditor::_area_renamed() {
-
- TreeItem *it = area_list->get_selected();
- int area = it->get_metadata(0);
- if (area < 1)
- return;
- node->area_set_name(area, it->get_text(0));
-}
-
-void GridMapEditor::_area_selected() {
-
- TreeItem *it = area_list->get_selected();
- int area = it->get_metadata(0);
- if (area < 1)
- return;
- selected_area = area;
-}
-
-void GridMapEditor::update_areas() {
-
- area_list->clear();
-
- List<int> areas;
- node->get_area_list(&areas);
-
- TreeItem *root = area_list->create_item(NULL);
- area_list->set_hide_root(true);
- TreeItem *selected = NULL;
-
- for (List<int>::Element *E = areas.front(); E; E = E->next()) {
-
- int area = E->get();
- TreeItem *ti = area_list->create_item(root);
- String name = node->area_get_name(area);
-
- ti->set_metadata(0, area);
- ti->set_text(0, name);
- ti->set_editable(0, true);
- if (area == selected_area)
- selected = ti;
- }
-
- if (selected)
- selected->select(0);
-}
-
void GridMapEditor::edit(GridMap *p_gridmap) {
node = p_gridmap;
@@ -816,13 +696,10 @@ void GridMapEditor::edit(GridMap *p_gridmap) {
VisualServer::get_singleton()->instance_set_visible(cursor_instance, false);
- _clear_areas();
-
return;
}
update_pallete();
- update_areas();
set_process(true);
@@ -894,7 +771,6 @@ void GridMapEditor::edit(GridMap *p_gridmap) {
update_grid();
_update_clip();
- _update_areas_display();
}
void GridMapEditor::_update_clip() {
@@ -931,9 +807,6 @@ void GridMapEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
theme_pallete->connect("item_selected", this, "_item_selected_cbk");
- edit_mode->connect("item_selected", this, "_edit_mode_changed");
- area_list->connect("item_edited", this, "_area_renamed");
- area_list->connect("item_selected", this, "_area_selected");
for (int i = 0; i < 3; i++) {
grid[i] = VS::get_singleton()->mesh_create();
@@ -1021,85 +894,6 @@ void GridMapEditor::_item_selected_cbk(int idx) {
_update_cursor_instance();
}
-void GridMapEditor::_clear_areas() {
-
- for (int i = 0; i < areas.size(); i++) {
-
- VisualServer::get_singleton()->free(areas[i].instance);
- VisualServer::get_singleton()->free(areas[i].mesh);
- }
-
- areas.clear();
-}
-
-void GridMapEditor::_update_areas_display() {
- if (!node) {
- return;
- }
-#if 0
- _clear_areas();
- List<int> areas;
- node->get_area_list(&areas);
-
- Transform global_xf = node->get_global_transform();
-
- for(List<int>::Element *E=areas.front();E;E=E->next()) {
-
- int area = E->get();
- Color color;
- if (node->area_is_exterior_portal(area))
- color=Color(1,1,1,0.2);
- else
- color.set_hsv(Math::fmod(area*0.37,1),Math::fmod(area*0.75,1),1.0,0.2);
-
-
- RID material = VisualServer::get_singleton()->fixed_material_create();
- VisualServer::get_singleton()->fixed_material_set_param( material, VS::FIXED_MATERIAL_PARAM_DIFFUSE,color );
- VisualServer::get_singleton()->fixed_material_set_param( material, VS::FIXED_MATERIAL_PARAM_EMISSION,0.5 );
- VisualServer::get_singleton()->fixed_material_set_flag( material, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA, true );
-
-
- RID mesh = VisualServer::get_singleton()->mesh_create();
-
- PoolVector<Plane> planes;
- for(int i=0;i<3;i++) {
-
- Vector3 axis;
- axis[i]=1.0;
- planes.push_back(Plane(axis,1));
- planes.push_back(Plane(-axis,0));
- }
-
- VisualServer::get_singleton()->mesh_add_surface_from_planes(mesh,planes);
- VisualServer::get_singleton()->mesh_surface_set_material(mesh,0,material,true);
-
- AreaDisplay ad;
- ad.mesh=mesh;
- ad.instance = VisualServer::get_singleton()->instance_create2(mesh,node->get_world()->get_scenario());
- Transform xform;
- Rect3 aabb = node->area_get_bounds(area);
- xform.origin=aabb.pos * node->get_cell_size();
- xform.basis.scale(aabb.size * node->get_cell_size());
- VisualServer::get_singleton()->instance_set_transform(ad.instance,global_xf * xform);
- this->areas.push_back(ad);
-
- }
-#endif
-}
-
-void GridMapEditor::_edit_mode_changed(int p_what) {
-
- if (p_what == 0) {
-
- theme_pallete->show();
- area_list->hide();
- } else {
-
- theme_pallete->hide();
- area_list->show();
- }
-}
-
void GridMapEditor::_floor_changed(float p_value) {
if (updating)
@@ -1116,9 +910,6 @@ void GridMapEditor::_bind_methods() {
ClassDB::bind_method("_menu_option", &GridMapEditor::_menu_option);
ClassDB::bind_method("_configure", &GridMapEditor::_configure);
ClassDB::bind_method("_item_selected_cbk", &GridMapEditor::_item_selected_cbk);
- ClassDB::bind_method("_edit_mode_changed", &GridMapEditor::_edit_mode_changed);
- ClassDB::bind_method("_area_renamed", &GridMapEditor::_area_renamed);
- ClassDB::bind_method("_area_selected", &GridMapEditor::_area_selected);
ClassDB::bind_method("_floor_changed", &GridMapEditor::_floor_changed);
ClassDB::bind_method(D_METHOD("_set_display_mode", "mode"), &GridMapEditor::_set_display_mode);
@@ -1198,15 +989,6 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
add_child(hb);
hb->set_h_size_flags(SIZE_EXPAND_FILL);
- edit_mode = memnew(OptionButton);
- edit_mode->set_area_as_parent_rect();
- edit_mode->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_BEGIN, 24);
- edit_mode->set_margin(MARGIN_RIGHT, -14);
- edit_mode->add_item(TTR("Tiles"));
- edit_mode->add_item(TTR("Areas"));
- hb->add_child(edit_mode);
- edit_mode->set_h_size_flags(SIZE_EXPAND_FILL);
-
mode_thumbnail = memnew(ToolButton);
mode_thumbnail->set_toggle_mode(true);
mode_thumbnail->set_pressed(true);
@@ -1224,17 +1006,11 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
EDITOR_DEF("editors/grid_map/preview_size", 64);
display_mode = DISPLAY_THUMBNAIL;
- selected_area = -1;
theme_pallete = memnew(ItemList);
add_child(theme_pallete);
theme_pallete->set_v_size_flags(SIZE_EXPAND_FILL);
- area_list = memnew(Tree);
- add_child(area_list);
- area_list->set_v_size_flags(SIZE_EXPAND_FILL);
- area_list->hide();
-
spatial_editor_hb->add_child(memnew(VSeparator));
Label *fl = memnew(Label);
fl->set_text(" Floor: ");
@@ -1363,8 +1139,6 @@ GridMapEditor::~GridMapEditor() {
VisualServer::get_singleton()->free(duplicate_mesh);
if (duplicate_instance.is_valid())
VisualServer::get_singleton()->free(duplicate_instance);
-
- _clear_areas();
}
void GridMapEditorPlugin::edit(Object *p_object) {
diff --git a/modules/gridmap/grid_map_editor_plugin.h b/modules/gridmap/grid_map_editor_plugin.h
index a1b2c96ccd..6c7c0ab331 100644
--- a/modules/gridmap/grid_map_editor_plugin.h
+++ b/modules/gridmap/grid_map_editor_plugin.h
@@ -75,7 +75,6 @@ class GridMapEditor : public VBoxContainer {
Panel *panel;
MenuButton *options;
SpinBox *floor;
- OptionButton *edit_mode;
ToolButton *mode_thumbnail;
ToolButton *mode_list;
HBoxContainer *spatial_editor_hb;
@@ -137,7 +136,6 @@ class GridMapEditor : public VBoxContainer {
int display_mode;
int selected_pallete;
- int selected_area;
int cursor_rot;
enum Menu {
@@ -177,18 +175,12 @@ class GridMapEditor : public VBoxContainer {
RID instance;
};
- Vector<AreaDisplay> areas;
-
- void _update_areas_display();
- void _clear_areas();
-
void update_grid();
void _configure();
void _menu_option(int);
void update_pallete();
void _set_display_mode(int p_mode);
ItemList *theme_pallete;
- Tree *area_list;
void _item_selected_cbk(int idx);
void _update_cursor_transform();
void _update_cursor_instance();
@@ -199,14 +191,9 @@ class GridMapEditor : public VBoxContainer {
void _update_selection_transform();
void _validate_selection();
- void _edit_mode_changed(int p_what);
- void _area_renamed();
- void _area_selected();
-
void _floor_changed(float p_value);
void _delete_selection();
- void update_areas();
EditorNode *editor;
bool do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click);
diff --git a/scene/3d/portal.cpp b/scene/3d/portal.cpp
index d77dde1dd8..f79f7f6949 100644
--- a/scene/3d/portal.cpp
+++ b/scene/3d/portal.cpp
@@ -32,6 +32,7 @@
#include "scene/resources/surface_tool.h"
#include "servers/visual_server.h"
+#if 0
bool Portal::_set(const StringName &p_name, const Variant &p_value) {
if (p_name == "shape") {
@@ -226,3 +227,4 @@ Portal::~Portal() {
VisualServer::get_singleton()->free(portal);
}
+#endif
diff --git a/scene/3d/portal.h b/scene/3d/portal.h
index 7c25e4904b..9cc5d280a1 100644
--- a/scene/3d/portal.h
+++ b/scene/3d/portal.h
@@ -39,7 +39,8 @@
If a portal is placed next (very close to) a similar, opposing portal, they automatically connect,
otherwise, a portal connects to the parent room
*/
-
+//this will be redone and replaced by area portals, left for reference since a new class with this name will have to exist and want to reuse the gizmos
+#if 0
class Portal : public VisualInstance {
GDCLASS(Portal, VisualInstance);
@@ -85,3 +86,4 @@ public:
};
#endif
+#endif
diff --git a/scene/3d/room_instance.cpp b/scene/3d/room_instance.cpp
index 3e6a8d3c38..81ddf4a667 100644
--- a/scene/3d/room_instance.cpp
+++ b/scene/3d/room_instance.cpp
@@ -31,6 +31,7 @@
#include "servers/visual_server.h"
+#if 0
#include "geometry.h"
#include "project_settings.h"
#include "scene/resources/surface_tool.h"
@@ -158,3 +159,4 @@ Room::Room() {
Room::~Room() {
}
+#endif
diff --git a/scene/3d/room_instance.h b/scene/3d/room_instance.h
index 4176da92e8..5b9886671f 100644
--- a/scene/3d/room_instance.h
+++ b/scene/3d/room_instance.h
@@ -44,6 +44,9 @@
*/
+//this will be removed, left for reference
+#if 0
+
class Room : public VisualInstance {
GDCLASS(Room, VisualInstance);
@@ -77,5 +80,5 @@ public:
Room();
~Room();
};
-
+#endif
#endif // ROOM_INSTANCE_H
diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp
index 9e85a8a5b1..2c1ef5c00b 100644
--- a/scene/3d/spatial.cpp
+++ b/scene/3d/spatial.cpp
@@ -185,8 +185,13 @@ void Spatial::_notification(int p_what) {
get_tree()->call_group_flags(0, SceneStringNames::get_singleton()->_spatial_editor_group, SceneStringNames::get_singleton()->_request_gizmo, this);
if (!data.gizmo_disabled) {
- if (data.gizmo.is_valid())
+ if (data.gizmo.is_valid()) {
data.gizmo->create();
+ if (data.gizmo->can_draw()) {
+ data.gizmo->redraw();
+ }
+ data.gizmo->transform();
+ }
}
}
#endif
@@ -449,7 +454,9 @@ void Spatial::set_gizmo(const Ref<SpatialGizmo> &p_gizmo) {
if (data.gizmo.is_valid() && is_inside_world()) {
data.gizmo->create();
- data.gizmo->redraw();
+ if (data.gizmo->can_draw()) {
+ data.gizmo->redraw();
+ }
data.gizmo->transform();
}
@@ -471,12 +478,16 @@ Ref<SpatialGizmo> Spatial::get_gizmo() const {
void Spatial::_update_gizmo() {
+ if (!is_inside_world())
+ return;
data.gizmo_dirty = false;
if (data.gizmo.is_valid()) {
- if (is_visible_in_tree())
- data.gizmo->redraw();
- else
- data.gizmo->clear();
+ if (data.gizmo->can_draw()) {
+ if (is_visible_in_tree())
+ data.gizmo->redraw();
+ else
+ data.gizmo->clear();
+ }
}
}
diff --git a/scene/3d/spatial.h b/scene/3d/spatial.h
index f22b19d3cc..3e647927ae 100644
--- a/scene/3d/spatial.h
+++ b/scene/3d/spatial.h
@@ -47,6 +47,7 @@ public:
virtual void clear() = 0;
virtual void redraw() = 0;
virtual void free() = 0;
+ virtual bool can_draw() const = 0;
SpatialGizmo();
};
diff --git a/scene/3d/visual_instance.cpp b/scene/3d/visual_instance.cpp
index b9e4488998..1ca6ec42d9 100644
--- a/scene/3d/visual_instance.cpp
+++ b/scene/3d/visual_instance.cpp
@@ -29,7 +29,6 @@
/*************************************************************************/
#include "visual_instance.h"
-#include "room_instance.h"
#include "scene/scene_string_names.h"
#include "servers/visual_server.h"
#include "skeleton.h"
@@ -54,29 +53,6 @@ void VisualInstance::_notification(int p_what) {
case NOTIFICATION_ENTER_WORLD: {
- // CHECK ROOM
- Spatial *parent = get_parent_spatial();
- Room *room = NULL;
- bool is_geom = Object::cast_to<GeometryInstance>(this);
-
- /* while(parent) {
-
- room = Object::cast_to<Room>(parent);
- if (room)
- break;
-
- if (is_geom && Object::cast_to<BakedLightSampler>(parent)) {
- VS::get_singleton()->instance_geometry_set_baked_light_sampler(get_instance(),Object::cast_to<BakedLightSampler>(parent)->get_instance());
- break;
- }
-
- parent=parent->get_parent_spatial();
- }*/
-
- if (room) {
-
- VisualServer::get_singleton()->instance_set_room(instance, room->get_instance());
- }
// CHECK SKELETON => moving skeleton attaching logic to MeshInstance
/*
Skeleton *skeleton=Object::cast_to<Skeleton>(get_parent());
@@ -96,7 +72,6 @@ void VisualInstance::_notification(int p_what) {
case NOTIFICATION_EXIT_WORLD: {
VisualServer::get_singleton()->instance_set_scenario(instance, RID());
- VisualServer::get_singleton()->instance_set_room(instance, RID());
VisualServer::get_singleton()->instance_attach_skeleton(instance, RID());
//VS::get_singleton()->instance_geometry_set_baked_light_sampler(instance, RID() );
@@ -303,7 +278,6 @@ void GeometryInstance::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material_override", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,SpatialMaterial"), "set_material_override", "get_material_override");
ADD_PROPERTY(PropertyInfo(Variant::INT, "cast_shadow", PROPERTY_HINT_ENUM, "Off,On,Double-Sided,Shadows Only"), "set_cast_shadows_setting", "get_cast_shadows_setting");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "extra_cull_margin", PROPERTY_HINT_RANGE, "0,16384,0"), "set_extra_cull_margin", "get_extra_cull_margin");
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "visible_in_all_rooms"), "set_flag", "get_flag", FLAG_VISIBLE_IN_ALL_ROOMS);
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "use_in_baked_light"), "set_flag", "get_flag", FLAG_USE_BAKED_LIGHT);
ADD_GROUP("LOD", "lod_");
@@ -314,7 +288,6 @@ void GeometryInstance::_bind_methods() {
//ADD_SIGNAL( MethodInfo("visibility_changed"));
- BIND_CONSTANT(FLAG_VISIBLE_IN_ALL_ROOMS);
BIND_CONSTANT(FLAG_MAX);
BIND_CONSTANT(SHADOW_CASTING_SETTING_OFF);
diff --git a/scene/3d/visual_instance.h b/scene/3d/visual_instance.h
index 694d0c2499..4751d109e6 100644
--- a/scene/3d/visual_instance.h
+++ b/scene/3d/visual_instance.h
@@ -84,7 +84,6 @@ class GeometryInstance : public VisualInstance {
public:
enum Flags {
- FLAG_VISIBLE_IN_ALL_ROOMS = VS::INSTANCE_FLAG_VISIBLE_IN_ALL_ROOMS,
FLAG_USE_BAKED_LIGHT = VS::INSTANCE_FLAG_USE_BAKED_LIGHT,
FLAG_MAX = VS::INSTANCE_FLAG_MAX,
};
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 0661b10184..b4eabaa540 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -395,7 +395,7 @@ void Viewport::_notification(int p_what) {
contact_3d_debug_instance = VisualServer::get_singleton()->instance_create();
VisualServer::get_singleton()->instance_set_base(contact_3d_debug_instance, contact_3d_debug_multimesh);
VisualServer::get_singleton()->instance_set_scenario(contact_3d_debug_instance, find_world()->get_scenario());
- VisualServer::get_singleton()->instance_geometry_set_flag(contact_3d_debug_instance, VS::INSTANCE_FLAG_VISIBLE_IN_ALL_ROOMS, true);
+ //VisualServer::get_singleton()->instance_geometry_set_flag(contact_3d_debug_instance, VS::INSTANCE_FLAG_VISIBLE_IN_ALL_ROOMS, true);
}
VS::get_singleton()->viewport_set_active(viewport, true);
diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp
index 3e6d80d314..7d9e262b3f 100644
--- a/scene/register_scene_types.cpp
+++ b/scene/register_scene_types.cpp
@@ -167,7 +167,7 @@
#include "scene/3d/audio_stream_player_3d.h"
#include "scene/resources/material.h"
#include "scene/resources/mesh.h"
-#include "scene/resources/room.h"
+
#include "scene/resources/sky_box.h"
#include "scene/resources/texture.h"
@@ -424,7 +424,7 @@ void register_scene_types() {
ClassDB::register_class<GIProbe>();
ClassDB::register_class<GIProbeData>();
ClassDB::register_class<AnimationTreePlayer>();
- ClassDB::register_class<Portal>();
+ //ClassDB::register_class<Portal>();
ClassDB::register_class<Particles>();
ClassDB::register_class<Position3D>();
ClassDB::register_class<NavigationMeshInstance>();
@@ -446,7 +446,7 @@ void register_scene_types() {
ClassDB::register_class<CollisionPolygon>();
ClassDB::register_class<RayCast>();
ClassDB::register_class<MultiMeshInstance>();
- ClassDB::register_class<Room>();
+
ClassDB::register_class<Curve3D>();
ClassDB::register_class<Path>();
ClassDB::register_class<PathFollow>();
@@ -546,7 +546,6 @@ void register_scene_types() {
ParticlesMaterial::init_shaders();
//ClassDB::register_type<ShaderMaterial>();
- ClassDB::register_class<RoomBounds>();
ClassDB::register_class<MultiMesh>();
ClassDB::register_class<MeshLibrary>();
diff --git a/scene/resources/room.cpp b/scene/resources/room.cpp
index c89b7c72c7..de238ebcc0 100644
--- a/scene/resources/room.cpp
+++ b/scene/resources/room.cpp
@@ -30,7 +30,7 @@
#include "room.h"
#include "servers/visual_server.h"
-
+#if 0
RID RoomBounds::get_rid() const {
return area;
@@ -64,3 +64,4 @@ RoomBounds::~RoomBounds() {
VisualServer::get_singleton()->free(area);
}
+#endif
diff --git a/scene/resources/room.h b/scene/resources/room.h
index ba5c0eee1c..4b8c837458 100644
--- a/scene/resources/room.h
+++ b/scene/resources/room.h
@@ -36,6 +36,9 @@
@author Juan Linietsky <reduzio@gmail.com>
*/
+//left for reference but will be removed when portals are reimplemented using Area
+#if 0
+
class RoomBounds : public Resource {
GDCLASS(RoomBounds, Resource);
@@ -57,4 +60,5 @@ public:
~RoomBounds();
};
+#endif
#endif // ROOM_H
diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h
index 3b4ba313e6..a75ce1cf35 100644
--- a/servers/visual/rasterizer.h
+++ b/servers/visual/rasterizer.h
@@ -376,23 +376,6 @@ public:
virtual float reflection_probe_get_origin_max_distance(RID p_probe) const = 0;
virtual bool reflection_probe_renders_shadows(RID p_probe) const = 0;
- /* ROOM API */
-
- virtual RID room_create() = 0;
- virtual void room_add_bounds(RID p_room, const PoolVector<Vector2> &p_convex_polygon, float p_height, const Transform &p_transform) = 0;
- virtual void room_clear_bounds(RID p_room) = 0;
-
- /* PORTAL API */
-
- // portals are only (x/y) points, forming a convex shape, which its clockwise
- // order points outside. (z is 0)=0;
-
- virtual RID portal_create() = 0;
- virtual void portal_set_shape(RID p_portal, const Vector<Point2> &p_shape) = 0;
- virtual void portal_set_enabled(RID p_portal, bool p_enabled) = 0;
- virtual void portal_set_disable_distance(RID p_portal, float p_distance) = 0;
- virtual void portal_set_disabled_color(RID p_portal, const Color &p_color) = 0;
-
virtual void instance_add_skeleton(RID p_skeleton, RasterizerScene::InstanceBase *p_instance) = 0;
virtual void instance_remove_skeleton(RID p_skeleton, RasterizerScene::InstanceBase *p_instance) = 0;
diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h
index fff37a71b3..70492afe83 100644
--- a/servers/visual/visual_server_raster.h
+++ b/servers/visual/visual_server_raster.h
@@ -811,23 +811,6 @@ public:
BIND2(reflection_probe_set_enable_shadows, RID, bool)
BIND2(reflection_probe_set_cull_mask, RID, uint32_t)
- /* ROOM API */
-
- BIND0R(RID, room_create)
- BIND4(room_add_bounds, RID, const PoolVector<Vector2> &, float, const Transform &)
- BIND1(room_clear_bounds, RID)
-
- /* PORTAL API */
-
- // portals are only (x/y) points, forming a convex shape, which its clockwise
- // order points outside. (z is 0);
-
- BIND0R(RID, portal_create)
- BIND2(portal_set_shape, RID, const Vector<Point2> &)
- BIND2(portal_set_enabled, RID, bool)
- BIND2(portal_set_disable_distance, RID, float)
- BIND2(portal_set_disabled_color, RID, const Color &)
-
/* BAKED LIGHT API */
BIND0R(RID, gi_probe_create)
@@ -1011,7 +994,6 @@ public:
BIND2(instance_attach_skeleton, RID, RID)
BIND2(instance_set_exterior, RID, bool)
- BIND2(instance_set_room, RID, RID)
BIND2(instance_set_extra_visibility_margin, RID, real_t)
diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp
index fb298e3ed7..fc9583d793 100644
--- a/servers/visual/visual_server_scene.cpp
+++ b/servers/visual/visual_server_scene.cpp
@@ -156,58 +156,6 @@ void *VisualServerScene::_instance_pair(void *p_self, OctreeElementID, Instance
return gi_probe->lights.insert(A);
}
-#if 0
- if (A->base_type==INSTANCE_PORTAL) {
-
- ERR_FAIL_COND_V( B->base_type!=INSTANCE_PORTAL,NULL );
-
- A->portal_info->candidate_set.insert(B);
- B->portal_info->candidate_set.insert(A);
-
- self->_portal_attempt_connect(A);
- //attempt to conncet portal A (will go through B anyway)
- //this is a little hackish, but works fine in practice
-
- } else if (A->base_type==INSTANCE_GI_PROBE || B->base_type==INSTANCE_GI_PROBE) {
-
- if (B->base_type==INSTANCE_GI_PROBE) {
- SWAP(A,B);
- }
-
- ERR_FAIL_COND_V(B->base_type!=INSTANCE_GI_PROBE_SAMPLER,NULL);
- B->gi_probe_sampler_info->gi_probes.insert(A);
-
- } else if (A->base_type==INSTANCE_ROOM || B->base_type==INSTANCE_ROOM) {
-
- if (B->base_type==INSTANCE_ROOM)
- SWAP(A,B);
-
- ERR_FAIL_COND_V(! ((1<<B->base_type)&INSTANCE_GEOMETRY_MASK ),NULL);
-
- B->auto_rooms.insert(A);
- A->room_info->owned_autoroom_geometry.insert(B);
-
- self->_instance_validate_autorooms(B);
-
-
- } else {
-
- if (B->base_type==INSTANCE_LIGHT) {
-
- SWAP(A,B);
- } else if (A->base_type!=INSTANCE_LIGHT) {
- return NULL;
- }
-
-
- A->light_info->affected.insert(B);
- B->lights.insert(A);
- B->light_cache_dirty=true;
-
-
- }
-#endif
-
return NULL;
}
void VisualServerScene::_instance_unpair(void *p_self, OctreeElementID, Instance *p_A, int, OctreeElementID, Instance *p_B, int, void *udata) {
@@ -269,57 +217,6 @@ void VisualServerScene::_instance_unpair(void *p_self, OctreeElementID, Instance
gi_probe->lights.erase(E);
}
-#if 0
- if (A->base_type==INSTANCE_PORTAL) {
-
- ERR_FAIL_COND( B->base_type!=INSTANCE_PORTAL );
-
-
- A->portal_info->candidate_set.erase(B);
- B->portal_info->candidate_set.erase(A);
-
- //after disconnecting them, see if they can connect again
- self->_portal_attempt_connect(A);
- self->_portal_attempt_connect(B);
-
- } else if (A->base_type==INSTANCE_GI_PROBE || B->base_type==INSTANCE_GI_PROBE) {
-
- if (B->base_type==INSTANCE_GI_PROBE) {
- SWAP(A,B);
- }
-
- ERR_FAIL_COND(B->base_type!=INSTANCE_GI_PROBE_SAMPLER);
- B->gi_probe_sampler_info->gi_probes.erase(A);
-
- } else if (A->base_type==INSTANCE_ROOM || B->base_type==INSTANCE_ROOM) {
-
- if (B->base_type==INSTANCE_ROOM)
- SWAP(A,B);
-
- ERR_FAIL_COND(! ((1<<B->base_type)&INSTANCE_GEOMETRY_MASK ));
-
- B->auto_rooms.erase(A);
- B->valid_auto_rooms.erase(A);
- A->room_info->owned_autoroom_geometry.erase(B);
-
- }else {
-
-
-
- if (B->base_type==INSTANCE_LIGHT) {
-
- SWAP(A,B);
- } else if (A->base_type!=INSTANCE_LIGHT) {
- return;
- }
-
-
- A->light_info->affected.erase(B);
- B->lights.erase(A);
- B->light_cache_dirty=true;
-
- }
-#endif
}
RID VisualServerScene::scenario_create() {
@@ -467,125 +364,6 @@ void VisualServerScene::instance_set_base(RID p_instance, RID p_base) {
}
}
instance->materials.clear();
-
-#if 0
- if (instance->light_info) {
-
- if (instance->scenario && instance->light_info->D)
- instance->scenario->directional_lights.erase( instance->light_info->D );
- rasterizer->free(instance->light_info->instance);
- memdelete(instance->light_info);
- instance->light_info=NULL;
- }
-
-
-
- if ( instance->room ) {
-
- instance_set_room(p_instance,RID());
- /*
- if((1<<instance->base_type)&INSTANCE_GEOMETRY_MASK)
- instance->room->room_info->owned_geometry_instances.erase(instance->RE);
- else if (instance->base_type==INSTANCE_PORTAL) {
- print_line("freeing portal, is it there? "+itos(instance->room->room_info->owned_portal_instances.(instance->RE)));
- instance->room->room_info->owned_portal_instances.erase(instance->RE);
- } else if (instance->base_type==INSTANCE_ROOM)
- instance->room->room_info->owned_room_instances.erase(instance->RE);
- else if (instance->base_type==INSTANCE_LIGHT)
- instance->room->room_info->owned_light_instances.erase(instance->RE);
-
- instance->RE=NULL;*/
- }
-
-
-
-
-
-
- if (instance->portal_info) {
-
- _portal_disconnect(instance,true);
- memdelete(instance->portal_info);
- instance->portal_info=NULL;
-
- }
-
- if (instance->gi_probe_info) {
-
- while(instance->gi_probe_info->owned_instances.size()) {
-
- Instance *owned=instance->gi_probe_info->owned_instances.front()->get();
- owned->gi_probe=NULL;
- owned->data.gi_probe=NULL;
- owned->data.gi_probe_octree_xform=NULL;
- owned->BLE=NULL;
- instance->gi_probe_info->owned_instances.pop_front();
- }
-
- memdelete(instance->gi_probe_info);
- instance->gi_probe_info=NULL;
-
- }
-
- if (instance->scenario && instance->octree_id) {
- instance->scenario->octree.erase( instance->octree_id );
- instance->octree_id=0;
- }
-
-
- if (instance->room_info) {
-
- for(List<Instance*>::Element *E=instance->room_info->owned_geometry_instances.front();E;E=E->next()) {
-
- Instance *owned = E->get();
- owned->room=NULL;
- owned->RE=NULL;
- }
- for(List<Instance*>::Element *E=instance->room_info->owned_portal_instances.front();E;E=E->next()) {
-
- _portal_disconnect(E->get(),true);
- Instance *owned = E->get();
- owned->room=NULL;
- owned->RE=NULL;
- }
-
- for(List<Instance*>::Element *E=instance->room_info->owned_room_instances.front();E;E=E->next()) {
-
- Instance *owned = E->get();
- owned->room=NULL;
- owned->RE=NULL;
- }
-
- if (instance->room_info->disconnected_child_portals.size()) {
- ERR_PRINT("BUG: Disconnected portals remain!");
- }
- memdelete(instance->room_info);
- instance->room_info=NULL;
-
- }
-
- if (instance->particles_info) {
-
- rasterizer->free( instance->particles_info->instance );
- memdelete(instance->particles_info);
- instance->particles_info=NULL;
-
- }
-
- if (instance->gi_probe_sampler_info) {
-
- while (instance->gi_probe_sampler_info->owned_instances.size()) {
-
- instance_geometry_set_gi_probe_sampler(instance->gi_probe_sampler_info->owned_instances.front()->get()->self,RID());
- }
-
- if (instance->gi_probe_sampler_info->sampled_light.is_valid()) {
- rasterizer->free(instance->gi_probe_sampler_info->sampled_light);
- }
- memdelete( instance->gi_probe_sampler_info );
- instance->gi_probe_sampler_info=NULL;
- }
-#endif
}
instance->base_type = VS::INSTANCE_NONE;
@@ -646,64 +424,6 @@ void VisualServerScene::instance_set_base(RID p_instance, RID p_base) {
if (scenario)
_instance_queue_update(instance, true, true);
-
-#if 0
- if (rasterizer->is_mesh(p_base)) {
- instance->base_type=INSTANCE_MESH;
- instance->data.morph_values.resize( rasterizer->mesh_get_morph_target_count(p_base));
- instance->data.materials.resize( rasterizer->mesh_get_surface_count(p_base));
- } else if (rasterizer->is_multimesh(p_base)) {
- instance->base_type=INSTANCE_MULTIMESH;
- } else if (rasterizer->is_immediate(p_base)) {
- instance->base_type=INSTANCE_IMMEDIATE;
- } else if (rasterizer->is_particles(p_base)) {
- instance->base_type=INSTANCE_PARTICLES;
- instance->particles_info=memnew( Instance::ParticlesInfo );
- instance->particles_info->instance = rasterizer->particles_instance_create( p_base );
- } else if (rasterizer->is_light(p_base)) {
-
- instance->base_type=INSTANCE_LIGHT;
- instance->light_info = memnew( Instance::LightInfo );
- instance->light_info->instance = rasterizer->light_instance_create(p_base);
- if (instance->scenario && rasterizer->light_get_type(p_base)==LIGHT_DIRECTIONAL) {
-
- instance->light_info->D = instance->scenario->directional_lights.push_back(instance->self);
- }
-
- } else if (room_owner.owns(p_base)) {
- instance->base_type=INSTANCE_ROOM;
- instance->room_info = memnew( Instance::RoomInfo );
- instance->room_info->room=room_owner.get(p_base);
- } else if (portal_owner.owns(p_base)) {
-
- instance->base_type=INSTANCE_PORTAL;
- instance->portal_info = memnew(Instance::PortalInfo);
- instance->portal_info->portal=portal_owner.get(p_base);
- } else if (gi_probe_owner.owns(p_base)) {
-
- instance->base_type=INSTANCE_GI_PROBE;
- instance->gi_probe_info=memnew(Instance::BakedLightInfo);
- instance->gi_probe_info->gi_probe=gi_probe_owner.get(p_base);
-
- //instance->portal_info = memnew(Instance::PortalInfo);
- //instance->portal_info->portal=portal_owner.get(p_base);
- } else if (gi_probe_sampler_owner.owns(p_base)) {
-
-
- instance->base_type=INSTANCE_GI_PROBE_SAMPLER;
- instance->gi_probe_sampler_info=memnew( Instance::BakedLightSamplerInfo);
- instance->gi_probe_sampler_info->sampler=gi_probe_sampler_owner.get(p_base);
-
- //instance->portal_info = memnew(Instance::PortalInfo);
- //instance->portal_info->portal=portal_owner.get(p_base);
-
- } else {
- ERR_EXPLAIN("Invalid base RID for instance!")
- ERR_FAIL();
- }
-
- instance_dependency_map[ p_base ].insert( instance->self );
-#endif
}
}
void VisualServerScene::instance_set_scenario(RID p_instance, RID p_scenario) {
@@ -894,8 +614,6 @@ void VisualServerScene::instance_attach_skeleton(RID p_instance, RID p_skeleton)
void VisualServerScene::instance_set_exterior(RID p_instance, bool p_enabled) {
}
-void VisualServerScene::instance_set_room(RID p_instance, RID p_room) {
-}
void VisualServerScene::instance_set_extra_visibility_margin(RID p_instance, real_t p_margin) {
}
@@ -978,11 +696,6 @@ void VisualServerScene::instance_geometry_set_flag(RID p_instance, VS::InstanceF
switch (p_flags) {
- case VS::INSTANCE_FLAG_VISIBLE_IN_ALL_ROOMS: {
-
- instance->visible_in_all_rooms = p_enabled;
-
- } break;
case VS::INSTANCE_FLAG_USE_BAKED_LIGHT: {
instance->baked_light = p_enabled;
@@ -1067,58 +780,12 @@ void VisualServerScene::_update_instance(Instance *p_instance) {
}
}
}
-#if 0
- else if (p_instance->base_type == INSTANCE_ROOM) {
-
- p_instance->room_info->affine_inverse=p_instance->data.transform.affine_inverse();
- } else if (p_instance->base_type == INSTANCE_GI_PROBE) {
-
- Transform scale;
- scale.basis.scale(p_instance->gi_probe_info->gi_probe->octree_aabb.size);
- scale.origin=p_instance->gi_probe_info->gi_probe->octree_aabb.pos;
- //print_line("scale: "+scale);
- p_instance->gi_probe_info->affine_inverse=(p_instance->data.transform*scale).affine_inverse();
- }
-
-#endif
p_instance->mirror = p_instance->transform.basis.determinant() < 0.0;
Rect3 new_aabb;
-#if 0
- if (p_instance->base_type==INSTANCE_PORTAL) {
-
- //portals need to be transformed in a special way, so they don't become too wide if they have scale..
- Transform portal_xform = p_instance->data.transform;
- portal_xform.basis.set_axis(2,portal_xform.basis.get_axis(2).normalized());
- p_instance->portal_info->plane_cache=Plane( p_instance->data.transform.origin, portal_xform.basis.get_axis(2));
- int point_count=p_instance->portal_info->portal->shape.size();
- p_instance->portal_info->transformed_point_cache.resize(point_count);
-
- AABB portal_aabb;
-
- for(int i=0;i<point_count;i++) {
-
- Point2 src = p_instance->portal_info->portal->shape[i];
- Vector3 point = portal_xform.xform(Vector3(src.x,src.y,0));
- p_instance->portal_info->transformed_point_cache[i]=point;
- if (i==0)
- portal_aabb.pos=point;
- else
- portal_aabb.expand_to(point);
- }
-
- portal_aabb.grow_by(p_instance->portal_info->portal->connect_range);
-
- new_aabb = portal_aabb;
-
- } else {
-#endif
new_aabb = p_instance->transform.xform(p_instance->aabb);
-#if 0
- }
-#endif
p_instance->transformed_aabb = new_aabb;
@@ -1145,33 +812,6 @@ void VisualServerScene::_update_instance(Instance *p_instance) {
pairable = true;
}
-#if 0
-
- if (p_instance->base_type == VS::INSTANCE_PORTAL) {
-
- pairable_mask=(1<<INSTANCE_PORTAL);
- pairable=true;
- }
-
- if (p_instance->base_type == VS::INSTANCE_GI_PROBE_SAMPLER) {
-
- pairable_mask=(1<<INSTANCE_GI_PROBE);
- pairable=true;
- }
-
-
- if (!p_instance->room && (1<<p_instance->base_type)&VS::INSTANCE_GEOMETRY_MASK) {
-
- base_type|=VS::INSTANCE_ROOMLESS_MASK;
- }
-
- if (p_instance->base_type == VS::INSTANCE_ROOM) {
-
- pairable_mask=INSTANCE_ROOMLESS_MASK;
- pairable=true;
- }
-#endif
-
// not inside octree
p_instance->octree_id = p_instance->scenario->octree.create(p_instance, new_aabb, 0, pairable, base_type, pairable_mask);
@@ -1184,23 +824,6 @@ void VisualServerScene::_update_instance(Instance *p_instance) {
p_instance->scenario->octree.move(p_instance->octree_id, new_aabb);
}
-#if 0
- if (p_instance->base_type==INSTANCE_PORTAL) {
-
- _portal_attempt_connect(p_instance);
- }
-
- if (!p_instance->room && (1<<p_instance->base_type)&INSTANCE_GEOMETRY_MASK) {
-
- _instance_validate_autorooms(p_instance);
- }
-
- if (p_instance->base_type == INSTANCE_ROOM) {
-
- for(Set<Instance*>::Element *E=p_instance->room_info->owned_autoroom_geometry.front();E;E=E->next())
- _instance_validate_autorooms(E->get());
- }
-#endif
}
void VisualServerScene::_update_instance_aabb(Instance *p_instance) {
@@ -1235,15 +858,6 @@ void VisualServerScene::_update_instance_aabb(Instance *p_instance) {
new_aabb = VSG::storage->particles_get_aabb(p_instance->base);
} break;
-#if 0
-
- case VisualServer::INSTANCE_PARTICLES: {
-
- new_aabb = rasterizer->particles_get_aabb(p_instance->base);
-
-
- } break;
-#endif
case VisualServer::INSTANCE_LIGHT: {
new_aabb = VSG::storage->light_get_aabb(p_instance->base);
@@ -1260,49 +874,6 @@ void VisualServerScene::_update_instance_aabb(Instance *p_instance) {
} break;
-#if 0
- case VisualServer::INSTANCE_ROOM: {
-
- Room *room = room_owner.get( p_instance->base );
- ERR_FAIL_COND(!room);
- new_aabb=room->bounds.get_aabb();
-
- } break;
- case VisualServer::INSTANCE_PORTAL: {
-
- Portal *portal = portal_owner.get( p_instance->base );
- ERR_FAIL_COND(!portal);
- for (int i=0;i<portal->shape.size();i++) {
-
- Vector3 point( portal->shape[i].x, portal->shape[i].y, 0 );
- if (i==0) {
-
- new_aabb.pos=point;
- new_aabb.size.z=0.01; // make it not flat for octree
- } else {
-
- new_aabb.expand_to(point);
- }
- }
-
- } break;
- case VisualServer::INSTANCE_GI_PROBE: {
-
- BakedLight *gi_probe = gi_probe_owner.get( p_instance->base );
- ERR_FAIL_COND(!gi_probe);
- new_aabb=gi_probe->octree_aabb;
-
- } break;
- case VisualServer::INSTANCE_GI_PROBE_SAMPLER: {
-
- BakedLightSampler *gi_probe_sampler = gi_probe_sampler_owner.get( p_instance->base );
- ERR_FAIL_COND(!gi_probe_sampler);
- float radius = gi_probe_sampler->params[VS::BAKED_LIGHT_SAMPLER_RADIUS];
-
- new_aabb=AABB(Vector3(-radius,-radius,-radius),Vector3(radius*2,radius*2,radius*2));
-
- } break;
-#endif
default: {}
}
@@ -1736,98 +1307,17 @@ void VisualServerScene::_render_scene(const Transform p_cam_transform, const Cam
reflection_probe_cull_count = 0;
-//light_samplers_culled=0;
+ //light_samplers_culled=0;
-/* print_line("OT: "+rtos( (OS::get_singleton()->get_ticks_usec()-t)/1000.0));
+ /* print_line("OT: "+rtos( (OS::get_singleton()->get_ticks_usec()-t)/1000.0));
print_line("OTO: "+itos(p_scenario->octree.get_octant_count()));
//print_line("OTE: "+itos(p_scenario->octree.get_elem_count()));
print_line("OTP: "+itos(p_scenario->octree.get_pair_count()));
*/
-/* STEP 3 - PROCESS PORTALS, VALIDATE ROOMS */
-
-// compute portals
-#if 0
- exterior_visited=false;
- exterior_portal_cull_count=0;
-
- if (room_cull_enabled) {
- for(int i=0;i<cull_count;i++) {
-
- Instance *ins = instance_cull_result[i];
- ins->last_render_pass=render_pass;
+ /* STEP 3 - PROCESS PORTALS, VALIDATE ROOMS */
+ //removed, will replace with culling
- if (ins->base_type!=INSTANCE_PORTAL)
- continue;
-
- if (ins->room)
- continue;
-
- ERR_CONTINUE(exterior_portal_cull_count>=MAX_EXTERIOR_PORTALS);
- exterior_portal_cull_result[exterior_portal_cull_count++]=ins;
-
- }
-
- room_cull_count = p_scenario->octree.cull_point(camera->transform.origin,room_cull_result,MAX_ROOM_CULL,NULL,(1<<INSTANCE_ROOM)|(1<<INSTANCE_PORTAL));
-
-
- Set<Instance*> current_rooms;
- Set<Instance*> portal_rooms;
- //add to set
- for(int i=0;i<room_cull_count;i++) {
-
- if (room_cull_result[i]->base_type==INSTANCE_ROOM) {
- current_rooms.insert(room_cull_result[i]);
- }
- if (room_cull_result[i]->base_type==INSTANCE_PORTAL) {
- //assume inside that room if also inside the portal..
- if (room_cull_result[i]->room) {
- portal_rooms.insert(room_cull_result[i]->room);
- }
-
- SWAP(room_cull_result[i],room_cull_result[room_cull_count-1]);
- room_cull_count--;
- i--;
- }
- }
-
- //remove from set if it has a parent room or BSP doesn't contain
- for(int i=0;i<room_cull_count;i++) {
- Instance *r = room_cull_result[i];
-
- //check inside BSP
- Vector3 room_local_point = r->room_info->affine_inverse.xform( camera->transform.origin );
-
- if (!portal_rooms.has(r) && !r->room_info->room->bounds.point_is_inside(room_local_point)) {
-
- current_rooms.erase(r);
- continue;
- }
-
- //check parent
- while (r->room) {// has parent room
-
- current_rooms.erase(r);
- r=r->room;
- }
-
- }
-
- if (current_rooms.size()) {
- //camera is inside a room
- // go through rooms
- for(Set<Instance*>::Element *E=current_rooms.front();E;E=E->next()) {
- _cull_room(camera,E->get());
- }
-
- } else {
- //start from exterior
- _cull_room(camera,NULL);
-
- }
- }
-
-#endif
/* STEP 4 - REMOVE FURTHER CULLED OBJECTS, ADD LIGHTS */
for (int i = 0; i < cull_count; i++) {
@@ -1895,71 +1385,6 @@ void VisualServerScene::_render_scene(const Transform p_cam_transform, const Cam
} else if ((1 << ins->base_type) & VS::INSTANCE_GEOMETRY_MASK && ins->visible && ins->cast_shadows != VS::SHADOW_CASTING_SETTING_SHADOWS_ONLY) {
keep = true;
-#if 0
- bool discarded=false;
-
- if (ins->draw_range_end>0) {
-
- float d = cull_range.nearp.distance_to(ins->data.transform.origin);
- if (d<0)
- d=0;
- discarded=(d<ins->draw_range_begin || d>=ins->draw_range_end);
-
-
- }
-
- if (!discarded) {
-
- // test if this geometry should be visible
-
- if (room_cull_enabled) {
-
-
- if (ins->visible_in_all_rooms) {
- keep=true;
- } else if (ins->room) {
-
- if (ins->room->room_info->last_visited_pass==render_pass)
- keep=true;
- } else if (ins->auto_rooms.size()) {
-
-
- for(Set<Instance*>::Element *E=ins->auto_rooms.front();E;E=E->next()) {
-
- if (E->get()->room_info->last_visited_pass==render_pass) {
- keep=true;
- break;
- }
- }
- } else if(exterior_visited)
- keep=true;
- } else {
-
- keep=true;
- }
-
-
- }
-
-
- if (keep) {
- // update cull range
- float min,max;
- ins->transformed_aabb.project_range_in_plane(cull_range.nearp,min,max);
-
- if (min<cull_range.min)
- cull_range.min=min;
- if (max>cull_range.max)
- cull_range.max=max;
-
- if (ins->sampled_light && ins->sampled_light->gi_probe_sampler_info->last_pass!=render_pass) {
- if (light_samplers_culled<MAX_LIGHT_SAMPLERS) {
- light_sampler_cull_result[light_samplers_culled++]=ins->sampled_light;
- ins->sampled_light->gi_probe_sampler_info->last_pass=render_pass;
- }
- }
- }
-#endif
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(ins->base_data);
@@ -3467,7 +2892,6 @@ bool VisualServerScene::free(RID p_rid) {
Instance *instance = instance_owner.get(p_rid);
- instance_set_room(p_rid, RID());
instance_set_scenario(p_rid, RID());
instance_set_base(p_rid, RID());
instance_geometry_set_material_override(p_rid, RID());
diff --git a/servers/visual/visual_server_scene.h b/servers/visual/visual_server_scene.h
index 910e75c3e3..177521e267 100644
--- a/servers/visual/visual_server_scene.h
+++ b/servers/visual/visual_server_scene.h
@@ -137,38 +137,6 @@ public:
virtual void camera_set_environment(RID p_camera, RID p_env);
virtual void camera_set_use_vertical_aspect(RID p_camera, bool p_enable);
- /*
-
- struct RoomInfo {
-
- Transform affine_inverse;
- Room *room;
- List<Instance*> owned_geometry_instances;
- List<Instance*> owned_portal_instances;
- List<Instance*> owned_room_instances;
- List<Instance*> owned_light_instances; //not used, but just for the sake of it
- Set<Instance*> disconnected_child_portals;
- Set<Instance*> owned_autoroom_geometry;
- uint64_t last_visited_pass;
- RoomInfo() { last_visited_pass=0; }
-
- };
-
- struct InstancePortal {
-
- Portal *portal;
- Set<Instance*> candidate_set;
- Instance *connected;
- uint64_t last_visited_pass;
-
- Plane plane_cache;
- Vector<Vector3> transformed_point_cache;
-
-
- PortalInfo() { connected=NULL; last_visited_pass=0;}
- };
-*/
-
/* SCENARIO API */
struct Instance;
@@ -236,10 +204,6 @@ public:
float lod_end_hysteresis;
RID lod_instance;
- Instance *room;
- SelfList<Instance> room_item;
- bool visible_in_all_rooms;
-
uint64_t last_render_pass;
uint64_t last_frame_pass;
@@ -263,7 +227,7 @@ public:
}
Instance()
- : scenario_item(this), update_item(this), room_item(this) {
+ : scenario_item(this), update_item(this) {
octree_id = 0;
scenario = NULL;
@@ -281,9 +245,6 @@ public:
lod_begin_hysteresis = 0;
lod_end_hysteresis = 0;
- room = NULL;
- visible_in_all_rooms = false;
-
last_render_pass = 0;
last_frame_pass = 0;
version = 1;
@@ -496,7 +457,6 @@ public:
virtual void instance_attach_skeleton(RID p_instance, RID p_skeleton);
virtual void instance_set_exterior(RID p_instance, bool p_enabled);
- virtual void instance_set_room(RID p_instance, RID p_room);
virtual void instance_set_extra_visibility_margin(RID p_instance, real_t p_margin);
diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h
index ca040e9355..476412a4f1 100644
--- a/servers/visual/visual_server_wrap_mt.h
+++ b/servers/visual/visual_server_wrap_mt.h
@@ -250,23 +250,6 @@ public:
FUNC2(reflection_probe_set_enable_shadows, RID, bool)
FUNC2(reflection_probe_set_cull_mask, RID, uint32_t)
- /* ROOM API */
-
- FUNC0R(RID, room_create)
- FUNC4(room_add_bounds, RID, const PoolVector<Vector2> &, float, const Transform &)
- FUNC1(room_clear_bounds, RID)
-
- /* PORTAL API */
-
- // portals are only (x/y) points, forming a convex shape, which its clockwise
- // order points outside. (z is 0);
-
- FUNC0R(RID, portal_create)
- FUNC2(portal_set_shape, RID, const Vector<Point2> &)
- FUNC2(portal_set_enabled, RID, bool)
- FUNC2(portal_set_disable_distance, RID, float)
- FUNC2(portal_set_disabled_color, RID, const Color &)
-
/* BAKED LIGHT API */
FUNC0R(RID, gi_probe_create)
@@ -438,7 +421,6 @@ public:
FUNC2(instance_attach_skeleton, RID, RID)
FUNC2(instance_set_exterior, RID, bool)
- FUNC2(instance_set_room, RID, RID)
FUNC2(instance_set_extra_visibility_margin, RID, real_t)
diff --git a/servers/visual_server.h b/servers/visual_server.h
index 5e0a390a21..cf32dcd1d5 100644
--- a/servers/visual_server.h
+++ b/servers/visual_server.h
@@ -421,23 +421,6 @@ public:
virtual void reflection_probe_set_enable_shadows(RID p_probe, bool p_enable) = 0;
virtual void reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) = 0;
- /* ROOM API */
-
- virtual RID room_create() = 0;
- virtual void room_add_bounds(RID p_room, const PoolVector<Vector2> &p_convex_polygon, float p_height, const Transform &p_transform) = 0;
- virtual void room_clear_bounds(RID p_room) = 0;
-
- /* PORTAL API */
-
- // portals are only (x/y) points, forming a convex shape, which its clockwise
- // order points outside. (z is 0);
-
- virtual RID portal_create() = 0;
- virtual void portal_set_shape(RID p_portal, const Vector<Point2> &p_shape) = 0;
- virtual void portal_set_enabled(RID p_portal, bool p_enabled) = 0;
- virtual void portal_set_disable_distance(RID p_portal, float p_distance) = 0;
- virtual void portal_set_disabled_color(RID p_portal, const Color &p_color) = 0;
-
/* GI PROBE API */
virtual RID gi_probe_create() = 0;
@@ -709,8 +692,6 @@ public:
INSTANCE_PARTICLES,
INSTANCE_LIGHT,
INSTANCE_REFLECTION_PROBE,
- INSTANCE_ROOM,
- INSTANCE_PORTAL,
INSTANCE_GI_PROBE,
INSTANCE_MAX,
/*INSTANCE_BAKED_LIGHT_SAMPLER,*/
@@ -734,7 +715,6 @@ public:
virtual void instance_attach_skeleton(RID p_instance, RID p_skeleton) = 0;
virtual void instance_set_exterior(RID p_instance, bool p_enabled) = 0;
- virtual void instance_set_room(RID p_instance, RID p_room) = 0;
virtual void instance_set_extra_visibility_margin(RID p_instance, real_t p_margin) = 0;
@@ -744,7 +724,6 @@ public:
virtual Vector<ObjectID> instances_cull_convex(const Vector<Plane> &p_convex, RID p_scenario = RID()) const = 0;
enum InstanceFlags {
- INSTANCE_FLAG_VISIBLE_IN_ALL_ROOMS,
INSTANCE_FLAG_USE_BAKED_LIGHT,
INSTANCE_FLAG_MAX
};