Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/object.c
| Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | |||||
| #include "DNA_smoke_types.h" | #include "DNA_smoke_types.h" | ||||
| #include "DNA_space_types.h" | #include "DNA_space_types.h" | ||||
| #include "DNA_view3d_types.h" | #include "DNA_view3d_types.h" | ||||
| #include "DNA_world_types.h" | #include "DNA_world_types.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_lightprobe_types.h" | #include "DNA_lightprobe_types.h" | ||||
| #include "DNA_property_types.h" | #include "DNA_property_types.h" | ||||
| #include "DNA_rigidbody_types.h" | #include "DNA_rigidbody_types.h" | ||||
| #include "DNA_workspace_types.h" | |||||
| #include "BLI_blenlib.h" | #include "BLI_blenlib.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_linklist.h" | #include "BLI_linklist.h" | ||||
| #include "BLI_kdtree.h" | #include "BLI_kdtree.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_speaker.h" | #include "BKE_speaker.h" | ||||
| #include "BKE_softbody.h" | #include "BKE_softbody.h" | ||||
| #include "BKE_subsurf.h" | #include "BKE_subsurf.h" | ||||
| #include "BKE_material.h" | #include "BKE_material.h" | ||||
| #include "BKE_camera.h" | #include "BKE_camera.h" | ||||
| #include "BKE_image.h" | #include "BKE_image.h" | ||||
| #include "BKE_workspace.h" | |||||
| #include "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| #include "DRW_engine.h" | #include "DRW_engine.h" | ||||
| #ifdef WITH_MOD_FLUID | #ifdef WITH_MOD_FLUID | ||||
| #include "LBM_fluidsim.h" | #include "LBM_fluidsim.h" | ||||
| #endif | #endif | ||||
| ▲ Show 20 Lines • Show All 349 Lines • ▼ Show 20 Lines | void BKE_object_free(Object *ob) | ||||
| } | } | ||||
| BKE_previewimg_free(&ob->preview); | BKE_previewimg_free(&ob->preview); | ||||
| /* don't free, let the base free it */ | /* don't free, let the base free it */ | ||||
| ob->base_collection_properties = NULL; | ob->base_collection_properties = NULL; | ||||
| } | } | ||||
| /** | |||||
| * Checks the mode to be set is compatible with the object | |||||
| * should be made into a generic function. | |||||
| */ | |||||
| bool BKE_object_is_mode_compatible(const Object *ob, int mode) | |||||
| { | |||||
| eObjectMode _mode = mode; | |||||
| if (ob) { | |||||
| if (_mode == OB_MODE_OBJECT) | |||||
| return true; | |||||
| else if (_mode == OB_MODE_GPENCIL) | |||||
| return true; /* XXX: assume this is the case for now... */ | |||||
| switch (ob->type) { | |||||
| case OB_MESH: | |||||
| if (_mode & (OB_MODE_EDIT | OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | | |||||
| OB_MODE_TEXTURE_PAINT | OB_MODE_PARTICLE_EDIT)) | |||||
| { | |||||
| return true; | |||||
| } | |||||
| break; | |||||
| case OB_CURVE: | |||||
| case OB_SURF: | |||||
| case OB_FONT: | |||||
| case OB_MBALL: | |||||
| if (_mode & (OB_MODE_EDIT)) | |||||
| return true; | |||||
| break; | |||||
| case OB_LATTICE: | |||||
| if (_mode & (OB_MODE_EDIT | OB_MODE_WEIGHT_PAINT)) | |||||
| return true; | |||||
| break; | |||||
| case OB_ARMATURE: | |||||
| if (_mode & (OB_MODE_EDIT | OB_MODE_POSE)) | |||||
| return true; | |||||
| break; | |||||
| } | |||||
| } | |||||
| return false; | |||||
| } | |||||
| /* actual check for internal data, not context or flags */ | /* actual check for internal data, not context or flags */ | ||||
| bool BKE_object_is_in_editmode(Object *ob) | bool BKE_object_is_in_editmode(Object *ob) | ||||
| { | { | ||||
| if (ob->data == NULL) | if (ob->data == NULL) | ||||
| return false; | return false; | ||||
| if (ob->type == OB_MESH) { | if (ob->type == OB_MESH) { | ||||
| Mesh *me = ob->data; | Mesh *me = ob->data; | ||||
| ▲ Show 20 Lines • Show All 255 Lines • ▼ Show 20 Lines | |||||
| * General add: to scene, with layer from area and default name | * General add: to scene, with layer from area and default name | ||||
| * | * | ||||
| * Object is added to the active SceneCollection. | * Object is added to the active SceneCollection. | ||||
| * If there is no linked collection to the active ViewLayer we create a new one. | * If there is no linked collection to the active ViewLayer we create a new one. | ||||
| */ | */ | ||||
| /* creates minimum required data, but without vertices etc. */ | /* creates minimum required data, but without vertices etc. */ | ||||
| Object *BKE_object_add( | Object *BKE_object_add( | ||||
| Main *bmain, Scene *scene, ViewLayer *view_layer, | Main *bmain, Scene *scene, ViewLayer *view_layer, | ||||
| WorkSpace *workspace, | |||||
| int type, const char *name) | int type, const char *name) | ||||
| { | { | ||||
| Object *ob; | Object *ob; | ||||
| Base *base; | Base *base; | ||||
| LayerCollection *layer_collection; | LayerCollection *layer_collection; | ||||
| ob = object_add_common(bmain, view_layer, type, name); | ob = object_add_common(bmain, view_layer, type, name); | ||||
| layer_collection = BKE_layer_collection_get_active_ensure(scene, view_layer); | layer_collection = BKE_layer_collection_get_active_ensure(scene, view_layer); | ||||
| BKE_collection_object_add(&scene->id, layer_collection->scene_collection, ob); | BKE_collection_object_add(&scene->id, layer_collection->scene_collection, ob); | ||||
| base = BKE_view_layer_base_find(view_layer, ob); | base = BKE_view_layer_base_find(view_layer, ob); | ||||
| BKE_view_layer_base_select(view_layer, base); | BKE_view_layer_base_select(view_layer, base, workspace); | ||||
| return ob; | return ob; | ||||
| } | } | ||||
| /** | /** | ||||
| * Add a new object, using another one as a reference | * Add a new object, using another one as a reference | ||||
| * | * | ||||
| * /param ob_src object to use to determine the collections of the new object. | * /param ob_src object to use to determine the collections of the new object. | ||||
| */ | */ | ||||
| Object *BKE_object_add_from( | Object *BKE_object_add_from( | ||||
| Main *bmain, Scene *scene, ViewLayer *view_layer, | Main *bmain, Scene *scene, ViewLayer *view_layer, | ||||
| int type, const char *name, Object *ob_src) | int type, const char *name, Object *ob_src, | ||||
| WorkSpace *workspace) | |||||
| { | { | ||||
| Object *ob; | Object *ob; | ||||
| Base *base; | Base *base; | ||||
| ob = object_add_common(bmain, view_layer, type, name); | ob = object_add_common(bmain, view_layer, type, name); | ||||
| BKE_collection_object_add_from(scene, ob_src, ob); | BKE_collection_object_add_from(scene, ob_src, ob); | ||||
| base = BKE_view_layer_base_find(view_layer, ob); | base = BKE_view_layer_base_find(view_layer, ob); | ||||
| BKE_view_layer_base_select(view_layer, base); | BKE_view_layer_base_select(view_layer, base, workspace); | ||||
| return ob; | return ob; | ||||
| } | } | ||||
| #ifdef WITH_GAMEENGINE | #ifdef WITH_GAMEENGINE | ||||
| void BKE_object_lod_add(Object *ob) | void BKE_object_lod_add(Object *ob) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 2,972 Lines • Show Last 20 Lines | |||||