Properly manage drawing of primitives when they lack an area, fixes #8930

This commit is contained in:
Juan Linietsky 2017-08-18 15:11:16 -03:00
parent 3b553377c7
commit 72be8876ea
5 changed files with 26 additions and 13 deletions

View File

@ -47,12 +47,12 @@ public:
real_t get_area() const; /// get area real_t get_area() const; /// get area
_FORCE_INLINE_ bool has_no_area() const { _FORCE_INLINE_ bool has_no_area() const {
return (size.x <= CMP_EPSILON || size.y <= CMP_EPSILON || size.z <= CMP_EPSILON); return (size.x <= 0 || size.y <= 0 || size.z <= 0);
} }
_FORCE_INLINE_ bool has_no_surface() const { _FORCE_INLINE_ bool has_no_surface() const {
return (size.x <= CMP_EPSILON && size.y <= CMP_EPSILON && size.z <= CMP_EPSILON); return (size.x <= 0 && size.y <= 0 && size.z <= 0);
} }
const Vector3 &get_position() const { return position; } const Vector3 &get_position() const { return position; }

View File

@ -222,8 +222,10 @@ void PathSpatialGizmo::redraw() {
//v3p.push_back(r[i]+Vector3(0,0.2,0)); //v3p.push_back(r[i]+Vector3(0,0.2,0));
} }
if (v3p.size() > 1) {
add_lines(v3p, PathEditorPlugin::singleton->path_material); add_lines(v3p, PathEditorPlugin::singleton->path_material);
add_collision_segments(v3p); add_collision_segments(v3p);
}
if (PathEditorPlugin::singleton->get_edited_path() == path) { if (PathEditorPlugin::singleton->get_edited_path() == path) {
v3p.clear(); v3p.clear();
@ -247,11 +249,17 @@ void PathSpatialGizmo::redraw() {
} }
} }
if (v3p.size() > 1) {
add_lines(v3p, PathEditorPlugin::singleton->path_thin_material); add_lines(v3p, PathEditorPlugin::singleton->path_thin_material);
}
if (handles.size()) {
add_handles(handles); add_handles(handles);
}
if (sec_handles.size()) {
add_handles(sec_handles, false, true); add_handles(sec_handles, false, true);
} }
} }
}
PathSpatialGizmo::PathSpatialGizmo(Path *p_path) { PathSpatialGizmo::PathSpatialGizmo(Path *p_path) {

View File

@ -2030,6 +2030,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel
tb->set_tooltip(TTR("Attach a new or existing script for the selected node.")); tb->set_tooltip(TTR("Attach a new or existing script for the selected node."));
tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/attach_script")); tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/attach_script"));
filter_hbc->add_child(tb); filter_hbc->add_child(tb);
tb->hide();
button_create_script = tb; button_create_script = tb;
tb = memnew(ToolButton); tb = memnew(ToolButton);
@ -2038,6 +2039,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel
tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/clear_script")); tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/clear_script"));
filter_hbc->add_child(tb); filter_hbc->add_child(tb);
button_clear_script = tb; button_clear_script = tb;
tb->hide();
scene_tree = memnew(SceneTreeEditor(false, true, true)); scene_tree = memnew(SceneTreeEditor(false, true, true));
vbc->add_child(scene_tree); vbc->add_child(scene_tree);

View File

@ -1048,8 +1048,9 @@ void VisualServerScene::_update_instance(Instance *p_instance) {
VSG::storage->particles_set_emission_transform(p_instance->base, p_instance->transform); VSG::storage->particles_set_emission_transform(p_instance->base, p_instance->transform);
} }
if (p_instance->aabb.has_no_surface()) if (p_instance->aabb.has_no_area()) {
return; return;
}
#if 0 #if 0
if (p_instance->base_type == VS::INSTANCE_PARTICLES) { if (p_instance->base_type == VS::INSTANCE_PARTICLES) {
@ -3278,8 +3279,9 @@ void VisualServerScene::render_probes() {
void VisualServerScene::_update_dirty_instance(Instance *p_instance) { void VisualServerScene::_update_dirty_instance(Instance *p_instance) {
if (p_instance->update_aabb) if (p_instance->update_aabb) {
_update_instance_aabb(p_instance); _update_instance_aabb(p_instance);
}
if (p_instance->update_materials) { if (p_instance->update_materials) {

View File

@ -339,7 +339,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_
if (i == 0) { if (i == 0) {
aabb = Rect2(src[i], Vector2()); aabb = Rect2(src[i], Vector2(0.00001, 0.00001)); //must have a bit of size
} else { } else {
aabb.expand_to(src[i]); aabb.expand_to(src[i]);
@ -355,7 +355,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_
if (i == 0) { if (i == 0) {
aabb = Rect2(src[i], Vector2()); aabb = Rect2(src[i], Vector2(0.00001, 0.00001)); //must have a bit of size
} else { } else {
aabb.expand_to(src[i]); aabb.expand_to(src[i]);
@ -385,7 +385,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_
if (i == 0) { if (i == 0) {
aabb = Rect3(src[i], Vector3()); aabb = Rect3(src[i], Vector3(0.00001, 0.00001, 0.00001));
} else { } else {
aabb.expand_to(src[i]); aabb.expand_to(src[i]);
@ -401,7 +401,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_
if (i == 0) { if (i == 0) {
aabb = Rect3(src[i], Vector3()); aabb = Rect3(src[i], Vector3(0.00001, 0.00001, 0.00001));
} else { } else {
aabb.expand_to(src[i]); aabb.expand_to(src[i]);
@ -735,6 +735,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_
//first //first
bptr[idx] = Rect3(); bptr[idx] = Rect3();
bptr[idx].position = v; bptr[idx].position = v;
bptr[idx].size = Vector3(0.00001, 0.00001, 0.00001); //must have at least a bit of size
any_valid = true; any_valid = true;
} else { } else {
bptr[idx].expand_to(v); bptr[idx].expand_to(v);