Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/object.c
| Show First 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | |||||
| #include "DNA_world_types.h" | #include "DNA_world_types.h" | ||||
| #include "BLI_blenlib.h" | #include "BLI_blenlib.h" | ||||
| #include "BLI_kdtree.h" | #include "BLI_kdtree.h" | ||||
| #include "BLI_linklist.h" | #include "BLI_linklist.h" | ||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "BLI_threads.h" | #include "BLI_threads.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BLI_string_utils.h" | |||||
| #include "BLT_translation.h" | #include "BLT_translation.h" | ||||
| #include "BKE_DerivedMesh.h" | #include "BKE_DerivedMesh.h" | ||||
| #include "BKE_action.h" | #include "BKE_action.h" | ||||
| #include "BKE_anim.h" | #include "BKE_anim.h" | ||||
| #include "BKE_animsys.h" | #include "BKE_animsys.h" | ||||
| #include "BKE_armature.h" | #include "BKE_armature.h" | ||||
| ▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | |||||
| #include "BKE_scene.h" | #include "BKE_scene.h" | ||||
| #include "BKE_sequencer.h" | #include "BKE_sequencer.h" | ||||
| #include "BKE_shader_fx.h" | #include "BKE_shader_fx.h" | ||||
| #include "BKE_softbody.h" | #include "BKE_softbody.h" | ||||
| #include "BKE_speaker.h" | #include "BKE_speaker.h" | ||||
| #include "BKE_subdiv_ccg.h" | #include "BKE_subdiv_ccg.h" | ||||
| #include "BKE_subsurf.h" | #include "BKE_subsurf.h" | ||||
| #include "BKE_volume.h" | #include "BKE_volume.h" | ||||
| #include "BKE_colortools.h" | |||||
| #include "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| #include "DEG_depsgraph_query.h" | #include "DEG_depsgraph_query.h" | ||||
| #include "DRW_engine.h" | #include "DRW_engine.h" | ||||
| #ifdef WITH_PYTHON | #ifdef WITH_PYTHON | ||||
| # include "BPY_extern.h" | # include "BPY_extern.h" | ||||
| ▲ Show 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | static void object_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const int flag) | ||||
| /* Do not copy object's preview | /* Do not copy object's preview | ||||
| * (mostly due to the fact renderers create temp copy of objects). */ | * (mostly due to the fact renderers create temp copy of objects). */ | ||||
| if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0 && false) { /* XXX TODO temp hack */ | if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0 && false) { /* XXX TODO temp hack */ | ||||
| BKE_previewimg_id_copy(&ob_dst->id, &ob_src->id); | BKE_previewimg_id_copy(&ob_dst->id, &ob_src->id); | ||||
| } | } | ||||
| else { | else { | ||||
| ob_dst->preview = NULL; | ob_dst->preview = NULL; | ||||
| } | } | ||||
| BLI_duplicatelist(&ob_dst->bake_passes, &ob_src->bake_passes); | |||||
| for (BakePass *bp_dst = ob_dst->bake_passes.first, *bp_src = ob_src->bake_passes.first; bp_src; | |||||
| bp_dst = bp_dst->next, bp_src = bp_src->next) { | |||||
| if (bp_dst->prop != NULL) { | |||||
| bp_dst->prop = IDP_CopyProperty_ex(bp_dst->prop, flag_subdata); | |||||
| } | |||||
| BKE_color_managed_display_settings_copy(&bp_dst->im_format.display_settings, | |||||
| &bp_src->im_format.display_settings); | |||||
| BKE_color_managed_view_settings_copy(&bp_dst->im_format.view_settings, | |||||
| &bp_src->im_format.view_settings); | |||||
| } | |||||
| } | } | ||||
| static void object_free_data(ID *id) | static void object_free_data(ID *id) | ||||
| { | { | ||||
| Object *ob = (Object *)id; | Object *ob = (Object *)id; | ||||
| DRW_drawdata_free((ID *)ob); | DRW_drawdata_free((ID *)ob); | ||||
| Show All 37 Lines | if (ob->runtime.curve_cache) { | ||||
| if (ob->runtime.curve_cache->path) { | if (ob->runtime.curve_cache->path) { | ||||
| free_path(ob->runtime.curve_cache->path); | free_path(ob->runtime.curve_cache->path); | ||||
| } | } | ||||
| MEM_freeN(ob->runtime.curve_cache); | MEM_freeN(ob->runtime.curve_cache); | ||||
| ob->runtime.curve_cache = NULL; | ob->runtime.curve_cache = NULL; | ||||
| } | } | ||||
| BKE_previewimg_free(&ob->preview); | BKE_previewimg_free(&ob->preview); | ||||
| for (BakePass *bp = ob->bake_passes.first; bp; bp = bp->next) { | |||||
| if (bp->prop) { | |||||
| IDP_FreeProperty(bp->prop); | |||||
| } | |||||
| } | |||||
| BLI_freelistN(&ob->bake_passes); | |||||
| } | } | ||||
| static void object_make_local(Main *bmain, ID *id, const int flags) | static void object_make_local(Main *bmain, ID *id, const int flags) | ||||
| { | { | ||||
| Object *ob = (Object *)id; | Object *ob = (Object *)id; | ||||
| const bool lib_local = (flags & LIB_ID_MAKELOCAL_FULL_LIBRARY) != 0; | const bool lib_local = (flags & LIB_ID_MAKELOCAL_FULL_LIBRARY) != 0; | ||||
| const bool clear_proxy = (flags & LIB_ID_MAKELOCAL_OBJECT_NO_PROXY_CLEARING) == 0; | const bool clear_proxy = (flags & LIB_ID_MAKELOCAL_OBJECT_NO_PROXY_CLEARING) == 0; | ||||
| bool is_local = false, is_lib = false; | bool is_local = false, is_lib = false; | ||||
| ▲ Show 20 Lines • Show All 4,251 Lines • ▼ Show 20 Lines | |||||
| void BKE_object_to_mesh_clear(Object *object) | void BKE_object_to_mesh_clear(Object *object) | ||||
| { | { | ||||
| if (object->runtime.object_as_temp_mesh == NULL) { | if (object->runtime.object_as_temp_mesh == NULL) { | ||||
| return; | return; | ||||
| } | } | ||||
| BKE_id_free(NULL, object->runtime.object_as_temp_mesh); | BKE_id_free(NULL, object->runtime.object_as_temp_mesh); | ||||
| object->runtime.object_as_temp_mesh = NULL; | object->runtime.object_as_temp_mesh = NULL; | ||||
| } | } | ||||
| /* return default layer, also used to patch old files */ | |||||
| BakePass *BKE_object_add_bake_pass(Object *ob, const char *name) | |||||
| { | |||||
| BakePass *bp; | |||||
| if (!name) | |||||
| name = DATA_("BakePass"); | |||||
| bp = MEM_callocN(sizeof(BakePass), "new bake pass"); | |||||
| BLI_strncpy(bp->name, name, sizeof(bp->name)); | |||||
| bp->flag = R_BAKE_CLEAR | R_BAKE_ENABLED; | |||||
| bp->width = 512; | |||||
| bp->height = 512; | |||||
| bp->margin = 16; | |||||
| bp->normal_space = R_BAKE_SPACE_TANGENT; | |||||
| bp->normal_swizzle[0] = R_BAKE_POSX; | |||||
| bp->normal_swizzle[1] = R_BAKE_POSY; | |||||
| bp->normal_swizzle[2] = R_BAKE_POSZ; | |||||
| BLI_strncpy(bp->filepath, U.renderdir, sizeof(bp->filepath)); | |||||
| bp->im_format.planes = R_IMF_PLANES_RGBA; | |||||
| bp->im_format.imtype = R_IMF_IMTYPE_PNG; | |||||
| bp->im_format.depth = R_IMF_CHAN_DEPTH_8; | |||||
| bp->im_format.quality = 90; | |||||
| bp->im_format.compress = 15; | |||||
| BLI_uniquename( | |||||
| &ob->bake_passes, bp, DATA_("BakePass"), '.', offsetof(BakePass, name), sizeof(bp->name)); | |||||
| BLI_addtail(&ob->bake_passes, bp); | |||||
| return bp; | |||||
| } | |||||
| bool BKE_object_remove_bake_pass(Object *ob, BakePass *bp) | |||||
| { | |||||
| const int act = BLI_findindex(&ob->bake_passes, bp); | |||||
| if (act == -1) { | |||||
| return false; | |||||
| } | |||||
| if (bp->prop) { | |||||
| IDP_FreeProperty(bp->prop); | |||||
| } | |||||
| BLI_remlink(&ob->bake_passes, bp); | |||||
| MEM_freeN(bp); | |||||
| ob->active_bake_pass = 0; | |||||
| return true; | |||||
| } | |||||