[Bf-blender-cvs] [581b0c9a4f] clay-engine: More Object mode work.
Clément Foucault
noreply at git.blender.org
Tue Jan 31 14:04:35 CET 2017
Commit: 581b0c9a4f80bb56e25622da3e526e7be24ea68a
Author: Clément Foucault
Date: Tue Jan 31 14:01:23 2017 +0100
Branches: clay-engine
https://developer.blender.org/rB581b0c9a4f80bb56e25622da3e526e7be24ea68a
More Object mode work.
===================================================================
M source/blender/blenkernel/BKE_layer.h
M source/blender/draw/engines/clay/clay.c
M source/blender/draw/intern/draw_manager.c
M source/blender/draw/intern/draw_mode_pass.c
M source/blender/draw/intern/draw_mode_pass.h
===================================================================
diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h
index 0f328700bf..ff5b16f208 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -143,6 +143,15 @@ void BKE_visible_bases_Iterator_end(Iterator *iter);
} \
}
+#define FOREACH_BASE(sl, _object_base) \
+{ \
+ for (base = sl->object_bases.first; base; base = base->next) { \
+ _object_base = base;
+
+#define FOREACH_BASE_END \
+ } \
+}
+
#define FOREACH_OBJECT_FLAG(scene, sl, flag, _ob) \
{ \
IteratorBeginCb func_begin; \
diff --git a/source/blender/draw/engines/clay/clay.c b/source/blender/draw/engines/clay/clay.c
index a588412903..dabb500936 100644
--- a/source/blender/draw/engines/clay/clay.c
+++ b/source/blender/draw/engines/clay/clay.c
@@ -529,7 +529,7 @@ static void CLAY_create_cache(CLAY_PassList *passes, const struct bContext *C)
{
SceneLayer *sl = CTX_data_scene_layer(C);
DRWShadingGroup *default_shgrp, *depthbatch;
- Object *ob;
+ ObjectBase *base;
/* Depth Pass */
{
@@ -558,9 +558,10 @@ static void CLAY_create_cache(CLAY_PassList *passes, const struct bContext *C)
}
/* TODO Create hash table of batch based on material id*/
- FOREACH_OBJECT(sl, ob)
+ FOREACH_BASE(sl, base)
{
struct Batch *geom;
+ Object *ob = base->object;
switch (ob->type) {
case OB_MESH:
@@ -583,14 +584,14 @@ static void CLAY_create_cache(CLAY_PassList *passes, const struct bContext *C)
case OB_CAMERA:
case OB_EMPTY:
default:
- DRW_shgroup_non_meshes(passes->non_meshes_pass, ob);
+ DRW_shgroup_non_meshes(passes->non_meshes_pass, base);
break;
}
- DRW_shgroup_object_center(passes->ob_center_pass, ob);
- DRW_shgroup_relationship_lines(passes->non_meshes_pass, ob);
+ DRW_shgroup_object_center(passes->ob_center_pass, base);
+ DRW_shgroup_relationship_lines(passes->non_meshes_pass, base);
}
- FOREACH_OBJECT_END
+ FOREACH_BASE_END
}
static void CLAY_view_draw(RenderEngine *UNUSED(engine), const struct bContext *context)
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 9fc020885d..3fff977bc9 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -544,7 +544,6 @@ static void shgroup_dynamic_batch_from_calls(DRWShadingGroup *shgroup)
#ifdef WITH_VIEWPORT_CACHE_TEST
if (shgroup->dyngeom) return;
#endif
-
if (shgroup->dyntype == DRW_DYN_INSTANCE) {
shgroup_dynamic_batch_instance(shgroup);
}
@@ -786,7 +785,7 @@ static void draw_shgroup(DRWShadingGroup *shgroup)
float obmat[4][4];
unit_m4(obmat);
- if (shgroup->dyntype == DRW_DYN_INSTANCE) {
+ if (shgroup->dyntype == DRW_DYN_INSTANCE && shgroup->instance_count > 0) {
DRWCall *call = shgroup->calls.first;
draw_geometry(shgroup, interface, call->geometry, shgroup->instance_vbo, shgroup->instance_count, obmat);
}
diff --git a/source/blender/draw/intern/draw_mode_pass.c b/source/blender/draw/intern/draw_mode_pass.c
index d8db13925f..c93c9a1610 100644
--- a/source/blender/draw/intern/draw_mode_pass.c
+++ b/source/blender/draw/intern/draw_mode_pass.c
@@ -29,10 +29,30 @@
#include "UI_resources.h"
+#include "BKE_global.h"
+
#include "draw_mode_pass.h"
/* ************************** OBJECT MODE ******************************* */
+/* Store list of shading group for easy access*/
+
+/* Empties */
+static DRWShadingGroup *empty_wire;
+static DRWShadingGroup *empty_active;
+static DRWShadingGroup *empty_select;
+static DRWShadingGroup *empty_transform;
+static DRWShadingGroup *empty_group;
+static DRWShadingGroup *empty_group_active;
+
+/* Helpers */
+static DRWShadingGroup *relationship_lines;
+
+/* Objects Centers */
+static DRWShadingGroup *center_active;
+static DRWShadingGroup *center_selected;
+static DRWShadingGroup *center_deselected;
+
/* This Function setup the passes needed for the mode rendering.
* The passes are populated by the rendering engine using the DRW_shgroup_* functions. */
void DRW_pass_setup_common(DRWPass **wire_overlay, DRWPass **wire_outline, DRWPass **non_meshes, DRWPass **ob_center)
@@ -52,6 +72,22 @@ void DRW_pass_setup_common(DRWPass **wire_overlay, DRWPass **wire_outline, DRWPa
}
if (non_meshes) {
+ static float colorWire[4], colorWireEdit[4];
+ static float colorActive[4], colorSelect[4], colorTransform[4], colorGroup[4], colorGroupActive[4];
+ static float colorEmpty[4], colorLamp[4], colorCamera[4], colorSpeaker[4];
+
+ UI_GetThemeColor4fv(TH_WIRE, colorWire);
+ UI_GetThemeColor4fv(TH_WIRE_EDIT, colorWireEdit);
+ UI_GetThemeColor4fv(TH_ACTIVE, colorActive);
+ UI_GetThemeColor4fv(TH_SELECT, colorSelect);
+ UI_GetThemeColor4fv(TH_TRANSFORM, colorTransform);
+ UI_GetThemeColor4fv(TH_GROUP_ACTIVE, colorGroupActive);
+ UI_GetThemeColor4fv(TH_GROUP, colorGroup);
+ UI_GetThemeColor4fv(OB_LAMP, colorLamp);
+ UI_GetThemeColor4fv(OB_SPEAKER, colorSpeaker);
+ UI_GetThemeColor4fv(OB_CAMERA, colorCamera);
+ UI_GetThemeColor4fv(OB_EMPTY, colorEmpty);
+
/* Non Meshes Pass (Camera, empties, lamps ...) */
DRWShadingGroup *grp;
@@ -69,14 +105,40 @@ void DRW_pass_setup_common(DRWPass **wire_overlay, DRWPass **wire_outline, DRWPa
grp = DRW_shgroup_create(sh, *non_meshes);
/* Empties */
- static float frontcol[4] = {0.0f, 0.0f, 0.0f, 1.0f};
- grp = DRW_shgroup_create(sh_inst, *non_meshes);
- DRW_shgroup_uniform_vec4(grp, "color", frontcol, 1);
- DRW_shgroup_dyntype_set(grp, DRW_DYN_INSTANCE);
+ {
+ grp = DRW_shgroup_create(sh_inst, *non_meshes);
+ DRW_shgroup_uniform_vec4(grp, "color", colorEmpty, 1);
+ DRW_shgroup_dyntype_set(grp, DRW_DYN_INSTANCE);
+ empty_wire = grp;
+
+ grp = DRW_shgroup_create(sh_inst, *non_meshes);
+ DRW_shgroup_uniform_vec4(grp, "color", colorActive, 1);
+ DRW_shgroup_dyntype_set(grp, DRW_DYN_INSTANCE);
+ empty_active = grp;
+
+ grp = DRW_shgroup_create(sh_inst, *non_meshes);
+ DRW_shgroup_uniform_vec4(grp, "color", colorSelect, 1);
+ DRW_shgroup_dyntype_set(grp, DRW_DYN_INSTANCE);
+ empty_select = grp;
+
+ grp = DRW_shgroup_create(sh_inst, *non_meshes);
+ DRW_shgroup_uniform_vec4(grp, "color", colorTransform, 1);
+ DRW_shgroup_dyntype_set(grp, DRW_DYN_INSTANCE);
+ empty_transform = grp;
+
+ grp = DRW_shgroup_create(sh_inst, *non_meshes);
+ DRW_shgroup_uniform_vec4(grp, "color", colorGroup, 1);
+ DRW_shgroup_dyntype_set(grp, DRW_DYN_INSTANCE);
+ empty_group = grp;
+
+ grp = DRW_shgroup_create(sh_inst, *non_meshes);
+ DRW_shgroup_uniform_vec4(grp, "color", colorGroupActive, 1);
+ DRW_shgroup_dyntype_set(grp, DRW_DYN_INSTANCE);
+ empty_group_active = grp;
+ }
/* Stipple Wires */
grp = DRW_shgroup_create(sh, *non_meshes);
- DRW_shgroup_uniform_vec4(grp, "color", frontcol, 1);
DRW_shgroup_state_set(grp, DRW_STATE_STIPPLE_2);
grp = DRW_shgroup_create(sh, *non_meshes);
@@ -86,9 +148,13 @@ void DRW_pass_setup_common(DRWPass **wire_overlay, DRWPass **wire_outline, DRWPa
DRW_shgroup_state_set(grp, DRW_STATE_STIPPLE_4);
/* Relationship Lines */
- grp = DRW_shgroup_create(sh, *non_meshes);
- DRW_shgroup_state_set(grp, DRW_STATE_STIPPLE_3);
- DRW_shgroup_dyntype_set(grp, DRW_DYN_LINES);
+ {
+ grp = DRW_shgroup_create(sh, *non_meshes);
+ DRW_shgroup_uniform_vec4(grp, "color", colorWire, 1);
+ DRW_shgroup_state_set(grp, DRW_STATE_STIPPLE_3);
+ DRW_shgroup_dyntype_set(grp, DRW_DYN_LINES);
+ relationship_lines = grp;
+ }
}
if (ob_center) {
@@ -116,16 +182,19 @@ void DRW_pass_setup_common(DRWPass **wire_overlay, DRWPass **wire_outline, DRWPa
DRW_shgroup_uniform_float(grp, "outlineWidth", &outlineWidth, 1);
DRW_shgroup_uniform_vec4(grp, "color", colorActive, 1);
DRW_shgroup_uniform_vec4(grp, "outlineColor", outlineColor, 1);
+ center_active = grp;
/* Select */
grp = DRW_shgroup_create(sh, *ob_center);
DRW_shgroup_dyntype_set(grp, DRW_DYN_POINTS);
DRW_shgroup_uniform_vec4(grp, "color", colorSelect, 1);
+ center_selected = grp;
/* Deselect */
grp = DRW_shgroup_create(sh, *ob_center);
DRW_shgroup_dyntype_set(grp, DRW_DYN_POINTS);
DRW_shgroup_uniform_vec4(grp, "color", colorDeselect, 1);
+ center_deselected = grp;
}
}
@@ -219,40 +288,106 @@ void DRW_draw_lamp(DRWPass *non_meshes, Object *ob)
/* TODO */
}
-void DRW_shgroup_non_meshes(DRWPass *non_meshes, Object *ob)
+/* TODO FINISH */
+static int draw_object_wire_theme(ObjectBase *base)
+{
+ Object *ob = base->object;
+ const bool is_edit = (ob->mode & OB_MODE_EDIT) != 0;
+ /* confusing logic here, there are 2 methods of setting the color
+ * 'colortab[colindex]' and 'theme_id', colindex overrides theme_id.
+ *
+ * note: no theme yet for 'colindex' */
+ int theme_id = is_edit ? TH_WIRE_EDIT : TH_WIRE;
+
+ if (//(scene->obedit == NULL) &&
+ (G.moving & G_TRANSFORM_OBJ) &&
+ (base->flag & BASE_SELECTED))
+ {
+ theme_id = TH_TRANSFORM;
+ }
+ else {
+ /* Sets the 'theme_id' or fallback to wire */
+ if ((ob->flag & OB_FROMGROUP) != 0) {
+ if (base->flag & BASE_SELECTED) {
+ /* uses darker active color for non-active + selected */
+ theme_id = TH_GROUP_ACTIVE;
+
+ // if (scene->basact != base) {
+ // theme_shade = -16;
+ // }
+ }
+ else {
+ theme_id = TH_GROUP;
+ }
+ }
+ else {
+ if (base->flag & BASE_SELECTED) {
+ theme_id = //scene->basact == base ? TH_ACTIVE :
+ TH_SELECT;
+ }
+ else {
+ if (ob->type == OB_LAMP) theme_id = TH_LAMP;
+ else if (ob->type == OB_SPEAKER) theme_id = TH_SPEAKER;
+ else if (ob->type == OB_CAMERA) theme_id = TH_CAMERA;
+ else if (ob->type == OB_EMPTY) theme_id = TH_EMPTY;
+ /* fallback to TH_WIRE */
+ }
+ }
+ }
+
+ return theme_id;
+}
+
+void DRW_shgroup_non_meshes(DRWP
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list