diff options
author | Jeroen Bakker <j.bakker@atmind.nl> | 2018-04-17 15:59:37 +0300 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2018-04-17 15:59:37 +0300 |
commit | 3759b2aa59ae7ea680b02b15b5cb3534097107a7 (patch) | |
tree | 6f47613340c83dc7bab2e0d29600816289afe12e /source | |
parent | fa687866924fe3b0f24f2f33d12224b9bca8d298 (diff) | |
parent | c991bb0baf60a1bd2ab73dc5ccaf086d95c16955 (diff) |
Merge branch 'blender2.8' into blender2.8-workbench
Diffstat (limited to 'source')
33 files changed, 481 insertions, 119 deletions
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index d2d90801ade..b51c4e17394 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -142,6 +142,14 @@ bool BKE_object_pose_context_check(const struct Object *ob); struct Object *BKE_object_pose_armature_get(struct Object *ob); struct Object *BKE_object_pose_armature_get_visible(struct Object *ob, struct ViewLayer *view_layer); +struct Object **BKE_object_pose_array_get_ex(struct ViewLayer *view_layer, uint *r_objects_len, bool unique); +struct Object **BKE_object_pose_array_get_unique(struct ViewLayer *view_layer, uint *r_objects_len); +struct Object **BKE_object_pose_array_get(struct ViewLayer *view_layer, uint *r_objects_len); + +struct Base **BKE_object_pose_base_array_get_ex(struct ViewLayer *view_layer, uint *r_bases_len, bool unique); +struct Base **BKE_object_pose_base_array_get_unique(struct ViewLayer *view_layer, uint *r_bases_len); +struct Base **BKE_object_pose_base_array_get(struct ViewLayer *view_layer, uint *r_bases_len); + void BKE_object_get_parent_matrix( struct Scene *scene, struct Object *ob, struct Object *par, float parentmat[4][4]); diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index e8fd71c2b2d..27c1eeb3d77 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -31,6 +31,7 @@ set(INC ../blentranslation ../depsgraph ../draw + ../editors/include ../gpu ../ikplugin ../imbuf diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 132f247f0a1..879c4900146 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -81,9 +81,10 @@ static DerivedMesh *navmesh_dm_createNavMeshForVisualization(DerivedMesh *dm); #include "GPU_shader.h" #include "GPU_immediate.h" +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_query.h" + #ifdef WITH_OPENSUBDIV -# include "DEG_depsgraph.h" -# include "DEG_depsgraph_query.h" # include "DNA_userdef_types.h" #endif diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index f59a942c683..8b6ae075f9c 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1233,6 +1233,83 @@ Object *BKE_object_pose_armature_get_visible(Object *ob, ViewLayer *view_layer) } return NULL; } + +/** + * Access pose array with special check to get pose object when in weight paint mode. + */ +Object **BKE_object_pose_array_get_ex(ViewLayer *view_layer, uint *r_objects_len, bool unique) +{ + Object *ob_active = OBACT(view_layer); + Object *ob_pose = BKE_object_pose_armature_get(ob_active); + Object **objects = NULL; + if (ob_pose == ob_active) { + objects = BKE_view_layer_array_from_objects_in_mode( + view_layer, r_objects_len, { + .object_mode = OB_MODE_POSE, + .no_dup_data = unique}); + } + else if (ob_pose != NULL) { + *r_objects_len = 1; + objects = MEM_mallocN(sizeof(*objects), __func__); + objects[0] = ob_pose; + } + else { + *r_objects_len = 0; + objects = MEM_mallocN(0, __func__); + } + return objects; +} +Object **BKE_object_pose_array_get_unique(ViewLayer *view_layer, uint *r_objects_len) +{ + return BKE_object_pose_array_get_ex(view_layer, r_objects_len, true); +} +Object **BKE_object_pose_array_get(ViewLayer *view_layer, uint *r_objects_len) +{ + return BKE_object_pose_array_get_ex(view_layer, r_objects_len, false); +} + +Base **BKE_object_pose_base_array_get_ex(ViewLayer *view_layer, uint *r_bases_len, bool unique) +{ + Base *base_active = BASACT(view_layer); + Object *ob_pose = base_active ? BKE_object_pose_armature_get(base_active->object) : NULL; + Base *base_pose = NULL; + Base **bases = NULL; + + if (base_active) { + if (ob_pose == base_active->object) { + base_pose = base_active; + } + else { + base_pose = BKE_view_layer_base_find(view_layer, ob_pose); + } + } + + if (base_active && (base_pose == base_active)) { + bases = BKE_view_layer_array_from_bases_in_mode( + view_layer, r_bases_len, { + .object_mode = OB_MODE_POSE, + .no_dup_data = unique}); + } + else if (base_pose != NULL) { + *r_bases_len = 1; + bases = MEM_mallocN(sizeof(*bases), __func__); + bases[0] = base_pose; + } + else { + *r_bases_len = 0; + bases = MEM_mallocN(0, __func__); + } + return bases; +} +Base **BKE_object_pose_base_array_get_unique(ViewLayer *view_layer, uint *r_bases_len) +{ + return BKE_object_pose_base_array_get_ex(view_layer, r_bases_len, true); +} +Base **BKE_object_pose_base_array_get(ViewLayer *view_layer, uint *r_bases_len) +{ + return BKE_object_pose_base_array_get_ex(view_layer, r_bases_len, false); +} + void BKE_object_transform_copy(Object *ob_tar, const Object *ob_src) { copy_v3_v3(ob_tar->loc, ob_src->loc); diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index cbc3b17a5c2..e1e24a24245 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -2618,7 +2618,7 @@ void psys_cache_edit_paths(Depsgraph *depsgraph, Scene *scene, Object *ob, PTCac if (!cache || edit->totpoint != edit->totcached) { /* clear out old and create new empty path cache */ - psys_free_path_cache(edit->psys, edit); + psys_free_path_cache(NULL, edit); cache = edit->pathcache = psys_alloc_path_cache_buffers(&edit->pathcachebufs, totpart, segments + 1); /* set flag for update (child particles check this too) */ diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index b9361f3499b..edc3f2e42fd 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -96,6 +96,8 @@ #include "RE_shader_ext.h" +#include "ED_particle.h" + /* fluid sim particle import */ #ifdef WITH_MOD_FLUID #include "DNA_object_fluidsim_types.h" @@ -2906,9 +2908,7 @@ static void psys_update_path_cache(ParticleSimulationData *sim, float cfra, cons { ParticleSystem *psys = sim->psys; ParticleSettings *part = psys->part; -#if 0 ParticleEditSettings *pset = &sim->scene->toolsettings->particle; -#endif int distr=0, alloc=0, skip=0; if ((psys->part->childtype && psys->totchild != psys_get_tot_child(sim->scene, psys, use_render_params)) || psys->recalc&PSYS_RECALC_RESET) @@ -2944,14 +2944,14 @@ static void psys_update_path_cache(ParticleSimulationData *sim, float cfra, cons else if (psys->pointcache->flag & PTCACHE_BAKING) skip = 1; /* no need to cache paths while baking dynamics */ -#if 0 /* TODO(mai): something is very wrong with these conditionals, they dont make sense and the cache isnt updating */ else if (psys_in_edit_mode(sim->depsgraph, psys)) { if ((pset->flag & PE_DRAW_PART)==0) skip = 1; +#if 0 /* TODO(mai): something is very wrong with these conditionals, they dont make sense and the cache isnt updating */ else if (part->childtype==0 && (psys->flag & PSYS_HAIR_DYNAMICS && psys->pointcache->flag & PTCACHE_BAKED)==0) skip = 1; /* in edit mode paths are needed for child particles and dynamic hair */ - } #endif + } } @@ -4384,6 +4384,22 @@ void particle_system_update(struct Depsgraph *depsgraph, Scene *scene, Object *o /* save matrix for duplicators, at rendertime the actual dupliobject's matrix is used so don't update! */ invert_m4_m4(psys->imat, ob->obmat); + if (ob->mode & OB_MODE_PARTICLE_EDIT && ob == OBACT(DEG_get_evaluated_view_layer(depsgraph))) { + PTCacheEdit *edit = PE_create_current(depsgraph, scene, ob); + + if (edit && edit->psys == psys) { + if (edit->psys && edit->psys->flag & PSYS_HAIR_UPDATED) { + PE_update_object(depsgraph, scene, ob, 0); + } + + /* create path and child path cache if it doesn't exist already */ + if (edit->pathcache == NULL) { + psys_cache_edit_paths(depsgraph, scene, ob, edit, DEG_get_ctime(depsgraph), DEG_get_mode(depsgraph) == DAG_EVAL_RENDER); + + } + } + } + BKE_particle_batch_cache_dirty(psys, BKE_PARTICLE_BATCH_DIRTY_ALL); } diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h index bbd7fdb9a63..2ed0a92d89c 100644 --- a/source/blender/collada/AnimationExporter.h +++ b/source/blender/collada/AnimationExporter.h @@ -91,8 +91,8 @@ private: public: AnimationExporter(Depsgraph *depsgraph, COLLADASW::StreamWriter *sw, const ExportSettings *export_settings): - depsgraph(depsgraph), COLLADASW::LibraryAnimations(sw), + depsgraph(depsgraph), export_settings(export_settings) { this->sw = sw; diff --git a/source/blender/collada/DocumentExporter.h b/source/blender/collada/DocumentExporter.h index b420140c3bf..c98f82e68b4 100644 --- a/source/blender/collada/DocumentExporter.h +++ b/source/blender/collada/DocumentExporter.h @@ -44,8 +44,8 @@ class DocumentExporter void exportScenes(const char *filename); private: - const ExportSettings *export_settings; Depsgraph *depsgraph; + const ExportSettings *export_settings; }; #endif diff --git a/source/blender/collada/TransformWriter.cpp b/source/blender/collada/TransformWriter.cpp index 84817d76073..1fb54e99147 100644 --- a/source/blender/collada/TransformWriter.cpp +++ b/source/blender/collada/TransformWriter.cpp @@ -26,8 +26,10 @@ */ -#include "BKE_object.h" #include "BLI_math.h" +#include "BLI_sys_types.h" + +#include "BKE_object.h" #include "TransformWriter.h" diff --git a/source/blender/depsgraph/intern/depsgraph_query.cc b/source/blender/depsgraph/intern/depsgraph_query.cc index 6f0ba26c8f7..3bffbf4d88e 100644 --- a/source/blender/depsgraph/intern/depsgraph_query.cc +++ b/source/blender/depsgraph/intern/depsgraph_query.cc @@ -151,6 +151,9 @@ Object *DEG_get_evaluated_object(const Depsgraph *depsgraph, Object *object) ID *DEG_get_evaluated_id(const Depsgraph *depsgraph, ID *id) { + if (id == NULL) { + return NULL; + } /* TODO(sergey): This is a duplicate of Depsgraph::get_cow_id(), * but here we never do assert, since we don't know nature of the * incoming ID datablock. diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc index 6a6ebd1be44..bf5d594f97e 100644 --- a/source/blender/depsgraph/intern/depsgraph_tag.cc +++ b/source/blender/depsgraph/intern/depsgraph_tag.cc @@ -410,7 +410,7 @@ void deg_graph_id_tag_update(Main *bmain, Depsgraph *graph, ID *id, int flag) } deg_graph_id_tag_legacy_compat(bmain, id, (eDepsgraph_Tag)0); } - id->recalc |= flag; + id->recalc |= (flag & PSYS_RECALC); int current_flag = flag; while (current_flag != 0) { eDepsgraph_Tag tag = diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc index 91790522590..f6a37c49d32 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc @@ -649,7 +649,9 @@ ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph, * everything is done by node tree update function which * only copies socket values. */ - const int ignore_flag = (ID_RECALC_DRAW | ID_RECALC_ANIMATION); + const int ignore_flag = (ID_RECALC_DRAW | + ID_RECALC_ANIMATION | + ID_RECALC_COPY_ON_WRITE); if ((id_cow->recalc & ~ignore_flag) == 0) { return id_cow; } diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index 27f2d891cc0..1f1c7f322f4 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -379,6 +379,8 @@ void DRW_shgroup_uniform_ivec2(DRWShadingGroup *shgroup, const char *name, const void DRW_shgroup_uniform_ivec3(DRWShadingGroup *shgroup, const char *name, const int *value, int arraysize); void DRW_shgroup_uniform_mat3(DRWShadingGroup *shgroup, const char *name, const float *value); void DRW_shgroup_uniform_mat4(DRWShadingGroup *shgroup, const char *name, const float *value); +/* Store value instead of referencing it. */ +void DRW_shgroup_uniform_int_copy(DRWShadingGroup *shgroup, const char *name, const int value); /* Passes */ DRWPass *DRW_pass_create(const char *name, DRWState state); diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c index 8d23688959c..68a82d017cf 100644 --- a/source/blender/draw/intern/draw_common.c +++ b/source/blender/draw/intern/draw_common.c @@ -332,6 +332,22 @@ DRWShadingGroup *shgroup_instance(DRWPass *pass, struct Gwn_Batch *geom) return grp; } +DRWShadingGroup *shgroup_instance_outline(DRWPass *pass, struct Gwn_Batch *geom, int *baseid) +{ + GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_INSTANCE_VARIYING_ID_VARIYING_SIZE); + + DRW_shgroup_instance_format(g_formats.instance_sized, { + {"callId" , DRW_ATTRIB_INT, 1}, + {"size" , DRW_ATTRIB_FLOAT, 1}, + {"InstanceModelMatrix", DRW_ATTRIB_FLOAT, 16} + }); + + DRWShadingGroup *grp = DRW_shgroup_instance_create(sh_inst, pass, geom, g_formats.instance_sized); + DRW_shgroup_uniform_int(grp, "baseId", baseid, 1); + + return grp; +} + DRWShadingGroup *shgroup_camera_instance(DRWPass *pass, struct Gwn_Batch *geom) { GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_CAMERA); diff --git a/source/blender/draw/intern/draw_common.h b/source/blender/draw/intern/draw_common.h index ec646693207..c70a1a38e62 100644 --- a/source/blender/draw/intern/draw_common.h +++ b/source/blender/draw/intern/draw_common.h @@ -114,6 +114,7 @@ struct DRWShadingGroup *shgroup_instance_axis_names(struct DRWPass *pass, struct struct DRWShadingGroup *shgroup_instance_image_plane(struct DRWPass *pass, struct Gwn_Batch *geom); struct DRWShadingGroup *shgroup_instance_scaled(struct DRWPass *pass, struct Gwn_Batch *geom); struct DRWShadingGroup *shgroup_instance(struct DRWPass *pass, struct Gwn_Batch *geom); +struct DRWShadingGroup *shgroup_instance_outline(struct DRWPass *pass, struct Gwn_Batch *geom, int *baseid); struct DRWShadingGroup *shgroup_camera_instance(struct DRWPass *pass, struct Gwn_Batch *geom); struct DRWShadingGroup *shgroup_distance_lines_instance(struct DRWPass *pass, struct Gwn_Batch *geom); struct DRWShadingGroup *shgroup_spot_instance(struct DRWPass *pass, struct Gwn_Batch *geom); diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h index 4f322b11931..fd75405f346 100644 --- a/source/blender/draw/intern/draw_manager.h +++ b/source/blender/draw/intern/draw_manager.h @@ -157,6 +157,7 @@ typedef enum { DRW_UNIFORM_SHORT_TO_INT, DRW_UNIFORM_SHORT_TO_FLOAT, DRW_UNIFORM_INT, + DRW_UNIFORM_INT_COPY, DRW_UNIFORM_FLOAT, DRW_UNIFORM_TEXTURE, DRW_UNIFORM_TEXTURE_PERSIST, diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c index 544129ea124..74f39cf9073 100644 --- a/source/blender/draw/intern/draw_manager_data.c +++ b/source/blender/draw/intern/draw_manager_data.c @@ -211,6 +211,12 @@ void DRW_shgroup_uniform_mat4(DRWShadingGroup *shgroup, const char *name, const drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_FLOAT, value, 16, 1); } +/* Stores the int instead of a pointer. */ +void DRW_shgroup_uniform_int_copy(DRWShadingGroup *shgroup, const char *name, const int value) +{ + drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_INT_COPY, SET_INT_IN_POINTER(value), 1, 1); +} + /** \} */ /* -------------------------------------------------------------------- */ diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c index dcd976805fd..3716c9d9acf 100644 --- a/source/blender/draw/intern/draw_manager_exec.c +++ b/source/blender/draw/intern/draw_manager_exec.c @@ -873,7 +873,12 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state) case DRW_UNIFORM_SHORT_TO_INT: val = (int)*((short *)uni->value); GPU_shader_uniform_vector_int( - shgroup->shader, uni->location, uni->length, uni->arraysize, (int *)&val); + shgroup->shader, uni->location, uni->length, uni->arraysize, &val); + break; + case DRW_UNIFORM_INT_COPY: + val = GET_INT_FROM_POINTER(uni->value); + GPU_shader_uniform_vector_int( + shgroup->shader, uni->location, uni->length, uni->arraysize, &val); break; case DRW_UNIFORM_SHORT_TO_FLOAT: fval = (float)*((short *)uni->value); diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index 0d9e46d1268..c9ef8640031 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -86,6 +86,7 @@ extern char datatoc_object_particle_dot_frag_glsl[]; extern char datatoc_common_globals_lib_glsl[]; extern char datatoc_common_fxaa_lib_glsl[]; extern char datatoc_gpu_shader_flat_color_frag_glsl[]; +extern char datatoc_gpu_shader_flat_id_frag_glsl[]; extern char datatoc_common_fullscreen_vert_glsl[]; extern char datatoc_gpu_shader_uniform_color_frag_glsl[]; @@ -208,8 +209,17 @@ typedef struct OBJECT_PrivateData { DRWShadingGroup *outlines_transform; /* Lightprobes */ - DRWShadingGroup *lightprobes_cube; - DRWShadingGroup *lightprobes_planar; + DRWShadingGroup *lightprobes_cube_select; + DRWShadingGroup *lightprobes_cube_select_group; + DRWShadingGroup *lightprobes_cube_active; + DRWShadingGroup *lightprobes_cube_active_group; + DRWShadingGroup *lightprobes_cube_transform; + + DRWShadingGroup *lightprobes_planar_select; + DRWShadingGroup *lightprobes_planar_select_group; + DRWShadingGroup *lightprobes_planar_active; + DRWShadingGroup *lightprobes_planar_active_group; + DRWShadingGroup *lightprobes_planar_transform; /* Wire */ DRWShadingGroup *wire; @@ -233,6 +243,11 @@ typedef struct OBJECT_PrivateData { int id_ofs_select; int id_ofs_select_group; int id_ofs_transform; + int id_ofs_prb_active; + int id_ofs_prb_active_group; + int id_ofs_prb_select; + int id_ofs_prb_select_group; + int id_ofs_prb_transform; } OBJECT_PrivateData; /* Transient data */ static struct { @@ -346,7 +361,7 @@ static void OBJECT_engine_init(void *vedata) datatoc_common_fullscreen_vert_glsl, NULL, datatoc_object_outline_detect_frag_glsl, datatoc_common_globals_lib_glsl, - NULL); + "#extension GL_ARB_texture_gather : enable\n"); e_data.outline_fade_sh = DRW_shader_create_fullscreen(datatoc_object_outline_expand_frag_glsl, NULL); @@ -381,7 +396,7 @@ static void OBJECT_engine_init(void *vedata) /* Lightprobes */ e_data.lightprobe_grid_sh = DRW_shader_create( - datatoc_object_lightprobe_grid_vert_glsl, NULL, datatoc_gpu_shader_uniform_color_frag_glsl, NULL); + datatoc_object_lightprobe_grid_vert_glsl, NULL, datatoc_gpu_shader_flat_id_frag_glsl, NULL); } { @@ -608,24 +623,96 @@ static DRWShadingGroup *shgroup_points(DRWPass *pass, const float col[4], GPUSha return grp; } +static int *shgroup_theme_id_to_probe_outline_counter( + OBJECT_StorageList *stl, int theme_id) +{ + switch (theme_id) { + case TH_ACTIVE: + return &stl->g_data->id_ofs_prb_active; + case TH_SELECT: + return &stl->g_data->id_ofs_prb_select; + case TH_GROUP: + return &stl->g_data->id_ofs_prb_select_group; + case TH_GROUP_ACTIVE: + return &stl->g_data->id_ofs_prb_active_group; + case TH_TRANSFORM: + default: + return &stl->g_data->id_ofs_prb_transform; + } +} + +static int *shgroup_theme_id_to_outline_counter( + OBJECT_StorageList *stl, int theme_id) +{ + switch (theme_id) { + case TH_ACTIVE: + return &stl->g_data->id_ofs_active; + case TH_SELECT: + return &stl->g_data->id_ofs_select; + case TH_GROUP: + return &stl->g_data->id_ofs_select_group; + case TH_GROUP_ACTIVE: + return &stl->g_data->id_ofs_active_group; + case TH_TRANSFORM: + default: + return &stl->g_data->id_ofs_transform; + } +} + +static DRWShadingGroup *shgroup_theme_id_to_probe_planar_outline_shgrp( + OBJECT_StorageList *stl, int theme_id) +{ + /* does not increment counter */ + switch (theme_id) { + case TH_ACTIVE: + return stl->g_data->lightprobes_planar_active; + case TH_SELECT: + return stl->g_data->lightprobes_planar_select; + case TH_GROUP: + return stl->g_data->lightprobes_planar_select_group; + case TH_GROUP_ACTIVE: + return stl->g_data->lightprobes_planar_active_group; + case TH_TRANSFORM: + default: + return stl->g_data->lightprobes_planar_transform; + } +} + +static DRWShadingGroup *shgroup_theme_id_to_probe_cube_outline_shgrp( + OBJECT_StorageList *stl, int theme_id) +{ + /* does not increment counter */ + switch (theme_id) { + case TH_ACTIVE: + return stl->g_data->lightprobes_cube_active; + case TH_SELECT: + return stl->g_data->lightprobes_cube_select; + case TH_GROUP: + return stl->g_data->lightprobes_cube_select_group; + case TH_GROUP_ACTIVE: + return stl->g_data->lightprobes_cube_active_group; + case TH_TRANSFORM: + default: + return stl->g_data->lightprobes_cube_transform; + } +} + static DRWShadingGroup *shgroup_theme_id_to_outline_or( OBJECT_StorageList *stl, int theme_id, DRWShadingGroup *fallback) { + int *counter = shgroup_theme_id_to_outline_counter(stl, theme_id); + *counter += 1; + switch (theme_id) { case TH_ACTIVE: - stl->g_data->id_ofs_active++; return stl->g_data->outlines_active; case TH_SELECT: - stl->g_data->id_ofs_select++; return stl->g_data->outlines_select; case TH_GROUP: - stl->g_data->id_ofs_select_group++; return stl->g_data->outlines_select_group; case TH_GROUP_ACTIVE: - stl->g_data->id_ofs_active_group++; return stl->g_data->outlines_active_group; case TH_TRANSFORM: - stl->g_data->id_ofs_transform++; return stl->g_data->outlines_transform; default: return fallback; @@ -798,12 +885,15 @@ static void OBJECT_cache_init(void *vedata) OBJECT_PassList *psl = ((OBJECT_Data *)vedata)->psl; OBJECT_StorageList *stl = ((OBJECT_Data *)vedata)->stl; DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); + OBJECT_PrivateData *g_data; if (!stl->g_data) { /* Alloc transient pointers */ stl->g_data = MEM_mallocN(sizeof(*stl->g_data), __func__); } + g_data = stl->g_data; + { DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_WIRE; psl->outlines = DRW_pass_create("Outlines Depth Pass", state); @@ -811,32 +901,48 @@ static void OBJECT_cache_init(void *vedata) GPUShader *sh = e_data.outline_prepass_sh; /* Select */ - stl->g_data->outlines_select = shgroup_outline(psl->outlines, &stl->g_data->id_ofs_select, sh); - stl->g_data->outlines_select_group = shgroup_outline(psl->outlines, &stl->g_data->id_ofs_select_group, sh); + g_data->outlines_select = shgroup_outline(psl->outlines, &g_data->id_ofs_select, sh); + g_data->outlines_select_group = shgroup_outline(psl->outlines, &g_data->id_ofs_select_group, sh); /* Transform */ - stl->g_data->outlines_transform = shgroup_outline(psl->outlines, &stl->g_data->id_ofs_transform, sh); + g_data->outlines_transform = shgroup_outline(psl->outlines, &g_data->id_ofs_transform, sh); /* Active */ - stl->g_data->outlines_active = shgroup_outline(psl->outlines, &stl->g_data->id_ofs_active, sh); - stl->g_data->outlines_active_group = shgroup_outline(psl->outlines, &stl->g_data->id_ofs_active_group, sh); + g_data->outlines_active = shgroup_outline(psl->outlines, &g_data->id_ofs_active, sh); + g_data->outlines_active_group = shgroup_outline(psl->outlines, &g_data->id_ofs_active_group, sh); - stl->g_data->id_ofs_select = 0; - stl->g_data->id_ofs_select_group = 0; - stl->g_data->id_ofs_active = 0; - stl->g_data->id_ofs_active_group = 0; - stl->g_data->id_ofs_transform = 0; + g_data->id_ofs_select = 0; + g_data->id_ofs_select_group = 0; + g_data->id_ofs_active = 0; + g_data->id_ofs_active_group = 0; + g_data->id_ofs_transform = 0; } { DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS; - psl->lightprobes = DRW_pass_create("Object Probe Pass", state); + DRWPass *pass = psl->lightprobes = DRW_pass_create("Object Probe Pass", state); + struct Gwn_Batch *sphere = DRW_cache_sphere_get(); + struct Gwn_Batch *quad = DRW_cache_quad_get(); /* Cubemap */ - stl->g_data->lightprobes_cube = shgroup_instance(psl->lightprobes, DRW_cache_sphere_get()); + g_data->lightprobes_cube_select = shgroup_instance_outline(pass, sphere, &g_data->id_ofs_prb_select); + g_data->lightprobes_cube_select_group = shgroup_instance_outline(pass, sphere, &g_data->id_ofs_prb_select_group); + g_data->lightprobes_cube_active = shgroup_instance_outline(pass, sphere, &g_data->id_ofs_prb_active); + g_data->lightprobes_cube_active_group = shgroup_instance_outline(pass, sphere, &g_data->id_ofs_prb_active_group); + g_data->lightprobes_cube_transform = shgroup_instance_outline(pass, sphere, &g_data->id_ofs_prb_transform); /* Planar */ - stl->g_data->lightprobes_planar = shgroup_instance(psl->lightprobes, DRW_cache_quad_get()); + g_data->lightprobes_planar_select = shgroup_instance_outline(pass, quad, &g_data->id_ofs_prb_select); + g_data->lightprobes_planar_select_group = shgroup_instance_outline(pass, quad, &g_data->id_ofs_prb_select_group); + g_data->lightprobes_planar_active = shgroup_instance_outline(pass, quad, &g_data->id_ofs_prb_active); + g_data->lightprobes_planar_active_group = shgroup_instance_outline(pass, quad, &g_data->id_ofs_prb_active_group); + g_data->lightprobes_planar_transform = shgroup_instance_outline(pass, quad, &g_data->id_ofs_prb_transform); + + g_data->id_ofs_prb_select = 0; + g_data->id_ofs_prb_select_group = 0; + g_data->id_ofs_prb_active = 0; + g_data->id_ofs_prb_active_group = 0; + g_data->id_ofs_prb_transform = 0; } { @@ -1596,7 +1702,7 @@ static void DRW_shgroup_lightprobe(OBJECT_StorageList *stl, OBJECT_PassList *psl static float one = 1.0f; LightProbe *prb = (LightProbe *)ob->data; bool do_outlines = ((ob->base_flag & BASE_SELECTED) != 0); - DRW_object_wire_theme_get(ob, view_layer, &color); + int theme_id = DRW_object_wire_theme_get(ob, view_layer, &color); OBJECT_LightProbeEngineData *prb_data = (OBJECT_LightProbeEngineData *)DRW_object_engine_data_ensure( @@ -1607,6 +1713,7 @@ static void DRW_shgroup_lightprobe(OBJECT_StorageList *stl, OBJECT_PassList *psl NULL); if ((DRW_state_is_select() || do_outlines) && ((prb->flag & LIGHTPROBE_FLAG_SHOW_DATA) != 0)) { + int *call_id = shgroup_theme_id_to_probe_outline_counter(stl, theme_id); if (prb->type == LIGHTPROBE_TYPE_GRID) { /* Update transforms */ @@ -1643,7 +1750,8 @@ static void DRW_shgroup_lightprobe(OBJECT_StorageList *stl, OBJECT_PassList *psl prb_data->cell_count = prb->grid_resolution_x * prb->grid_resolution_y * prb->grid_resolution_z; DRWShadingGroup *grp = DRW_shgroup_create(e_data.lightprobe_grid_sh, psl->lightprobes); - DRW_shgroup_uniform_vec4(grp, "color", color, 1); + DRW_shgroup_uniform_int_copy(grp, "call_id", *call_id); + DRW_shgroup_uniform_int(grp, "baseId", call_id, 1); /* that's correct */ DRW_shgroup_uniform_vec3(grp, "corner", prb_data->corner, 1); DRW_shgroup_uniform_vec3(grp, "increment_x", prb_data->increment_x, 1); DRW_shgroup_uniform_vec3(grp, "increment_y", prb_data->increment_y, 1); @@ -1656,12 +1764,18 @@ static void DRW_shgroup_lightprobe(OBJECT_StorageList *stl, OBJECT_PassList *psl prb_data->draw_size = prb->data_draw_size * 0.1f; unit_m4(prb_data->probe_cube_mat); copy_v3_v3(prb_data->probe_cube_mat[3], ob->obmat[3]); - DRW_shgroup_call_dynamic_add(stl->g_data->lightprobes_cube, color, &prb_data->draw_size, prb_data->probe_cube_mat); + + DRWShadingGroup *grp = shgroup_theme_id_to_probe_cube_outline_shgrp(stl, theme_id); + DRW_shgroup_call_dynamic_add(grp, call_id, &prb_data->draw_size, prb_data->probe_cube_mat); } else { prb_data->draw_size = 1.0f; - DRW_shgroup_call_dynamic_add(stl->g_data->lightprobes_planar, color, &prb_data->draw_size, ob->obmat); + + DRWShadingGroup *grp = shgroup_theme_id_to_probe_planar_outline_shgrp(stl, theme_id); + DRW_shgroup_call_dynamic_add(grp, call_id, &prb_data->draw_size, ob->obmat); } + + *call_id += 1; } switch (prb->type) { @@ -2072,21 +2186,37 @@ static void OBJECT_draw_scene(void *vedata) DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); + int id_ct_select = g_data->id_ofs_select; + int id_ct_select_group = g_data->id_ofs_select_group; + int id_ct_active = g_data->id_ofs_active; + int id_ct_active_group = g_data->id_ofs_active_group; + int id_ct_transform = g_data->id_ofs_transform; + + int id_ct_prb_select = g_data->id_ofs_prb_select; + int id_ct_prb_select_group = g_data->id_ofs_prb_select_group; + int id_ct_prb_active = g_data->id_ofs_prb_active; + int id_ct_prb_active_group = g_data->id_ofs_prb_active_group; + int id_ct_prb_transform = g_data->id_ofs_prb_transform; + + int outline_calls = id_ct_select + id_ct_select_group + id_ct_active + id_ct_active_group + id_ct_transform; + outline_calls += id_ct_prb_select + id_ct_prb_select_group + id_ct_prb_active + id_ct_prb_active_group + id_ct_prb_transform; + float clearcol[4] = {0.0f, 0.0f, 0.0f, 0.0f}; - if (DRW_state_is_fbo()) { + if (DRW_state_is_fbo() && outline_calls > 0) { DRW_stats_group_start("Outlines"); - int id_ct_select = g_data->id_ofs_select; - int id_ct_select_group = g_data->id_ofs_select_group; - int id_ct_active = g_data->id_ofs_active; - int id_ct_active_group = g_data->id_ofs_active_group; - g_data->id_ofs_active = 1; - g_data->id_ofs_active_group = g_data->id_ofs_active + id_ct_active + 1; - g_data->id_ofs_select = g_data->id_ofs_active_group + id_ct_active_group + 1; - g_data->id_ofs_select_group = g_data->id_ofs_select + id_ct_select + 1; - g_data->id_ofs_transform = g_data->id_ofs_select_group + id_ct_select_group + 1; + g_data->id_ofs_active_group = g_data->id_ofs_active + id_ct_active + id_ct_prb_active + 1; + g_data->id_ofs_select = g_data->id_ofs_active_group + id_ct_active_group + id_ct_prb_active_group + 1; + g_data->id_ofs_select_group = g_data->id_ofs_select + id_ct_select + id_ct_prb_select + 1; + g_data->id_ofs_transform = g_data->id_ofs_select_group + id_ct_select_group + id_ct_prb_select_group + 1; + + g_data->id_ofs_prb_active = g_data->id_ofs_active + id_ct_active; + g_data->id_ofs_prb_active_group = g_data->id_ofs_active_group + id_ct_active_group; + g_data->id_ofs_prb_select = g_data->id_ofs_select + id_ct_select; + g_data->id_ofs_prb_select_group = g_data->id_ofs_select_group + id_ct_select_group; + g_data->id_ofs_prb_transform = g_data->id_ofs_transform + id_ct_transform; /* Render filled polygon on a separate framebuffer */ GPU_framebuffer_bind(fbl->outlines_fb); @@ -2137,7 +2267,9 @@ static void OBJECT_draw_scene(void *vedata) } /* Combine with scene buffer last */ - DRW_draw_pass(psl->outlines_resolve); + if (outline_calls > 0) { + DRW_draw_pass(psl->outlines_resolve); + } } /* This has to be freed only after drawing empties! */ diff --git a/source/blender/draw/modes/shaders/object_lightprobe_grid_vert.glsl b/source/blender/draw/modes/shaders/object_lightprobe_grid_vert.glsl index b47b3ee1cf4..85a656df906 100644 --- a/source/blender/draw/modes/shaders/object_lightprobe_grid_vert.glsl +++ b/source/blender/draw/modes/shaders/object_lightprobe_grid_vert.glsl @@ -11,6 +11,11 @@ uniform vec3 increment_x; uniform vec3 increment_y; uniform vec3 increment_z; +uniform int call_id; /* we don't want the builtin callId which would be 0. */ +uniform int baseId; + +flat out uint finalId; + void main() { vec3 ls_cell_location; @@ -25,4 +30,6 @@ void main() increment_z * ls_cell_location.z); gl_Position = ViewProjectionMatrix * vec4(pos * 0.02 * sphere_size + ws_cell_location, 1.0); + + finalId = uint(baseId + call_id); }
\ No newline at end of file diff --git a/source/blender/draw/modes/shaders/object_outline_detect_frag.glsl b/source/blender/draw/modes/shaders/object_outline_detect_frag.glsl index 6b0f66d7c94..a7e68485b86 100644 --- a/source/blender/draw/modes/shaders/object_outline_detect_frag.glsl +++ b/source/blender/draw/modes/shaders/object_outline_detect_frag.glsl @@ -34,25 +34,28 @@ vec4 convert_id_to_color(int id) } } -const ivec2 ofs[4] = ivec2[4]( - ivec2( 1, 0), ivec2( 0, 1), - ivec2(-1, 0), ivec2( 0, -1) -); - void main() { ivec2 texel = ivec2(gl_FragCoord.xy); - vec2 uv = gl_FragCoord.xy / vec2(textureSize(outlineId, 0).xy); +#ifdef GL_ARB_texture_gather + vec2 texel_size = 1.0 / vec2(textureSize(outlineId, 0).xy); + vec2 uv1 = gl_FragCoord.xy * texel_size - texel_size; + vec2 uv2 = gl_FragCoord.xy * texel_size; + + /* Samples order is CW starting from top left. */ + uvec4 tmp1 = textureGather(outlineId, uv1); + uvec4 tmp2 = textureGather(outlineId, uv2); + + uint ref_id = tmp1.y; + uvec4 id = uvec4(tmp1.xz, tmp2.xz); +#else uvec4 id; uint ref_id = texelFetch(outlineId, texel, 0).r; -#if 0 /* commented out until being tested */ - id = textureGatherOffsets(outlineId, uv, ofs); -#else - id.x = texelFetchOffset(outlineId, texel, 0, ofs[0]).r; - id.y = texelFetchOffset(outlineId, texel, 0, ofs[1]).r; - id.z = texelFetchOffset(outlineId, texel, 0, ofs[2]).r; - id.w = texelFetchOffset(outlineId, texel, 0, ofs[3]).r; + id.x = texelFetchOffset(outlineId, texel, 0, ivec2( 1, 0)).r; + id.y = texelFetchOffset(outlineId, texel, 0, ivec2( 0, 1)).r; + id.z = texelFetchOffset(outlineId, texel, 0, ivec2(-1, 0)).r; + id.w = texelFetchOffset(outlineId, texel, 0, ivec2( 0, -1)).r; #endif float ref_depth = texelFetch(outlineDepth, texel, 0).r; diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c index 6ad33125a25..ce044d1cf48 100644 --- a/source/blender/editors/armature/armature_select.c +++ b/source/blender/editors/armature/armature_select.c @@ -41,6 +41,7 @@ #include "BKE_context.h" #include "BKE_action.h" +#include "BKE_object.h" #include "BKE_report.h" #include "BKE_layer.h" @@ -259,10 +260,16 @@ void *get_nearest_bone( if (hits > 0) { uint bases_len = 0; - Base **bases = BKE_view_layer_array_from_bases_in_mode( - vc.view_layer, &bases_len, { - .object_mode = vc.obedit ? OB_MODE_EDIT : OB_MODE_POSE, - .no_dup_data = true}); + Base **bases; + + if (vc.obedit != NULL) { + bases = BKE_view_layer_array_from_bases_in_mode( + vc.view_layer, &bases_len, { + .object_mode = OB_MODE_EDIT}); + } + else { + bases = BKE_object_pose_base_array_get(vc.view_layer, &bases_len); + } void *bone = get_bone_from_selectbuffer( bases, bases_len, vc.obedit != NULL, buffer, hits, findunsel, true, r_base); diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c index 80eeda1dd0c..397d39b539f 100644 --- a/source/blender/editors/armature/pose_edit.c +++ b/source/blender/editors/armature/pose_edit.c @@ -31,6 +31,8 @@ * \ingroup edarmature */ +#include "MEM_guardedalloc.h" + #include "BLI_math.h" #include "BLI_blenlib.h" @@ -1057,55 +1059,54 @@ void ARMATURE_OT_bone_layers(wmOperatorType *ot) /* ********************************************** */ /* Show/Hide Bones */ -static int hide_selected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr)) +static int hide_pose_bone_fn(Object *ob, Bone *bone, void *ptr) { bArmature *arm = ob->data; - + const bool hide_select = (bool)GET_INT_FROM_POINTER(ptr); + int count = 0; if (arm->layer & bone->layer) { - if (bone->flag & BONE_SELECTED) { + if (((bone->flag & BONE_SELECTED) != 0) == hide_select) { bone->flag |= BONE_HIDDEN_P; + /* only needed when 'hide_select' is true, but harmless. */ bone->flag &= ~BONE_SELECTED; - if (arm->act_bone == bone) - arm->act_bone = NULL; - } - } - return 0; -} - -static int hide_unselected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr)) -{ - bArmature *arm = ob->data; - - if (arm->layer & bone->layer) { - /* hrm... typo here? */ - if ((bone->flag & BONE_SELECTED) == 0) { - bone->flag |= BONE_HIDDEN_P; - if (arm->act_bone == bone) + if (arm->act_bone == bone) { arm->act_bone = NULL; + } + count += 1; } } - return 0; + return count; } /* active object is armature in posemode, poll checked */ -static int pose_hide_exec(bContext *C, wmOperator *op) +static int pose_hide_exec(bContext *C, wmOperator *op) { - Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); - bArmature *arm = ob->data; + ViewLayer *view_layer = CTX_data_view_layer(C); + uint objects_len; + Object **objects = BKE_object_pose_array_get_unique(view_layer, &objects_len); + bool changed_multi = false; + + const int hide_select = !RNA_boolean_get(op->ptr, "unselected"); + void *hide_select_p = SET_INT_IN_POINTER(hide_select); + + for (uint ob_index = 0; ob_index < objects_len; ob_index++) { + Object *ob_iter = objects[ob_index]; + bArmature *arm = ob_iter->data; + + if (ob_iter->proxy != NULL) { + BKE_report(op->reports, RPT_INFO, "Undo of hiding can only be done with Reveal Selected"); + } - if (ob->proxy != NULL) { - BKE_report(op->reports, RPT_INFO, "Undo of hiding can only be done with Reveal Selected"); + bool changed = bone_looper(ob_iter, arm->bonebase.first, hide_select_p, hide_pose_bone_fn) != 0; + if (changed) { + /* note, notifier might evolve */ + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob_iter); + changed_multi = true; + } } + MEM_freeN(objects); - if (RNA_boolean_get(op->ptr, "unselected")) - bone_looper(ob, arm->bonebase.first, NULL, hide_unselected_pose_bone_cb); - else - bone_looper(ob, arm->bonebase.first, NULL, hide_selected_pose_bone_cb); - - /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); - - return OPERATOR_FINISHED; + return changed_multi ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } void POSE_OT_hide(wmOperatorType *ot) @@ -1131,32 +1132,44 @@ static int show_pose_bone_cb(Object *ob, Bone *bone, void *data) const bool select = GET_INT_FROM_POINTER(data); bArmature *arm = ob->data; - + int count = 0; if (arm->layer & bone->layer) { if (bone->flag & BONE_HIDDEN_P) { if (!(bone->flag & BONE_UNSELECTABLE)) { SET_FLAG_FROM_TEST(bone->flag, select, BONE_SELECTED); } bone->flag &= ~BONE_HIDDEN_P; + count += 1; } } - - return 0; + + return count; } /* active object is armature in posemode, poll checked */ -static int pose_reveal_exec(bContext *C, wmOperator *op) +static int pose_reveal_exec(bContext *C, wmOperator *op) { - Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); - bArmature *arm = ob->data; + ViewLayer *view_layer = CTX_data_view_layer(C); + uint objects_len; + Object **objects = BKE_object_pose_array_get_unique(view_layer, &objects_len); + bool changed_multi = false; const bool select = RNA_boolean_get(op->ptr, "select"); - - bone_looper(ob, arm->bonebase.first, SET_INT_IN_POINTER(select), show_pose_bone_cb); - - /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); + void *select_p = SET_INT_IN_POINTER(select); - return OPERATOR_FINISHED; + for (uint ob_index = 0; ob_index < objects_len; ob_index++) { + Object *ob_iter = objects[ob_index]; + bArmature *arm = ob_iter->data; + + bool changed = bone_looper(ob_iter, arm->bonebase.first, select_p, show_pose_bone_cb); + if (changed) { + /* note, notifier might evolve */ + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob_iter); + changed_multi = true; + } + } + MEM_freeN(objects); + + return changed_multi ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } void POSE_OT_reveal(wmOperatorType *ot) diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c index b6f1e101291..39dba82aaf1 100644 --- a/source/blender/editors/armature/pose_select.c +++ b/source/blender/editors/armature/pose_select.c @@ -171,7 +171,7 @@ bool ED_armature_pose_select_pick_with_buffer( if (!extend && !deselect && !toggle) { { uint objects_len = 0; - Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len); + Object **objects = BKE_object_pose_array_get_unique(view_layer, &objects_len); ED_pose_deselect_all_multi(objects, objects_len, SEL_DESELECT, true); MEM_SAFE_FREE(objects); } diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index a2066ee51c7..d78d3f96835 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -2842,10 +2842,17 @@ static int viewselected_exec(bContext *C, wmOperator *op) ok = WM_manipulatormap_minmax(ar->manipulator_map, true, true, min, max); } else if (obedit) { - ok = ED_view3d_minmax_verts(obedit, min, max); /* only selected */ + /* only selected */ + FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, obedit->mode, ob_iter) { + ok |= ED_view3d_minmax_verts(ob_iter, min, max); + } + FOREACH_OBJECT_IN_MODE_END; } else if (ob && (ob->mode & OB_MODE_POSE)) { - ok = BKE_pose_minmax(ob, min, max, true, true); + FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, ob->mode, ob_iter) { + ok |= BKE_pose_minmax(ob_iter, min, max, true, true); + } + FOREACH_OBJECT_IN_MODE_END; } else if (BKE_paint_select_face_test(ob)) { ok = paintface_minmax(ob, min, max); diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index bf0e6ea3368..e3fb67261bb 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -131,6 +131,7 @@ data_to_c_simple(shaders/gpu_shader_simple_lighting_smooth_color_frag.glsl SRC) data_to_c_simple(shaders/gpu_shader_simple_lighting_smooth_color_alpha_frag.glsl SRC) data_to_c_simple(shaders/gpu_shader_flat_color_frag.glsl SRC) data_to_c_simple(shaders/gpu_shader_flat_color_alpha_test_0_frag.glsl SRC) +data_to_c_simple(shaders/gpu_shader_flat_id_frag.glsl SRC) data_to_c_simple(shaders/gpu_shader_2D_vert.glsl SRC) data_to_c_simple(shaders/gpu_shader_2D_widget_base_vert.glsl SRC) data_to_c_simple(shaders/gpu_shader_2D_widget_base_frag.glsl SRC) @@ -172,6 +173,7 @@ data_to_c_simple(shaders/gpu_shader_3D_clipped_uniform_color_vert.glsl SRC) data_to_c_simple(shaders/gpu_shader_instance_vert.glsl SRC) data_to_c_simple(shaders/gpu_shader_instance_variying_size_variying_color_vert.glsl SRC) +data_to_c_simple(shaders/gpu_shader_instance_variying_size_variying_id_vert.glsl SRC) data_to_c_simple(shaders/gpu_shader_instance_objectspace_variying_color_vert.glsl SRC) data_to_c_simple(shaders/gpu_shader_instance_screenspace_variying_color_vert.glsl SRC) data_to_c_simple(shaders/gpu_shader_instance_screen_aligned_vert.glsl SRC) diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h index b33df9fdb20..df38b08d5c4 100644 --- a/source/blender/gpu/GPU_shader.h +++ b/source/blender/gpu/GPU_shader.h @@ -168,6 +168,7 @@ typedef enum GPUBuiltinShader { GPU_SHADER_3D_INSTANCE_SCREEN_ALIGNED, /* instance */ GPU_SHADER_INSTANCE_UNIFORM_COLOR, + GPU_SHADER_INSTANCE_VARIYING_ID_VARIYING_SIZE, /* Uniformly scaled */ GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE, /* Uniformly scaled */ GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SCALE, GPU_SHADER_INSTANCE_EDGES_VARIYING_COLOR, diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c index e0b11edb197..319305fc02b 100644 --- a/source/blender/gpu/intern/gpu_shader.c +++ b/source/blender/gpu/intern/gpu_shader.c @@ -60,6 +60,7 @@ extern char datatoc_gpu_shader_simple_lighting_smooth_color_frag_glsl[]; extern char datatoc_gpu_shader_simple_lighting_smooth_color_alpha_frag_glsl[]; extern char datatoc_gpu_shader_flat_color_frag_glsl[]; extern char datatoc_gpu_shader_flat_color_alpha_test_0_frag_glsl[]; +extern char datatoc_gpu_shader_flat_id_frag_glsl[]; extern char datatoc_gpu_shader_2D_vert_glsl[]; extern char datatoc_gpu_shader_2D_flat_color_vert_glsl[]; extern char datatoc_gpu_shader_2D_smooth_color_vert_glsl[]; @@ -98,6 +99,7 @@ extern char datatoc_gpu_shader_3D_clipped_uniform_color_vert_glsl[]; extern char datatoc_gpu_shader_instance_vert_glsl[]; extern char datatoc_gpu_shader_instance_variying_size_variying_color_vert_glsl[]; +extern char datatoc_gpu_shader_instance_variying_size_variying_id_vert_glsl[]; extern char datatoc_gpu_shader_instance_objectspace_variying_color_vert_glsl[]; extern char datatoc_gpu_shader_instance_screenspace_variying_color_vert_glsl[]; extern char datatoc_gpu_shader_instance_screen_aligned_vert_glsl[]; @@ -792,6 +794,9 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader) datatoc_gpu_shader_point_uniform_color_outline_aa_frag_glsl }, [GPU_SHADER_INSTANCE_UNIFORM_COLOR] = { datatoc_gpu_shader_instance_vert_glsl, datatoc_gpu_shader_uniform_color_frag_glsl }, + [GPU_SHADER_INSTANCE_VARIYING_ID_VARIYING_SIZE] = + { datatoc_gpu_shader_instance_variying_size_variying_id_vert_glsl, + datatoc_gpu_shader_flat_id_frag_glsl }, [GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE] = { datatoc_gpu_shader_instance_variying_size_variying_color_vert_glsl, datatoc_gpu_shader_flat_color_frag_glsl }, @@ -833,6 +838,7 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader) case GPU_SHADER_SMOKE_COBA: defines = "#define USE_COBA\n"; break; + case GPU_SHADER_INSTANCE_VARIYING_ID_VARIYING_SIZE: case GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE: defines = "#define UNIFORM_SCALE\n"; break; diff --git a/source/blender/gpu/shaders/gpu_shader_flat_id_frag.glsl b/source/blender/gpu/shaders/gpu_shader_flat_id_frag.glsl new file mode 100644 index 00000000000..aa6f30531ae --- /dev/null +++ b/source/blender/gpu/shaders/gpu_shader_flat_id_frag.glsl @@ -0,0 +1,8 @@ + +flat in uint finalId; +out uint fragId; + +void main() +{ + fragId = finalId; +} diff --git a/source/blender/gpu/shaders/gpu_shader_instance_variying_size_variying_id_vert.glsl b/source/blender/gpu/shaders/gpu_shader_instance_variying_size_variying_id_vert.glsl new file mode 100644 index 00000000000..49750dddb3c --- /dev/null +++ b/source/blender/gpu/shaders/gpu_shader_instance_variying_size_variying_id_vert.glsl @@ -0,0 +1,23 @@ + +uniform mat4 ViewProjectionMatrix; +uniform int baseId; + +/* ---- Instanciated Attribs ---- */ +in vec3 pos; + +/* ---- Per instance Attribs ---- */ +in mat4 InstanceModelMatrix; +#ifdef UNIFORM_SCALE +in float size; +#else +in vec3 size; +#endif +in int callId; + +flat out uint finalId; + +void main() +{ + gl_Position = ViewProjectionMatrix * InstanceModelMatrix * vec4(pos * size, 1.0); + finalId = uint(baseId + callId); +} diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index 778aaec7d19..ba4b0970313 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -460,6 +460,7 @@ enum { LIB_TAG_NOT_ALLOCATED = 1 << 16, }; +/* WARNING - when adding flags check on PSYS_RECALC */ enum { /* RESET_AFTER_USE, used by update code (depsgraph). */ ID_RECALC_NONE = 0, diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 4a267313ac9..f7733957de9 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -284,8 +284,9 @@ IDProperty *RNA_struct_idprops(PointerRNA *ptr, bool create) { StructRNA *type = ptr->type; - if (type && type->idproperties) + if (type && type->idproperties) { return type->idproperties(ptr, create); + } return NULL; } @@ -299,8 +300,16 @@ static IDProperty *rna_idproperty_find(PointerRNA *ptr, const char *name) { IDProperty *group = RNA_struct_idprops(ptr, 0); - if (group) - return IDP_GetPropertyFromGroup(group, name); + if (group) { + if (group->type == IDP_GROUP) { + return IDP_GetPropertyFromGroup(group, name); + } + else { + /* Not sure why that happens sometimes, with nested properties... */ + /* Seems to be actually array prop, name is usually "0"... To be sorted out later. */ +// printf("Got unexpected IDProp container when trying to retrieve %s: %d\n", name, group->type); + } + } return NULL; } diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index b35fb30af66..1ab9f9fac98 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -484,6 +484,8 @@ void ED_fsmenu_entry_set_name(struct FSMenuEntry *fsentry, const char *name) RET struct PTCacheEdit *PE_get_current(struct Scene *scene, struct Object *ob) RET_NULL void PE_current_changed(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob) RET_NONE +struct PTCacheEdit *PE_create_current(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob) RET_NULL +void PE_update_object( struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, int useflag) RET_NONE /* rna keymap */ struct wmKeyMap *WM_keymap_active(struct wmWindowManager *wm, struct wmKeyMap *keymap) RET_NULL |