diff options
author | Jeroen Bakker <j.bakker@atmind.nl> | 2018-04-18 14:53:22 +0300 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2018-04-18 14:53:22 +0300 |
commit | 8a71c139d8b651bf30547236ffc0a2067d45c4d5 (patch) | |
tree | d4be5703d26d7d8117d4d3266b3d4cdba345a10f | |
parent | a091da7ffad137c114139dd59db79b2d7fbd8006 (diff) | |
parent | 9b338e802805bb7dbf981512923d6a1f343fbaa8 (diff) |
Merge branch 'blender2.8' into blender2.8-workbench
36 files changed, 323 insertions, 354 deletions
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 48d0451632a..5e022aee0ed 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -3734,11 +3734,11 @@ class VIEW3D_PT_transform_orientations(Panel): def draw(self, context): layout = self.layout - view = context.space_data - orientation = view.current_orientation + scene = context.scene + orientation = scene.current_orientation row = layout.row(align=True) - row.prop(view, "transform_orientation", text="") + row.prop(scene, "transform_orientation", text="") row.operator("transform.create_orientation", text="", icon='ZOOMIN') if orientation: diff --git a/source/blender/blenkernel/BKE_library_override.h b/source/blender/blenkernel/BKE_library_override.h index 35672cb5ded..6f32d565562 100644 --- a/source/blender/blenkernel/BKE_library_override.h +++ b/source/blender/blenkernel/BKE_library_override.h @@ -65,8 +65,8 @@ void BKE_override_static_property_operation_delete( bool BKE_override_static_status_check_local(struct ID *local); bool BKE_override_static_status_check_reference(struct ID *local); -bool BKE_override_static_operations_create(struct ID *local); -void BKE_main_override_static_operations_create(struct Main *bmain); +bool BKE_override_static_operations_create(struct ID *local, const bool force_auto); +void BKE_main_override_static_operations_create(struct Main *bmain, const bool force_auto); void BKE_override_static_update(struct Main *bmain, struct ID *local); void BKE_main_override_static_update(struct Main *bmain); diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index afb77bb5206..8036673cbdf 100644 --- a/source/blender/blenkernel/BKE_scene.h +++ b/source/blender/blenkernel/BKE_scene.h @@ -48,6 +48,7 @@ struct ViewLayer; struct UnitSettings; struct ViewRender; struct WorkSpace; +struct TransformOrientation; typedef enum eSceneCopyMethod { SCE_COPY_NEW = 0, @@ -211,6 +212,13 @@ void BKE_scene_free_depsgraph_hash(struct Scene *scene); struct Depsgraph *BKE_scene_get_depsgraph(struct Scene *scene, struct ViewLayer *view_layer, bool allocate); +void BKE_scene_transform_orientation_remove( + struct Scene *scene, struct TransformOrientation *orientation); +struct TransformOrientation *BKE_scene_transform_orientation_find( + const struct Scene *scene, const int index); +int BKE_scene_transform_orientation_get_index( + const struct Scene *scene, const struct TransformOrientation *orientation); + #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index 984e3fb2a03..ee0fb5f2776 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -325,9 +325,6 @@ void BKE_screen_manipulator_tag_refresh(struct bScreen *sc); void BKE_screen_view3d_sync(struct View3D *v3d, struct Scene *scene); void BKE_screen_view3d_scene_sync(struct bScreen *sc, struct Scene *scene); -void BKE_screen_transform_orientation_remove( - const struct bScreen *screen, const struct WorkSpace *workspace, - const struct TransformOrientation *orientation) ATTR_NONNULL(); bool BKE_screen_is_fullscreen_area(const struct bScreen *screen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); bool BKE_screen_is_used(const struct bScreen *screen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); diff --git a/source/blender/blenkernel/BKE_workspace.h b/source/blender/blenkernel/BKE_workspace.h index c4de9d134b7..3d28b66dd20 100644 --- a/source/blender/blenkernel/BKE_workspace.h +++ b/source/blender/blenkernel/BKE_workspace.h @@ -62,13 +62,6 @@ void BKE_workspace_view_layer_remove_references( const struct Main *bmain, const struct ViewLayer *view_layer) ATTR_NONNULL(); -void BKE_workspace_transform_orientation_remove( - struct WorkSpace *workspace, struct TransformOrientation *orientation) ATTR_NONNULL(); -struct TransformOrientation *BKE_workspace_transform_orientation_find( - const struct WorkSpace *workspace, const int index) ATTR_NONNULL(); -int BKE_workspace_transform_orientation_get_index( - const struct WorkSpace *workspace, const struct TransformOrientation *orientation) ATTR_NONNULL(); - struct WorkSpaceLayout *BKE_workspace_layout_find( const struct WorkSpace *workspace, const struct bScreen *screen) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT; struct WorkSpaceLayout *BKE_workspace_layout_find_global( @@ -96,7 +89,6 @@ void BKE_workspace_active_screen_set( struct WorkSpaceInstanceHook *hook, struct WorkSpace *workspace, struct bScreen *screen) SETTER_ATTRS; struct Base *BKE_workspace_active_base_get(const struct WorkSpace *workspace, const struct Scene *scene); -struct ListBase *BKE_workspace_transform_orientations_get(struct WorkSpace *workspace) GETTER_ATTRS; struct ViewLayer *BKE_workspace_view_layer_get( const struct WorkSpace *workspace, const struct Scene *scene) GETTER_ATTRS; diff --git a/source/blender/blenkernel/intern/library_override.c b/source/blender/blenkernel/intern/library_override.c index 8b8658921b5..653a590e7f2 100644 --- a/source/blender/blenkernel/intern/library_override.c +++ b/source/blender/blenkernel/intern/library_override.c @@ -86,7 +86,7 @@ IDOverrideStatic *BKE_override_static_init(ID *local_id, ID *reference_id) local_id->override_static = MEM_callocN(sizeof(*local_id->override_static), __func__); local_id->override_static->reference = reference_id; id_us_plus(local_id->override_static->reference); - local_id->tag &= ~LIB_TAG_OVERRIDESTATIC_OK; + local_id->tag &= ~LIB_TAG_OVERRIDESTATIC_REFOK; /* TODO do we want to add tag or flag to referee to mark it as such? */ return local_id->override_static; } @@ -125,7 +125,7 @@ void BKE_override_static_copy(ID *dst_id, const ID *src_id) bke_override_property_copy(op_dst, op_src); } - dst_id->tag &= ~LIB_TAG_OVERRIDESTATIC_OK; + dst_id->tag &= ~LIB_TAG_OVERRIDESTATIC_REFOK; } /** Clear any overriding data from given \a override. */ @@ -445,7 +445,7 @@ bool BKE_override_static_status_check_local(ID *local) &rnaptr_local, &rnaptr_reference, NULL, local->override_static, RNA_OVERRIDE_COMPARE_IGNORE_NON_OVERRIDABLE | RNA_OVERRIDE_COMPARE_IGNORE_OVERRIDDEN, NULL)) { - local->tag &= ~LIB_TAG_OVERRIDESTATIC_OK; + local->tag &= ~LIB_TAG_OVERRIDESTATIC_REFOK; return false; } @@ -474,12 +474,12 @@ bool BKE_override_static_status_check_reference(ID *local) BLI_assert(GS(local->name) == GS(reference->name)); - if (reference->override_static && (reference->tag & LIB_TAG_OVERRIDESTATIC_OK) == 0) { + if (reference->override_static && (reference->tag & LIB_TAG_OVERRIDESTATIC_REFOK) == 0) { if (!BKE_override_static_status_check_reference(reference)) { /* If reference is also override of another data-block, and its status is not OK, * then this override is not OK either. * Note that this should only happen when reloading libraries... */ - local->tag &= ~LIB_TAG_OVERRIDESTATIC_OK; + local->tag &= ~LIB_TAG_OVERRIDESTATIC_REFOK; return false; } } @@ -492,7 +492,7 @@ bool BKE_override_static_status_check_reference(ID *local) &rnaptr_local, &rnaptr_reference, NULL, local->override_static, RNA_OVERRIDE_COMPARE_IGNORE_OVERRIDDEN, NULL)) { - local->tag &= ~LIB_TAG_OVERRIDESTATIC_OK; + local->tag &= ~LIB_TAG_OVERRIDESTATIC_REFOK; return false; } @@ -511,13 +511,13 @@ bool BKE_override_static_status_check_reference(ID *local) * are much cheaper. * * \return true is new overriding op was created, or some local data was reset. */ -bool BKE_override_static_operations_create(ID *local) +bool BKE_override_static_operations_create(ID *local, const bool force_auto) { BLI_assert(local->override_static != NULL); const bool is_template = (local->override_static->reference == NULL); bool ret = false; - if (!is_template && local->flag & LIB_OVERRIDE_STATIC_AUTO) { + if (!is_template && (force_auto || local->flag & LIB_OVERRIDE_STATIC_AUTO)) { PointerRNA rnaptr_local, rnaptr_reference; RNA_id_pointer_create(local, &rnaptr_local); RNA_id_pointer_create(local->override_static->reference, &rnaptr_reference); @@ -545,7 +545,7 @@ bool BKE_override_static_operations_create(ID *local) } /** Check all overrides from given \a bmain and create/update overriding operations as needed. */ -void BKE_main_override_static_operations_create(Main *bmain) +void BKE_main_override_static_operations_create(Main *bmain, const bool force_auto) { ListBase *lbarray[MAX_LIBARRAY]; int base_count, i; @@ -557,9 +557,11 @@ void BKE_main_override_static_operations_create(Main *bmain) ID *id; for (id = lb->first; id; id = id->next) { - /* TODO Maybe we could also add an 'override update' tag e.g. when tagging for DEG update? */ - if (id->lib == NULL && id->override_static != NULL && id->override_static->reference != NULL && (id->flag & LIB_OVERRIDE_STATIC_AUTO)) { - BKE_override_static_operations_create(id); + if (force_auto || + (ID_IS_STATIC_OVERRIDE_AUTO(id) && (id->tag & LIB_TAG_OVERRIDESTATIC_AUTOREFRESH))) + { + BKE_override_static_operations_create(id, force_auto); + id->tag &= ~LIB_TAG_OVERRIDESTATIC_AUTOREFRESH; } } } @@ -573,7 +575,7 @@ void BKE_override_static_update(Main *bmain, ID *local) } /* Recursively do 'ancestors' overrides first, if any. */ - if (local->override_static->reference->override_static && (local->override_static->reference->tag & LIB_TAG_OVERRIDESTATIC_OK) == 0) { + if (local->override_static->reference->override_static && (local->override_static->reference->tag & LIB_TAG_OVERRIDESTATIC_REFOK) == 0) { BKE_override_static_update(bmain, local->override_static->reference); } @@ -624,7 +626,7 @@ void BKE_override_static_update(Main *bmain, ID *local) local->override_static->storage = NULL; } - local->tag |= LIB_TAG_OVERRIDESTATIC_OK; + local->tag |= LIB_TAG_OVERRIDESTATIC_REFOK; /* Full rebuild of Depsgraph! */ DEG_on_visible_update(bmain, true); /* XXX Is this actual valid replacement for old DAG_relations_tag_update(bmain) ? */ @@ -686,7 +688,7 @@ ID *BKE_override_static_operations_store_start(OverrideStaticStorage *override_s } /* Forcefully ensure we know about all needed override operations. */ - BKE_override_static_operations_create(local); + BKE_override_static_operations_create(local, false); ID *storage_id; #ifdef DEBUG_OVERRIDE_TIMEIT diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index e1e24a24245..07c8735f108 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3540,10 +3540,17 @@ float psys_get_child_size(ParticleSystem *psys, ChildParticle *cpa, float UNUSED ParticleSettings *part = psys->part; float size; // time XXX - if (part->childtype == PART_CHILD_FACES) - size = part->size; - else + if (part->childtype == PART_CHILD_FACES) { + int w = 0; + size = 0.0; + while (w < 4 && cpa->pa[w] >= 0) { + size += cpa->w[w] * (psys->particles + cpa->pa[w])->size; + w++; + } + } + else { size = psys->particles[cpa->parent].size; + } size *= part->childsize; diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index e94a722ca28..e68d1db3e4a 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -272,6 +272,7 @@ void BKE_scene_copy_data(Main *bmain, Scene *sce_dst, const Scene *sce_src, cons } BLI_duplicatelist(&(sce_dst->markers), &(sce_src->markers)); + BLI_duplicatelist(&(sce_dst->transform_spaces), &(sce_src->transform_spaces)); BLI_duplicatelist(&(sce_dst->r.views), &(sce_src->r.views)); BKE_keyingsets_copy(&(sce_dst->keyingsets), &(sce_src->keyingsets)); @@ -492,6 +493,7 @@ void BKE_scene_free_ex(Scene *sce, const bool do_id_user) } BLI_freelistN(&sce->markers); + BLI_freelistN(&sce->transform_spaces); BLI_freelistN(&sce->r.views); BKE_toolsettings_free(sce->toolsettings); @@ -835,6 +837,8 @@ void BKE_scene_init(Scene *sce) sce->toolsettings->gpencil_seq_align = GP_PROJECT_VIEWSPACE; sce->toolsettings->gpencil_ima_align = GP_PROJECT_VIEWSPACE; + sce->orientation_index_custom = -1; + /* Master Collection */ sce->collection = MEM_callocN(sizeof(SceneCollection), "Master Collection"); BLI_strncpy(sce->collection->name, "Master Collection", sizeof(sce->collection->name)); @@ -2134,3 +2138,36 @@ Depsgraph *BKE_scene_get_depsgraph(Scene *scene, } return depsgraph; } + +/* -------------------------------------------------------------------- */ +/** \name Scene Orientation + * \{ */ + +void BKE_scene_transform_orientation_remove( + Scene *scene, TransformOrientation *orientation) +{ + const int orientation_index = BKE_scene_transform_orientation_get_index(scene, orientation); + if (scene->orientation_index_custom == orientation_index) { + /* could also use orientation_index-- */ + scene->orientation_type = V3D_MANIP_GLOBAL; + scene->orientation_index_custom = -1; + } + BLI_freelinkN(&scene->transform_spaces, orientation); +} + +TransformOrientation *BKE_scene_transform_orientation_find( + const Scene *scene, const int index) +{ + return BLI_findlink(&scene->transform_spaces, index); +} + +/** + * \return the index that \a orientation has within \a scene's transform-orientation list or -1 if not found. + */ +int BKE_scene_transform_orientation_get_index( + const Scene *scene, const TransformOrientation *orientation) +{ + return BLI_findindex(&scene->transform_spaces, orientation); +} + +/** \} */ diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index 35055a59243..8283655503c 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -812,26 +812,6 @@ void BKE_screen_view3d_scene_sync(bScreen *sc, Scene *scene) } } -void BKE_screen_transform_orientation_remove( - const bScreen *screen, const WorkSpace *workspace, const TransformOrientation *orientation) -{ - const int orientation_index = BKE_workspace_transform_orientation_get_index(workspace, orientation); - - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { - if (sl->spacetype == SPACE_VIEW3D) { - View3D *v3d = (View3D *)sl; - - if (v3d->custom_orientation_index == orientation_index) { - /* could also use orientation_index-- */ - v3d->twmode = V3D_MANIP_GLOBAL; - v3d->custom_orientation_index = -1; - } - } - } - } -} - /* magic zoom calculation, no idea what * it signifies, if you find out, tell me! -zr */ diff --git a/source/blender/blenkernel/intern/undo_system.c b/source/blender/blenkernel/intern/undo_system.c index fd62650e898..cab675ccd2e 100644 --- a/source/blender/blenkernel/intern/undo_system.c +++ b/source/blender/blenkernel/intern/undo_system.c @@ -395,7 +395,7 @@ bool BKE_undosys_step_push_with_type(UndoStack *ustack, bContext *C, const char /* Might not be final place for this to be called - probably only want to call it from some * undo handlers, not all of them? */ - BKE_main_override_static_operations_create(CTX_data_main(C)); + BKE_main_override_static_operations_create(CTX_data_main(C), false); /* Remove all undos after (also when 'ustack->step_active == NULL'). */ while (ustack->steps.last != ustack->step_active) { diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c index afceea9dd5f..466848fa6b1 100644 --- a/source/blender/blenkernel/intern/workspace.c +++ b/source/blender/blenkernel/intern/workspace.c @@ -171,7 +171,6 @@ void BKE_workspace_free(WorkSpace *workspace) BLI_freelistN(&workspace->owner_ids); BLI_freelistN(&workspace->layouts); - BLI_freelistN(&workspace->transform_orientations); BKE_viewrender_free(&workspace->view_render); } @@ -272,31 +271,6 @@ void BKE_workspace_view_layer_remove_references( } } -void BKE_workspace_transform_orientation_remove( - WorkSpace *workspace, TransformOrientation *orientation) -{ - for (WorkSpaceLayout *layout = workspace->layouts.first; layout; layout = layout->next) { - BKE_screen_transform_orientation_remove(BKE_workspace_layout_screen_get(layout), workspace, orientation); - } - - BLI_freelinkN(&workspace->transform_orientations, orientation); -} - -TransformOrientation *BKE_workspace_transform_orientation_find( - const WorkSpace *workspace, const int index) -{ - return BLI_findlink(&workspace->transform_orientations, index); -} - -/** - * \return the index that \a orientation has within \a workspace's transform-orientation list or -1 if not found. - */ -int BKE_workspace_transform_orientation_get_index( - const WorkSpace *workspace, const TransformOrientation *orientation) -{ - return BLI_findindex(&workspace->transform_orientations, orientation); -} - WorkSpaceLayout *BKE_workspace_layout_find( const WorkSpace *workspace, const bScreen *screen) { @@ -423,11 +397,6 @@ Base *BKE_workspace_active_base_get(const WorkSpace *workspace, const Scene *sce return view_layer->basact; } -ListBase *BKE_workspace_transform_orientations_get(WorkSpace *workspace) -{ - return &workspace->transform_orientations; -} - ViewLayer *BKE_workspace_view_layer_get(const WorkSpace *workspace, const Scene *scene) { return workspace_relation_get_data_matching_parent(&workspace->scene_viewlayer_relations, scene); diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index b40321f75d1..fdd65add6d1 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2902,7 +2902,6 @@ static void direct_link_workspace(FileData *fd, WorkSpace *workspace, const Main link_list(fd, BKE_workspace_layouts_get(workspace)); link_list(fd, &workspace->hook_layout_relations); link_list(fd, &workspace->scene_viewlayer_relations); - link_list(fd, BKE_workspace_transform_orientations_get(workspace)); link_list(fd, &workspace->owner_ids); for (WorkSpaceDataRelation *relation = workspace->hook_layout_relations.first; @@ -6258,7 +6257,7 @@ static void direct_link_scene(FileData *fd, Scene *sce, Main *bmain) } link_list(fd, &(sce->markers)); - link_list(fd, &(sce->transform_spaces)); /* only for old files */ + link_list(fd, &(sce->transform_spaces)); link_list(fd, &(sce->r.layers)); link_list(fd, &(sce->r.views)); diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index d8314cb232c..b3cd1a6a1b7 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -95,7 +95,6 @@ static void do_version_workspaces_create_from_screens(Main *bmain) Scene *scene = screen->scene; WorkSpace *workspace; ViewLayer *layer = BKE_view_layer_from_scene_get(scene); - ListBase *transform_orientations; if (screen_parent) { /* fullscreen with "Back to Previous" option, don't create @@ -116,9 +115,6 @@ static void do_version_workspaces_create_from_screens(Main *bmain) BLI_strncpy(workspace->view_render.engine_id, RE_engine_id_BLENDER_EEVEE, sizeof(workspace->view_render.engine_id)); #endif - - transform_orientations = BKE_workspace_transform_orientations_get(workspace); - BLI_duplicatelist(transform_orientations, &scene->transform_spaces); } } @@ -750,25 +746,6 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main) } if (!MAIN_VERSION_ATLEAST(main, 280, 2)) { - if (!DNA_struct_elem_find(fd->filesdna, "View3D", "short", "custom_orientation_index")) { - for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { - if (sl->spacetype == SPACE_VIEW3D) { - View3D *v3d = (View3D *)sl; - if (v3d->twmode >= V3D_MANIP_CUSTOM) { - v3d->custom_orientation_index = v3d->twmode - V3D_MANIP_CUSTOM; - v3d->twmode = V3D_MANIP_CUSTOM; - } - else { - v3d->custom_orientation_index = -1; - } - } - } - } - } - } - if (!DNA_struct_elem_find(fd->filesdna, "Lamp", "float", "cascade_max_dist")) { for (Lamp *la = main->lamp.first; la; la = la->id.next) { la->cascade_max_dist = 1000.0f; @@ -923,17 +900,13 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main) } } } - } - if (!MAIN_VERSION_ATLEAST(main, 280, 6)) { if (!DNA_struct_elem_find(fd->filesdna, "LightProbe", "float", "intensity")) { for (LightProbe *probe = main->lightprobe.first; probe; probe = probe->id.next) { probe->intensity = 1.0f; } } - } - if (!MAIN_VERSION_ATLEAST(main, 280, 6)) { for (Object *ob = main->object.first; ob; ob = ob->id.next) { bConstraint *con, *con_next; con = ob->constraints.first; @@ -947,16 +920,16 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main) con = con_next; } } - } - if (!MAIN_VERSION_ATLEAST(main, 280, 6)) { - bScreen *sc; - ScrArea *sa; - SpaceLink *sl; + if (!DNA_struct_elem_find(fd->filesdna, "Scene", "int", "orientation_index_custom")) { + for (Scene *scene = main->scene.first; scene; scene = scene->id.next) { + scene->orientation_index_custom = -1; + } + } - for (sc = main->screen.first; sc; sc = sc->id.next) { - for (sa = sc->areabase.first; sa; sa = sa->next) { - for (sl = sa->spacedata.first; sl; sl = sl->next) { + for (bScreen *sc = main->screen.first; sc; sc = sc->id.next) { + for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) { + for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->drawtype_solid = OB_LIGHTING_STUDIO; diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index c6523dc99e2..ab71676b3df 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2648,6 +2648,11 @@ static void write_scene(WriteData *wd, Scene *sce) writestruct(wd, DATA, TimeMarker, 1, marker); } + /* writing dynamic list of TransformOrientations to the blend file */ + for (TransformOrientation *ts = sce->transform_spaces.first; ts; ts = ts->next) { + writestruct(wd, DATA, TransformOrientation, 1, ts); + } + /* writing MultiView to the blend file */ for (SceneRenderView *srv = sce->r.views.first; srv; srv = srv->next) { writestruct(wd, DATA, SceneRenderView, 1, srv); @@ -3625,14 +3630,12 @@ static void write_cachefile(WriteData *wd, CacheFile *cache_file) static void write_workspace(WriteData *wd, WorkSpace *workspace) { ListBase *layouts = BKE_workspace_layouts_get(workspace); - ListBase *transform_orientations = BKE_workspace_transform_orientations_get(workspace); writestruct(wd, ID_WS, WorkSpace, 1, workspace); writelist(wd, DATA, WorkSpaceLayout, layouts); writelist(wd, DATA, WorkSpaceDataRelation, &workspace->hook_layout_relations); writelist(wd, DATA, WorkSpaceDataRelation, &workspace->scene_viewlayer_relations); writelist(wd, DATA, wmOwnerID, &workspace->owner_ids); - writelist(wd, DATA, TransformOrientation, transform_orientations); } /* Keep it last of write_foodata functions. */ diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc index f7f55610d22..60fde1e69ee 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc @@ -241,6 +241,10 @@ void flush_editors_id_update(Main *bmain, /* Inform editors. */ if (deg_copy_on_write_is_expanded(id_cow)) { deg_editors_id_update(update_ctx, id_cow); + /* ID may need to get its auto-override operations refreshed. */ + if (ID_IS_STATIC_OVERRIDE_AUTO(id_orig)) { + id_orig->tag |= LIB_TAG_OVERRIDESTATIC_AUTOREFRESH; + } /* Inform draw engines that something was changed. */ flush_engine_data_update(id_cow); } diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h index cec0c2f4bf9..2b328ccbda2 100644 --- a/source/blender/draw/engines/workbench/workbench_private.h +++ b/source/blender/draw/engines/workbench/workbench_private.h @@ -41,17 +41,10 @@ typedef struct WORKBENCH_PassList { struct DRWPass *solid_pass; } WORKBENCH_PassList; -typedef struct WORKBENCH_FrameBufferList { -} WORKBENCH_FrameBufferList; - -typedef struct WORKBENCH_TextureList { -} WORKBENCH_TextureList; - - typedef struct WORKBENCH_Data { void *engine_type; - WORKBENCH_FrameBufferList *fbl; - WORKBENCH_TextureList *txl; + DRWViewportEmptyList *fbl; + DRWViewportEmptyList *txl; WORKBENCH_PassList *psl; WORKBENCH_StorageList *stl; } WORKBENCH_Data; diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index 720a547f8f8..7868e8a8232 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -886,6 +886,8 @@ static void OBJECT_cache_init(void *vedata) OBJECT_StorageList *stl = ((OBJECT_Data *)vedata)->stl; DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); OBJECT_PrivateData *g_data; + /* TODO : use dpi setting for enabling the second pass */ + const bool do_outline_expand = false; if (!stl->g_data) { /* Alloc transient pointers */ @@ -968,15 +970,17 @@ static void OBJECT_cache_init(void *vedata) grp = DRW_shgroup_create(e_data.outline_fade_sh, psl->outlines_expand); DRW_shgroup_uniform_texture_ref(grp, "outlineColor", &e_data.outlines_blur_tx); - DRW_shgroup_uniform_bool(grp, "doExpand", &bTrue, 1); + DRW_shgroup_uniform_bool(grp, "doExpand", (do_outline_expand) ? &bTrue : &bFalse, 1); DRW_shgroup_call_add(grp, quad, NULL); psl->outlines_bleed = DRW_pass_create("Outlines Bleed Pass", state); - grp = DRW_shgroup_create(e_data.outline_fade_sh, psl->outlines_bleed); - DRW_shgroup_uniform_texture_ref(grp, "outlineColor", &e_data.outlines_color_tx); - DRW_shgroup_uniform_bool(grp, "doExpand", &bFalse, 1); - DRW_shgroup_call_add(grp, quad, NULL); + if (do_outline_expand) { + grp = DRW_shgroup_create(e_data.outline_fade_sh, psl->outlines_bleed); + DRW_shgroup_uniform_texture_ref(grp, "outlineColor", &e_data.outlines_color_tx); + DRW_shgroup_uniform_bool(grp, "doExpand", &bFalse, 1); + DRW_shgroup_call_add(grp, quad, NULL); + } } { @@ -984,9 +988,10 @@ static void OBJECT_cache_init(void *vedata) psl->outlines_resolve = DRW_pass_create("Outlines Resolve Pass", state); struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get(); + GPUTexture **outline_tx = (do_outline_expand) ? &e_data.outlines_blur_tx : &e_data.outlines_color_tx; DRWShadingGroup *grp = DRW_shgroup_create(e_data.outline_resolve_aa_sh, psl->outlines_resolve); - DRW_shgroup_uniform_texture_ref(grp, "outlineBluredColor", &e_data.outlines_blur_tx); + DRW_shgroup_uniform_texture_ref(grp, "outlineBluredColor", outline_tx); DRW_shgroup_uniform_vec2(grp, "rcpDimensions", e_data.inv_viewport_size, 1); DRW_shgroup_call_add(grp, quad, NULL); } 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 dc457100d1c..771b6bcdc2e 100644 --- a/source/blender/draw/modes/shaders/object_outline_detect_frag.glsl +++ b/source/blender/draw/modes/shaders/object_outline_detect_frag.glsl @@ -40,8 +40,8 @@ void main() #ifdef GL_ARB_texture_gather vec2 texel_size = 1.0 / vec2(textureSize(outlineId, 0).xy); - vec2 uv1 = floor(gl_FragCoord.xy) * texel_size - texel_size; - vec2 uv2 = floor(gl_FragCoord.xy) * texel_size; + vec2 uv1 = ceil(gl_FragCoord.xy) * texel_size - texel_size; + vec2 uv2 = ceil(gl_FragCoord.xy) * texel_size; /* Samples order is CW starting from top left. */ uvec4 tmp1 = textureGather(outlineId, uv1); @@ -52,19 +52,36 @@ void main() #else uvec4 id; uint ref_id = texelFetch(outlineId, texel, 0).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; + 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( 0, 1)).r; + id.w = texelFetchOffset(outlineId, texel, 0, ivec2( 1, 0)).r; #endif - float ref_depth = texelFetch(outlineDepth, texel, 0).r; - float scene_depth = texelFetch(sceneDepth, texel, 0).r; + bool outline = any(notEqual(id, uvec4(ref_id))); + + ivec2 depth_texel = texel; + /* If texel is an outline but has no valid id ... + * replace id and depth texel by a valid one. + * This keeps the outline thickness consistent everywhere. */ + if (ref_id == 0u && outline) { + depth_texel = (id.x != 0u) ? texel + ivec2(-1, 0) : depth_texel; + depth_texel = (id.y != 0u) ? texel + ivec2( 0, -1) : depth_texel; + depth_texel = (id.z != 0u) ? texel + ivec2( 0, 1) : depth_texel; + depth_texel = (id.w != 0u) ? texel + ivec2( 1, 0) : depth_texel; + + ref_id = (id.x != 0u) ? id.x : ref_id; + ref_id = (id.y != 0u) ? id.y : ref_id; + ref_id = (id.z != 0u) ? id.z : ref_id; + ref_id = (id.w != 0u) ? id.w : ref_id; + } + + float ref_depth = texelFetch(outlineDepth, depth_texel, 0).r; + float scene_depth = texelFetch(sceneDepth, depth_texel, 0).r; /* Avoid bad cases of zfighting for occlusion only. */ const float epsilon = 3.0 / 8388608.0; bool occluded = (ref_depth > scene_depth + epsilon); - bool outline = any(notEqual(id, uvec4(ref_id))); FragColor = convert_id_to_color(int(ref_id)); FragColor.a *= (occluded) ? alphaOcclu : 1.0; diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h index 536f9c22dcd..a6bed6c1ee6 100644 --- a/source/blender/editors/include/ED_transform.h +++ b/source/blender/editors/include/ED_transform.h @@ -130,7 +130,7 @@ void BIF_createTransformOrientation(struct bContext *C, struct ReportList *repor const char *name, const bool use_view, const bool activate, const bool overwrite); void BIF_selectTransformOrientation(struct bContext *C, struct TransformOrientation *ts); -void BIF_selectTransformOrientationValue(struct View3D *v3d, int orientation); +void BIF_selectTransformOrientationValue(struct Scene *scene, int orientation); void ED_getTransformOrientationMatrix(const struct bContext *C, float orientation_mat[3][3], const short around); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 0e0f2784936..3cef80db032 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -2437,6 +2437,12 @@ static int make_override_static_exec(bContext *C, wmOperator *op) base = BKE_view_layer_base_find(view_layer, new_ob); BKE_view_layer_base_select(view_layer, base); } + else { + /* Disable auto-override tags for non-active objects, will help with performaces... */ + new_ob->id.flag &= ~LIB_OVERRIDE_STATIC_AUTO; + } + /* We still want to store all objects' current override status (i.e. change of parent). */ + BKE_override_static_operations_create(&new_ob->id, true); } } FOREACH_GROUP_OBJECT_END; diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c index ace3f17542e..b4aea54c66d 100644 --- a/source/blender/editors/screen/workspace_edit.c +++ b/source/blender/editors/screen/workspace_edit.c @@ -225,10 +225,6 @@ WorkSpace *ED_workspace_duplicate( bmain, workspace_old->id.name + 2, scene, BKE_workspace_view_layer_get(workspace_old, scene), &workspace_old->view_render); - ListBase *transform_orientations_old = BKE_workspace_transform_orientations_get(workspace_old); - ListBase *transform_orientations_new = BKE_workspace_transform_orientations_get(workspace_new); - - BLI_duplicatelist(transform_orientations_new, transform_orientations_old); workspace_new->tool = workspace_old->tool; diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 9234c8c3d77..5a5d1df3a08 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -348,7 +348,7 @@ static SpaceLink *view3d_new(const bContext *C) v3d->twflag |= U.manipulator_flag & V3D_MANIPULATOR_DRAW; v3d->twtype = V3D_MANIP_TRANSLATE; v3d->around = V3D_AROUND_CENTER_MEAN; - v3d->custom_orientation_index = -1; + scene->orientation_index_custom = -1; v3d->bundle_size = 0.2f; v3d->bundle_drawtype = OB_PLAINAXES; diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 3ed6c87b750..1f47f44f2f6 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -333,7 +333,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) if (v3d->twflag & V3D_MANIPULATOR_DRAW) { uiItemR(row, &v3dptr, "transform_manipulators", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); } - uiItemR(row, &v3dptr, "transform_orientation", 0, "", ICON_NONE); + uiItemR(row, &sceneptr, "transform_orientation", 0, "", ICON_NONE); } if (obedit == NULL && v3d->localvd == NULL) { diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 3752d7f6c26..b6d794a7812 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -62,6 +62,7 @@ #include "BKE_constraint.h" #include "BKE_particle.h" #include "BKE_unit.h" +#include "BKE_scene.h" #include "BKE_mask.h" #include "BKE_report.h" #include "BKE_workspace.h" @@ -2009,13 +2010,10 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op) if ((prop = RNA_struct_find_property(op->ptr, "constraint_orientation")) && !RNA_property_is_set(op->ptr, prop)) { - View3D *v3d = t->view; - - v3d->twmode = t->current_orientation; - - BLI_assert(((v3d->custom_orientation_index == -1) && (t->custom_orientation == NULL)) || - (BKE_workspace_transform_orientation_get_index( - CTX_wm_workspace(C), t->custom_orientation) == v3d->custom_orientation_index)); + t->scene->orientation_type = t->current_orientation; + BLI_assert(((t->scene->orientation_index_custom == -1) && (t->custom_orientation == NULL)) || + (BKE_scene_transform_orientation_get_index( + t->scene, t->custom_orientation) == t->scene->orientation_index_custom)); } } } @@ -2040,12 +2038,11 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op) short orientation = (t->con.mode & CON_APPLY) ? t->con.orientation : t->current_orientation; if (orientation == V3D_MANIP_CUSTOM) { - WorkSpace *workspace = CTX_wm_workspace(C); - const int custom_orientation_index = BKE_workspace_transform_orientation_get_index( - workspace, t->custom_orientation); + const int orientation_index_custom = BKE_scene_transform_orientation_get_index( + t->scene, t->custom_orientation); /* Maybe we need a t->con.custom_orientation? Seems like it would always match t->custom_orientation. */ - orientation = V3D_MANIP_CUSTOM + custom_orientation_index; + orientation = V3D_MANIP_CUSTOM + orientation_index_custom; BLI_assert(orientation >= V3D_MANIP_CUSTOM); } RNA_enum_set(op->ptr, "constraint_orientation", orientation); diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 8f369aea0c8..2fdb34e125a 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -83,6 +83,7 @@ #include "BKE_mask.h" #include "BKE_workspace.h" #include "BKE_layer.h" +#include "BKE_scene.h" #include "DEG_depsgraph.h" @@ -1328,9 +1329,9 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve t->around = V3D_AROUND_CURSOR; } - t->current_orientation = v3d->twmode; - t->custom_orientation = BKE_workspace_transform_orientation_find( - CTX_wm_workspace(C), v3d->custom_orientation_index); + t->current_orientation = t->scene->orientation_type; + t->custom_orientation = BKE_scene_transform_orientation_find( + t->scene, t->scene->orientation_index_custom); /* exceptional case */ if (t->around == V3D_AROUND_LOCAL_ORIGINS) { @@ -1429,8 +1430,8 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve orientation = V3D_MANIP_GLOBAL; } else { - custom_orientation = BKE_workspace_transform_orientation_find( - CTX_wm_workspace(C), orientation - V3D_MANIP_CUSTOM); + custom_orientation = BKE_scene_transform_orientation_find( + t->scene, orientation - V3D_MANIP_CUSTOM); orientation = V3D_MANIP_CUSTOM; } } diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index 8944817baca..6fb9ed862ab 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -59,6 +59,7 @@ #include "BKE_editmesh.h" #include "BKE_lattice.h" #include "BKE_gpencil.h" +#include "BKE_scene.h" #include "BKE_workspace.h" #include "BIF_gl.h" @@ -619,7 +620,7 @@ static int calc_manipulator_stats( * if we could check 'totsel' now, this should be skipped with no selection. */ if (ob && !is_gp_edit) { - switch (v3d->twmode) { + switch (scene->orientation_type) { case V3D_MANIP_GLOBAL: { @@ -672,8 +673,8 @@ static int calc_manipulator_stats( } case V3D_MANIP_CUSTOM: { - TransformOrientation *custom_orientation = BKE_workspace_transform_orientation_find( - CTX_wm_workspace(C), v3d->custom_orientation_index); + TransformOrientation *custom_orientation = BKE_scene_transform_orientation_find( + scene, scene->orientation_index_custom); float mat[3][3]; if (applyTransformOrientation(custom_orientation, mat, NULL)) { @@ -1133,9 +1134,9 @@ static void manipulator_xform_message_subscribe( RNA_pointer_create(&screen->id, &RNA_SpaceView3D, sa->spacedata.first, &space_ptr); { - extern PropertyRNA rna_SpaceView3D_transform_orientation; + extern PropertyRNA rna_Scene_transform_orientation; const PropertyRNA *props[] = { - &rna_SpaceView3D_transform_orientation, + &rna_Scene_transform_orientation, }; for (int i = 0; i < ARRAY_SIZE(props); i++) { WM_msg_subscribe_rna(mbus, &space_ptr, props[i], &msg_sub_value_mpr_tag_refresh, __func__); diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index d5d25888ec8..6f31f5311bc 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -160,12 +160,12 @@ const EnumPropertyItem rna_enum_transform_mode_types[] = static int select_orientation_exec(bContext *C, wmOperator *op) { - View3D *v3d = CTX_wm_view3d(C); + Scene *scene = CTX_data_scene(C); int orientation = RNA_enum_get(op->ptr, "orientation"); - BIF_selectTransformOrientationValue(v3d, orientation); - - WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); + BIF_selectTransformOrientationValue(scene, orientation); + + WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL); return OPERATOR_FINISHED; } @@ -206,12 +206,10 @@ static void TRANSFORM_OT_select_orientation(struct wmOperatorType *ot) static int delete_orientation_exec(bContext *C, wmOperator *UNUSED(op)) { - View3D *v3d = CTX_wm_view3d(C); + Scene *scene = CTX_data_scene(C); + BIF_removeTransformOrientationIndex(C, scene->orientation_index_custom); - BIF_removeTransformOrientationIndex(C, v3d->custom_orientation_index); - - WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); - WM_event_add_notifier(C, NC_SCENE | NA_EDITED, CTX_data_scene(C)); + WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene); return OPERATOR_FINISHED; } @@ -223,12 +221,12 @@ static int delete_orientation_invoke(bContext *C, wmOperator *op, const wmEvent static int delete_orientation_poll(bContext *C) { - View3D *v3d = CTX_wm_view3d(C); + Scene *scene = CTX_data_scene(C); if (ED_operator_areaactive(C) == 0) return 0; - return (v3d->twmode >= V3D_MANIP_CUSTOM) && (v3d->custom_orientation_index != -1); + return (scene->orientation_type >= V3D_MANIP_CUSTOM) && (scene->orientation_index_custom != -1); } static void TRANSFORM_OT_delete_orientation(struct wmOperatorType *ot) diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index 7b3f91b81da..9e6f4847b5b 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -53,6 +53,7 @@ #include "BKE_report.h" #include "BKE_main.h" #include "BKE_screen.h" +#include "BKE_scene.h" #include "BKE_workspace.h" #include "BLT_translation.h" @@ -65,16 +66,15 @@ void BIF_clearTransformOrientation(bContext *C) { - WorkSpace *workspace = CTX_wm_workspace(C); - ListBase *transform_orientations = BKE_workspace_transform_orientations_get(workspace); + Scene *scene = CTX_data_scene(C); + ListBase *transform_orientations = &scene->transform_spaces; View3D *v3d = CTX_wm_view3d(C); BLI_freelistN(transform_orientations); - - // Need to loop over all view3d - if (v3d && v3d->twmode == V3D_MANIP_CUSTOM) { - v3d->twmode = V3D_MANIP_GLOBAL; /* fallback to global */ - v3d->custom_orientation_index = -1; + + if (v3d && scene->orientation_type == V3D_MANIP_CUSTOM) { + scene->orientation_type = V3D_MANIP_GLOBAL; /* fallback to global */ + scene->orientation_index_custom = -1; } } @@ -323,8 +323,8 @@ TransformOrientation *addMatrixSpace(bContext *C, float mat[3][3], const char *name, const bool overwrite) { TransformOrientation *ts = NULL; - WorkSpace *workspace = CTX_wm_workspace(C); - ListBase *transform_orientations = BKE_workspace_transform_orientations_get(workspace); + Scene *scene = CTX_data_scene(C); + ListBase *transform_orientations = &scene->transform_spaces; char name_unique[sizeof(ts->name)]; if (overwrite) { @@ -351,24 +351,24 @@ TransformOrientation *addMatrixSpace(bContext *C, float mat[3][3], void BIF_removeTransformOrientation(bContext *C, TransformOrientation *target) { - BKE_workspace_transform_orientation_remove(CTX_wm_workspace(C), target); + BKE_scene_transform_orientation_remove(CTX_data_scene(C), target); } void BIF_removeTransformOrientationIndex(bContext *C, int index) { - TransformOrientation *target = BKE_workspace_transform_orientation_find(CTX_wm_workspace(C), index); + TransformOrientation *target = BKE_scene_transform_orientation_find(CTX_data_scene(C), index); BIF_removeTransformOrientation(C, target); } void BIF_selectTransformOrientation(bContext *C, TransformOrientation *target) { - int index = BKE_workspace_transform_orientation_get_index(CTX_wm_workspace(C), target); - View3D *v3d = CTX_wm_view3d(C); + Scene *scene = CTX_data_scene(C); + int index = BKE_scene_transform_orientation_get_index(scene, target); BLI_assert(index != -1); - v3d->twmode = V3D_MANIP_CUSTOM; - v3d->custom_orientation_index = index; + scene->orientation_type = V3D_MANIP_CUSTOM; + scene->orientation_index_custom = index; } /** @@ -377,18 +377,17 @@ void BIF_selectTransformOrientation(bContext *C, TransformOrientation *target) * \param orientation: If this is #V3D_MANIP_CUSTOM or greater, the custom transform orientation * with index \a orientation - #V3D_MANIP_CUSTOM gets activated. */ -void BIF_selectTransformOrientationValue(View3D *v3d, int orientation) +void BIF_selectTransformOrientationValue(Scene *scene, int orientation) { const bool is_custom = orientation >= V3D_MANIP_CUSTOM; - - v3d->twmode = is_custom ? V3D_MANIP_CUSTOM : orientation; - v3d->custom_orientation_index = is_custom ? (orientation - V3D_MANIP_CUSTOM) : -1; + scene->orientation_type = is_custom ? V3D_MANIP_CUSTOM : orientation; + scene->orientation_index_custom = is_custom ? (orientation - V3D_MANIP_CUSTOM) : -1; } int BIF_countTransformOrientation(const bContext *C) { - WorkSpace *workspace = CTX_wm_workspace(C); - ListBase *transform_orientations = BKE_workspace_transform_orientations_get(workspace); + Scene *scene = CTX_data_scene(C); + ListBase *transform_orientations = &scene->transform_spaces; return BLI_listbase_count(transform_orientations); } diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index edab09351ee..f192c9ea75a 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -387,6 +387,10 @@ typedef enum ID_Type { #define ID_IS_STATIC_OVERRIDE_TEMPLATE(_id) (((ID *)(_id))->override_static != NULL && \ ((ID *)(_id))->override_static->reference == NULL) +#define ID_IS_STATIC_OVERRIDE_AUTO(_id) (!ID_IS_LINKED((_id)) && \ + ID_IS_STATIC_OVERRIDE((_id)) && \ + (((ID *)(_id))->flag & LIB_OVERRIDE_STATIC_AUTO)) + #ifdef GS # undef GS #endif @@ -435,7 +439,9 @@ enum { LIB_TAG_MISSING = 1 << 6, /* RESET_NEVER tag datablock as being up-to-date regarding its reference. */ - LIB_TAG_OVERRIDESTATIC_OK = 1 << 9, + LIB_TAG_OVERRIDESTATIC_REFOK = 1 << 9, + /* RESET_NEVER tag datablock as needing an auto-override execution, if enabled. */ + LIB_TAG_OVERRIDESTATIC_AUTOREFRESH = 1 << 17, /* tag datablock has having an extra user. */ LIB_TAG_EXTRAUSER = 1 << 2, diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index db997aed1cb..1c518331cf7 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -1481,7 +1481,10 @@ typedef struct Scene { struct AudioData audio; ListBase markers; - ListBase transform_spaces DNA_DEPRECATED; + ListBase transform_spaces; + + int orientation_index_custom; + int orientation_type; void *sound_scene; void *playback_handle; diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index 70d0d8c9d4d..2b82638a6b8 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -197,7 +197,7 @@ typedef struct View3D { char gridflag; /* transform manipulator info */ - char twtype, twmode, twflag; + char twtype, _pad5, twflag; short flag3; @@ -211,9 +211,7 @@ typedef struct View3D { char multiview_eye; /* multiview current eye - for internal use */ - /* The active custom transform orientation of this 3D view. */ - short custom_orientation_index; - char pad3[2]; + char pad3[4]; /* note, 'fx_settings.dof' is currently _not_ allocated, * instead set (temporarily) from camera */ @@ -363,7 +361,7 @@ enum { #define V3D_MANIP_ROTATE 2 #define V3D_MANIP_SCALE 4 -/* View3d->twmode */ +/* Scene.orientation_type */ #define V3D_MANIP_GLOBAL 0 #define V3D_MANIP_LOCAL 1 #define V3D_MANIP_NORMAL 2 diff --git a/source/blender/makesdna/DNA_workspace_types.h b/source/blender/makesdna/DNA_workspace_types.h index 82aa7b8b81c..dab6f8c1ea0 100644 --- a/source/blender/makesdna/DNA_workspace_types.h +++ b/source/blender/makesdna/DNA_workspace_types.h @@ -95,9 +95,6 @@ typedef struct WorkSpace { /* Feature tagging (use for addons) */ ListBase owner_ids DNA_PRIVATE_WORKSPACE_READ_WRITE; /* wmOwnerID */ - /* Custom transform orientations */ - ListBase transform_orientations DNA_PRIVATE_WORKSPACE; - int pad; int flags DNA_PRIVATE_WORKSPACE; /* enum eWorkSpaceFlags */ diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index d276e2c0859..a2c1e4d9463 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -464,7 +464,7 @@ static int preprocess_include(char *maindata, int len) if (cp[0] == '/' && cp[1] == '/') { comment = 1; } - else if (*cp < 32) { + else if (*cp == '\n') { comment = 0; } if (comment || *cp < 32 || *cp > 128) *cp = 32; diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 2e842687831..6f9b1ccebf5 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -37,6 +37,8 @@ #include "DNA_userdef_types.h" #include "DNA_world_types.h" #include "DNA_gpencil_types.h" +#include "DNA_view3d_types.h" +#include "DNA_screen_types.h" /* TransformOrientation */ #include "IMB_imbuf_types.h" @@ -71,6 +73,7 @@ #endif #include "ED_render.h" +#include "ED_transform.h" #include "WM_api.h" #include "WM_types.h" @@ -438,6 +441,18 @@ static const EnumPropertyItem rna_enum_gpencil_interpolation_mode_items[] = { #endif +static const EnumPropertyItem transform_orientation_items[] = { + {V3D_MANIP_GLOBAL, "GLOBAL", 0, "Global", "Align the transformation axes to world space"}, + {V3D_MANIP_LOCAL, "LOCAL", 0, "Local", "Align the transformation axes to the selected objects' local space"}, + {V3D_MANIP_NORMAL, "NORMAL", 0, "Normal", + "Align the transformation axes to average normal of selected elements " + "(bone Y axis for pose mode)"}, + {V3D_MANIP_GIMBAL, "GIMBAL", 0, "Gimbal", "Align each axis to the Euler rotation axis as used for input"}, + {V3D_MANIP_VIEW, "VIEW", 0, "View", "Align the transformation axes to the window"}, + // {V3D_MANIP_CUSTOM, "CUSTOM", 0, "Custom", "Use a custom transform orientation"}, + {0, NULL, 0, NULL, NULL} +}; + #ifdef RNA_RUNTIME #include "DNA_anim_types.h" @@ -1627,6 +1642,8 @@ static void rna_Scene_sync_mode_set(PointerRNA *ptr, int value) } } + + static TimeMarker *rna_TimeLine_add(Scene *scene, const char name[], int frame) { TimeMarker *marker = MEM_callocN(sizeof(TimeMarker), "TimeMarker"); @@ -2013,6 +2030,71 @@ static void rna_ViewLayer_remove( } } +static int rna_Scene_transform_orientation_get(PointerRNA *ptr) +{ + Scene *scene = ptr->data; + /* convert to enum value */ + return (scene->orientation_type == V3D_MANIP_CUSTOM) ? + (scene->orientation_type + scene->orientation_index_custom) : scene->orientation_type; +} + +void rna_Scene_transform_orientation_set(PointerRNA *ptr, int value) +{ + Scene *scene = ptr->data; + BIF_selectTransformOrientationValue(scene, value); +} + +static PointerRNA rna_Scene_current_orientation_get(PointerRNA *ptr) +{ + Scene *scene = ptr->data; + TransformOrientation *orientation; + + if (scene->orientation_type < V3D_MANIP_CUSTOM) { + orientation = NULL; + } + else { + orientation = BKE_scene_transform_orientation_find(scene, scene->orientation_index_custom); + } + + return rna_pointer_inherit_refine(ptr, &RNA_TransformOrientation, orientation); +} + +const EnumPropertyItem *rna_TransformOrientation_itemf( + bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) +{ + EnumPropertyItem tmp = {0, "", 0, "", ""}; + EnumPropertyItem *item = NULL; + int i = V3D_MANIP_CUSTOM, totitem = 0; + + RNA_enum_items_add(&item, &totitem, transform_orientation_items); + + Scene *scene = CTX_data_scene(C); + if (ptr->type == &RNA_Scene) { + scene = ptr->data; + } + else { + scene = CTX_data_scene(C); + } + const ListBase *transform_orientations = &scene->transform_spaces; + + if (transform_orientations && (BLI_listbase_is_empty(transform_orientations) == false)) { + RNA_enum_item_add_separator(&item, &totitem); + + for (TransformOrientation *ts = transform_orientations->first; ts; ts = ts->next) { + tmp.identifier = ts->name; + tmp.name = ts->name; + tmp.value = i++; + RNA_enum_item_add(&item, &totitem, &tmp); + } + } + + RNA_enum_item_end(&item, &totitem); + *r_free = true; + + return item; +} + + #else /* Grease Pencil Interpolation tool settings */ @@ -2281,6 +2363,24 @@ static void rna_def_gpencil_brushes(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_ui_text(prop, "Active Brush Index", "Index of active brush"); } +static void rna_def_transform_orientation(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "TransformOrientation", NULL); + + prop = RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX); + RNA_def_property_float_sdna(prop, NULL, "mat"); + RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_3x3); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_struct_name_property(srna, prop); + RNA_def_property_ui_text(prop, "Name", "Name of the custom transform orientation"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); +} + static void rna_def_tool_settings(BlenderRNA *brna) { StructRNA *srna; @@ -6278,6 +6378,20 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Timeline Markers", "Markers used in all timelines for the current scene"); rna_def_timeline_markers(brna, prop); + /* Orientations */ + prop = RNA_def_property(srna, "transform_orientation", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "orientation_type"); + RNA_def_property_enum_items(prop, transform_orientation_items); + RNA_def_property_enum_funcs(prop, "rna_Scene_transform_orientation_get", "rna_Scene_transform_orientation_set", + "rna_TransformOrientation_itemf"); + RNA_def_property_ui_text(prop, "Transform Orientation", "Transformation orientation"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "current_orientation", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "TransformOrientation"); + RNA_def_property_pointer_funcs(prop, "rna_Scene_current_orientation_get", NULL, NULL, NULL); + RNA_def_property_ui_text(prop, "Current Transform Orientation", "Current transformation orientation"); + /* Audio Settings */ prop = RNA_def_property(srna, "use_audio", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs(prop, "rna_Scene_use_audio_get", "rna_Scene_use_audio_set"); @@ -6387,6 +6501,7 @@ void RNA_def_scene(BlenderRNA *brna) rna_def_statvis(brna); rna_def_unit_settings(brna); rna_def_scene_image_format_data(brna); + rna_def_transform_orientation(brna); rna_def_selected_uv_element(brna); rna_def_display_safe_areas(brna); RNA_define_animate_sdna(true); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index d983f529a48..601a8bffcfa 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -158,18 +158,6 @@ static const EnumPropertyItem draw_channels_items[] = { {0, NULL, 0, NULL, NULL} }; -static const EnumPropertyItem transform_orientation_items[] = { - {V3D_MANIP_GLOBAL, "GLOBAL", 0, "Global", "Align the transformation axes to world space"}, - {V3D_MANIP_LOCAL, "LOCAL", 0, "Local", "Align the transformation axes to the selected objects' local space"}, - {V3D_MANIP_NORMAL, "NORMAL", 0, "Normal", - "Align the transformation axes to average normal of selected elements " - "(bone Y axis for pose mode)"}, - {V3D_MANIP_GIMBAL, "GIMBAL", 0, "Gimbal", "Align each axis to the Euler rotation axis as used for input"}, - {V3D_MANIP_VIEW, "VIEW", 0, "View", "Align the transformation axes to the window"}, - // {V3D_MANIP_CUSTOM, "CUSTOM", 0, "Custom", "Use a custom transform orientation"}, - {0, NULL, 0, NULL, NULL} -}; - #ifndef RNA_RUNTIME static const EnumPropertyItem autosnap_items[] = { {SACTSNAP_OFF, "NONE", 0, "No Auto-Snap", ""}, @@ -435,77 +423,6 @@ static void rna_Space_view2d_sync_update(Main *UNUSED(bmain), Scene *UNUSED(scen } } -static int rna_View3D_transform_orientation_get(PointerRNA *ptr) -{ - const View3D *v3d = (View3D *)ptr->data; - /* convert to enum value */ - return (v3d->twmode == V3D_MANIP_CUSTOM) ? (v3d->twmode + v3d->custom_orientation_index) : v3d->twmode; -} - -void rna_View3D_transform_orientation_set(PointerRNA *ptr, int value) -{ - View3D *v3d = (View3D *)ptr->data; - BIF_selectTransformOrientationValue(v3d, value); -} - -static PointerRNA rna_View3D_current_orientation_get(PointerRNA *ptr) -{ - View3D *v3d = (View3D *)ptr->data; - TransformOrientation *orientation; - - if (v3d->twmode < V3D_MANIP_CUSTOM) { - orientation = NULL; - } - else { - WorkSpace *workspace; - bScreen *screen = ptr->id.data; - - BKE_workspace_layout_find_global(G.main, screen, &workspace); - orientation = BKE_workspace_transform_orientation_find(workspace, v3d->custom_orientation_index); - } - - return rna_pointer_inherit_refine(ptr, &RNA_TransformOrientation, orientation); -} - -const EnumPropertyItem *rna_TransformOrientation_itemf( - bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) -{ - WorkSpace *workspace; - ListBase *transform_orientations; - EnumPropertyItem tmp = {0, "", 0, "", ""}; - EnumPropertyItem *item = NULL; - int i = V3D_MANIP_CUSTOM, totitem = 0; - - RNA_enum_items_add(&item, &totitem, transform_orientation_items); - - if (ptr->type == &RNA_SpaceView3D) { - bScreen *screen = ptr->id.data; - BKE_workspace_layout_find_global(G.main, screen, &workspace); - } - else { - /* can't use scene from ptr->id.data because that enum is also used by operators */ - workspace = C ? CTX_wm_workspace(C) : NULL; - } - - transform_orientations = workspace ? BKE_workspace_transform_orientations_get(workspace) : NULL; - - if (transform_orientations && (BLI_listbase_is_empty(transform_orientations) == false)) { - RNA_enum_item_add_separator(&item, &totitem); - - for (TransformOrientation *ts = transform_orientations->first; ts; ts = ts->next) { - tmp.identifier = ts->name; - tmp.name = ts->name; - tmp.value = i++; - RNA_enum_item_add(&item, &totitem, &tmp); - } - } - - RNA_enum_item_end(&item, &totitem); - *r_free = true; - - return item; -} - /* Space 3D View */ static void rna_SpaceView3D_camera_update(Main *bmain, Scene *scene, PointerRNA *ptr) { @@ -2570,19 +2487,6 @@ static void rna_def_space_view3d(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Transform Manipulators", "Transformation manipulators"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "transform_orientation", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "twmode"); - RNA_def_property_enum_items(prop, transform_orientation_items); - RNA_def_property_enum_funcs(prop, "rna_View3D_transform_orientation_get", "rna_View3D_transform_orientation_set", - "rna_TransformOrientation_itemf"); - RNA_def_property_ui_text(prop, "Transform Orientation", "Transformation orientation"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - - prop = RNA_def_property(srna, "current_orientation", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "TransformOrientation"); - RNA_def_property_pointer_funcs(prop, "rna_View3D_current_orientation_get", NULL, NULL, NULL); - RNA_def_property_ui_text(prop, "Current Transform Orientation", "Current transformation orientation"); - prop = RNA_def_property(srna, "lock_camera_and_layers", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "scenelock", 1); RNA_def_property_boolean_funcs(prop, NULL, "rna_SpaceView3D_lock_camera_and_layers_set"); diff --git a/source/blender/makesrna/intern/rna_workspace.c b/source/blender/makesrna/intern/rna_workspace.c index 609493c54b8..92c45998913 100644 --- a/source/blender/makesrna/intern/rna_workspace.c +++ b/source/blender/makesrna/intern/rna_workspace.c @@ -71,18 +71,6 @@ static PointerRNA rna_workspace_screens_item_get(CollectionPropertyIterator *ite return rna_pointer_inherit_refine(&iter->parent, &RNA_Screen, screen); } -void rna_workspace_transform_orientations_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) -{ - WorkSpace *workspace = ptr->id.data; - rna_iterator_listbase_begin(iter, BKE_workspace_transform_orientations_get(workspace), NULL); -} - -static PointerRNA rna_workspace_transform_orientations_item_get(CollectionPropertyIterator *iter) -{ - TransformOrientation *transform_orientation = rna_iterator_listbase_get(iter); - return rna_pointer_inherit_refine(&iter->parent, &RNA_TransformOrientation, transform_orientation); -} - /* workspace.owner_ids */ static wmOwnerID *rna_WorkSpace_owner_ids_new( @@ -204,13 +192,6 @@ static void rna_def_workspace(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Active Tool Index", "Tool group index"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); - prop = RNA_def_property(srna, "orientations", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "transform_orientations", NULL); - RNA_def_property_struct_type(prop, "TransformOrientation"); - RNA_def_property_collection_funcs(prop, "rna_workspace_transform_orientations_begin", NULL, NULL, - "rna_workspace_transform_orientations_item_get", NULL, NULL, NULL, NULL); - RNA_def_property_ui_text(prop, "Transform Orientations", ""); - prop = RNA_def_property(srna, "owner_ids", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "wmOwnerID"); RNA_def_property_ui_text(prop, "UI Tags", ""); @@ -244,29 +225,10 @@ static void rna_def_workspace(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_window_update_all"); } -static void rna_def_transform_orientation(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "TransformOrientation", NULL); - - prop = RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX); - RNA_def_property_float_sdna(prop, NULL, "mat"); - RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_3x3); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - - prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); - RNA_def_struct_name_property(srna, prop); - RNA_def_property_ui_text(prop, "Name", "Name of the custom transform orientation"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); -} - void RNA_def_workspace(BlenderRNA *brna) { rna_def_workspace_owner(brna); rna_def_workspace(brna); - rna_def_transform_orientation(brna); } #endif /* RNA_RUNTIME */ |