Empty Images not displayed in the right Z order in viewport #41117

Closed
opened 2014-07-18 14:38:37 +02:00 by Flavio Perez · 11 comments

System Information
Windows

Blender Version
Broken: 2.71

Short description of error
Using empty Images doesn't display well in Wireframe and Bounding box viewport shading modes : Z Order is messed

Exact steps for others to reproduce the error

  • Create new file
  • Create 3 or 4 empties with image as display type and load textures
  • Switch the viewport shading to wireframe or bounding box
  • The order of the displayed planes is messed (if not, turn around). It looks like the Z is depending on the creation order.

order.jpg

I might be related to https:*developer.blender.org/T28749 and https:*developer.blender.org/T34644 , but I'm not using the Alpha of the images in my case (which I don't care to solve), I just want the right Z order (even if it's grouped by unselected first then selected).

Best regards,
Flavio

**System Information** Windows **Blender Version** Broken: 2.71 **Short description of error** Using empty Images doesn't display well in Wireframe and Bounding box viewport shading modes : Z Order is messed **Exact steps for others to reproduce the error** - Create new file - Create 3 or 4 empties with image as display type and load textures - Switch the viewport shading to wireframe or bounding box - The order of the displayed planes is messed (if not, turn around). It looks like the Z is depending on the creation order. ![order.jpg](https://archive.blender.org/developer/F98398/order.jpg) I might be related to https:*developer.blender.org/T28749 and https:*developer.blender.org/T34644 , but I'm not using the Alpha of the images in my case (which I don't care to solve), I just want the right Z order (even if it's grouped by unselected first then selected). Best regards, Flavio
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @flav-3

Added subscriber: @flav-3

Added subscriber: @mont29

Added subscriber: @mont29

Please always attach a .blend file demonstrating the issue, saves us quite some time!

And I think issue is, since in wire/bbox draw mode we only draw lines, there is no Z sorting done at all…

Please always attach a .blend file demonstrating the issue, saves us quite some time! And I think issue is, since in wire/bbox draw mode we only draw lines, there is no Z sorting done at all…
Author

Sorry, I forgot you can make a blend file including the external textures (...)
Here you have :

exampleEmptyImage.blend

But I expected some kind of answer like that. Umm..

Sorry, I forgot you can make a blend file including the external textures (...) Here you have : [exampleEmptyImage.blend](https://archive.blender.org/developer/F98414/exampleEmptyImage.blend) But I expected some kind of answer like that. Umm..
Bastien Montagne self-assigned this 2014-07-18 16:23:27 +02:00

Thanks, will have a look at that. :)

Thanks, will have a look at that. :)

Added subscriber: @Sergey

Added subscriber: @Sergey

So, issue is indeed ZBuffer is disabled in wire and bbox modes… and we need it for empty images.

Here is a patch that handles this, would like another advice about it though, since it adds another full cycle over base (i.e. all objects in scene)… :/

P91: #41117

diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index d34b3d8..e2abfac 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -752,6 +752,27 @@ static void draw_view_icon(RegionView3D *rv3d, rcti *rect)
 	glDisable(GL_BLEND);
 }
 
+bool view3d_need_zbuf(View3D *v3d, Scene *scene)
+{
+	Base *base;
+
+	if (v3d->drawtype > OB_WIRE) {
+		return true;
+	}
+
+	for (base = scene->base.first; base; base = base->next) {
+		if (v3d->lay & base->lay) {
+			Object *ob = base->object;
+
+			if (ob->type == OB_EMPTY && ob->empty_drawtype == OB_EMPTY_IMAGE) {
+				return true;
+			}
+		}
+	}
+
+	return false;
+}
+
 static const char *view3d_get_name(View3D *v3d, RegionView3D *rv3d)
 {
 	const char *name = NULL;
@@ -1314,7 +1335,7 @@ static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d)
 	}
 #endif
 
-	if (v3d->drawtype > OB_WIRE) v3d->zbuf = true;
+	if (view3d_need_zbuf(v3d, scene)) v3d->zbuf = true;
 	
 	/* dithering and AA break color coding, so disable */
 	glDisable(GL_DITHER);
@@ -2603,7 +2624,7 @@ static void view3d_draw_objects(
 		view3d_draw_clipping(rv3d);
 
 	/* set zbuffer after we draw clipping region */
-	if (v3d->drawtype > OB_WIRE) {
+	if (view3d_need_zbuf(v3d, scene)) {
 		v3d->zbuf = true;
 	}
 	else {
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index 169bc49..4cb9a23 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -186,6 +186,8 @@ void circ(float x, float y, float rad);
 void view3d_update_depths_rect(struct ARegion *ar, struct ViewDepths *d, struct rcti *rect);
 float view3d_depth_near(struct ViewDepths *d);
 
+bool view3d_need_zbuf(struct View3D *v3d, struct Scene *scene);
+
 /* view3d_select.c */
 void VIEW3D_OT_select(struct wmOperatorType *ot);
 void VIEW3D_OT_select_circle(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 716f4b1..2f2e3a7 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -989,7 +989,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b
 	view3d_winmatrix_set(ar, v3d, &rect);
 	mul_m4_m4m4(vc->rv3d->persmat, vc->rv3d->winmat, vc->rv3d->viewmat);
 	
-	if (v3d->drawtype > OB_WIRE) {
+	if (view3d_need_zbuf(v3d, scene)) {
 		v3d->zbuf = true;
 		glEnable(GL_DEPTH_TEST);
 	}
@@ -1073,8 +1073,8 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b
 	view3d_winmatrix_set(ar, v3d, NULL);
 	mul_m4_m4m4(vc->rv3d->persmat, vc->rv3d->winmat, vc->rv3d->viewmat);
 	
-	if (v3d->drawtype > OB_WIRE) {
-		v3d->zbuf = 0;
+	if (v3d->zbuf) {
+		v3d->zbuf = false;
 		glDisable(GL_DEPTH_TEST);
 	}
 // XXX	persp(PERSP_WIN);

So, issue is indeed ZBuffer is disabled in wire and bbox modes… and we need it for empty images. Here is a patch that handles this, would like another advice about it though, since it adds another full cycle over `base` (i.e. all objects in scene)… :/ [P91: #41117](https://archive.blender.org/developer/P91.txt) ```diff diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index d34b3d8..e2abfac 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -752,6 +752,27 @@ static void draw_view_icon(RegionView3D *rv3d, rcti *rect) glDisable(GL_BLEND); } +bool view3d_need_zbuf(View3D *v3d, Scene *scene) +{ + Base *base; + + if (v3d->drawtype > OB_WIRE) { + return true; + } + + for (base = scene->base.first; base; base = base->next) { + if (v3d->lay & base->lay) { + Object *ob = base->object; + + if (ob->type == OB_EMPTY && ob->empty_drawtype == OB_EMPTY_IMAGE) { + return true; + } + } + } + + return false; +} + static const char *view3d_get_name(View3D *v3d, RegionView3D *rv3d) { const char *name = NULL; @@ -1314,7 +1335,7 @@ static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d) } #endif - if (v3d->drawtype > OB_WIRE) v3d->zbuf = true; + if (view3d_need_zbuf(v3d, scene)) v3d->zbuf = true; /* dithering and AA break color coding, so disable */ glDisable(GL_DITHER); @@ -2603,7 +2624,7 @@ static void view3d_draw_objects( view3d_draw_clipping(rv3d); /* set zbuffer after we draw clipping region */ - if (v3d->drawtype > OB_WIRE) { + if (view3d_need_zbuf(v3d, scene)) { v3d->zbuf = true; } else { diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 169bc49..4cb9a23 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -186,6 +186,8 @@ void circ(float x, float y, float rad); void view3d_update_depths_rect(struct ARegion *ar, struct ViewDepths *d, struct rcti *rect); float view3d_depth_near(struct ViewDepths *d); +bool view3d_need_zbuf(struct View3D *v3d, struct Scene *scene); + /* view3d_select.c */ void VIEW3D_OT_select(struct wmOperatorType *ot); void VIEW3D_OT_select_circle(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 716f4b1..2f2e3a7 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -989,7 +989,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b view3d_winmatrix_set(ar, v3d, &rect); mul_m4_m4m4(vc->rv3d->persmat, vc->rv3d->winmat, vc->rv3d->viewmat); - if (v3d->drawtype > OB_WIRE) { + if (view3d_need_zbuf(v3d, scene)) { v3d->zbuf = true; glEnable(GL_DEPTH_TEST); } @@ -1073,8 +1073,8 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b view3d_winmatrix_set(ar, v3d, NULL); mul_m4_m4m4(vc->rv3d->persmat, vc->rv3d->winmat, vc->rv3d->viewmat); - if (v3d->drawtype > OB_WIRE) { - v3d->zbuf = 0; + if (v3d->zbuf) { + v3d->zbuf = false; glDisable(GL_DEPTH_TEST); } // XXX persp(PERSP_WIN); ```

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'

So, as I suspected, this patch has too much influence over wire mode performances…

Closing as TODO/known limitation for now, thanks for the report anyway!

So, as I suspected, this patch has too much influence over wire mode performances… Closing as [TODO/known limitation](http://wiki.blender.org/index.php/Dev:2.5/Source/Development/Todo/Editors#3D_View) for now, thanks for the report anyway!
Author

Thanks for having a look at it !

Let's see if it can be improved in the future.

Thanks for having a look at it ! Let's see if it can be improved in the future.
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#41117
No description provided.