Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/object.c
| Show All 28 Lines | |||||
| * \ingroup bke | * \ingroup bke | ||||
| */ | */ | ||||
| #include <string.h> | #include <string.h> | ||||
| #include <math.h> | #include <math.h> | ||||
| #include <stdio.h> | #include <stdio.h> | ||||
| #include "CLG_log.h" | |||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "DNA_anim_types.h" | #include "DNA_anim_types.h" | ||||
| #include "DNA_armature_types.h" | #include "DNA_armature_types.h" | ||||
| #include "DNA_camera_types.h" | #include "DNA_camera_types.h" | ||||
| #include "DNA_collection_types.h" | #include "DNA_collection_types.h" | ||||
| #include "DNA_constraint_types.h" | #include "DNA_constraint_types.h" | ||||
| #include "DNA_gpencil_types.h" | #include "DNA_gpencil_types.h" | ||||
| ▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | |||||
| #ifdef WITH_PYTHON | #ifdef WITH_PYTHON | ||||
| #include "BPY_extern.h" | #include "BPY_extern.h" | ||||
| #endif | #endif | ||||
| #include "CCGSubSurf.h" | #include "CCGSubSurf.h" | ||||
| #include "atomic_ops.h" | #include "atomic_ops.h" | ||||
| static CLG_LogRef LOG = {"bke.object"}; | |||||
| /* Vertex parent modifies original BMesh which is not safe for threading. | /* Vertex parent modifies original BMesh which is not safe for threading. | ||||
| * Ideally such a modification should be handled as a separate DAG update | * Ideally such a modification should be handled as a separate DAG update | ||||
| * callback for mesh datablock, but for until it is actually supported use | * callback for mesh datablock, but for until it is actually supported use | ||||
| * simpler solution with a mutex lock. | * simpler solution with a mutex lock. | ||||
| * - sergey - | * - sergey - | ||||
| */ | */ | ||||
| #define VPARENT_THREADING_HACK | #define VPARENT_THREADING_HACK | ||||
| ▲ Show 20 Lines • Show All 627 Lines • ▼ Show 20 Lines | switch (type) { | ||||
| case OB_CAMERA: return DATA_("Camera"); | case OB_CAMERA: return DATA_("Camera"); | ||||
| case OB_LAMP: return DATA_("Light"); | case OB_LAMP: return DATA_("Light"); | ||||
| case OB_LATTICE: return DATA_("Lattice"); | case OB_LATTICE: return DATA_("Lattice"); | ||||
| case OB_ARMATURE: return DATA_("Armature"); | case OB_ARMATURE: return DATA_("Armature"); | ||||
| case OB_SPEAKER: return DATA_("Speaker"); | case OB_SPEAKER: return DATA_("Speaker"); | ||||
| case OB_EMPTY: return DATA_("Empty"); | case OB_EMPTY: return DATA_("Empty"); | ||||
| case OB_GPENCIL: return DATA_("GPencil"); | case OB_GPENCIL: return DATA_("GPencil"); | ||||
| default: | default: | ||||
| printf("get_obdata_defname: Internal error, bad type: %d\n", type); | CLOG_ERROR(&LOG, "Internal error, bad type: %d", type); | ||||
| return DATA_("Empty"); | return DATA_("Empty"); | ||||
| } | } | ||||
| } | } | ||||
| void *BKE_object_obdata_add_from_type(Main *bmain, int type, const char *name) | void *BKE_object_obdata_add_from_type(Main *bmain, int type, const char *name) | ||||
| { | { | ||||
| if (name == NULL) { | if (name == NULL) { | ||||
| name = get_obdata_defname(type); | name = get_obdata_defname(type); | ||||
| Show All 9 Lines | switch (type) { | ||||
| case OB_LAMP: return BKE_lamp_add(bmain, name); | case OB_LAMP: return BKE_lamp_add(bmain, name); | ||||
| case OB_LATTICE: return BKE_lattice_add(bmain, name); | case OB_LATTICE: return BKE_lattice_add(bmain, name); | ||||
| case OB_ARMATURE: return BKE_armature_add(bmain, name); | case OB_ARMATURE: return BKE_armature_add(bmain, name); | ||||
| case OB_SPEAKER: return BKE_speaker_add(bmain, name); | case OB_SPEAKER: return BKE_speaker_add(bmain, name); | ||||
| case OB_LIGHTPROBE:return BKE_lightprobe_add(bmain, name); | case OB_LIGHTPROBE:return BKE_lightprobe_add(bmain, name); | ||||
| case OB_GPENCIL: return BKE_gpencil_data_addnew(bmain, name); | case OB_GPENCIL: return BKE_gpencil_data_addnew(bmain, name); | ||||
| case OB_EMPTY: return NULL; | case OB_EMPTY: return NULL; | ||||
| default: | default: | ||||
| printf("%s: Internal error, bad type: %d\n", __func__, type); | CLOG_ERROR(&LOG, "Internal error, bad type: %d", type); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| } | } | ||||
| void BKE_object_init(Object *ob) | void BKE_object_init(Object *ob) | ||||
| { | { | ||||
| /* BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(ob, id)); */ /* ob->type is already initialized... */ | /* BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(ob, id)); */ /* ob->type is already initialized... */ | ||||
| ▲ Show 20 Lines • Show All 740 Lines • ▼ Show 20 Lines | |||||
| /* proxy rule: lib_object->proxy_from == the one we borrow from, set temporally while object_update */ | /* proxy rule: lib_object->proxy_from == the one we borrow from, set temporally while object_update */ | ||||
| /* local_object->proxy == pointer to library object, saved in files and read */ | /* local_object->proxy == pointer to library object, saved in files and read */ | ||||
| /* local_object->proxy_group == pointer to collection dupli-object, saved in files and read */ | /* local_object->proxy_group == pointer to collection dupli-object, saved in files and read */ | ||||
| void BKE_object_make_proxy(Main *bmain, Object *ob, Object *target, Object *cob) | void BKE_object_make_proxy(Main *bmain, Object *ob, Object *target, Object *cob) | ||||
| { | { | ||||
| /* paranoia checks */ | /* paranoia checks */ | ||||
| if (ID_IS_LINKED(ob) || !ID_IS_LINKED(target)) { | if (ID_IS_LINKED(ob) || !ID_IS_LINKED(target)) { | ||||
| printf("cannot make proxy\n"); | CLOG_ERROR(&LOG, "cannot make proxy"); | ||||
| return; | return; | ||||
| } | } | ||||
| ob->proxy = target; | ob->proxy = target; | ||||
| ob->proxy_group = cob; | ob->proxy_group = cob; | ||||
| id_lib_extern(&target->id); | id_lib_extern(&target->id); | ||||
| DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION); | DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION); | ||||
| ▲ Show 20 Lines • Show All 412 Lines • ▼ Show 20 Lines | static void ob_parbone(Object *ob, Object *par, float mat[4][4]) | ||||
| if (par->type != OB_ARMATURE) { | if (par->type != OB_ARMATURE) { | ||||
| unit_m4(mat); | unit_m4(mat); | ||||
| return; | return; | ||||
| } | } | ||||
| /* Make sure the bone is still valid */ | /* Make sure the bone is still valid */ | ||||
| pchan = BKE_pose_channel_find_name(par->pose, ob->parsubstr); | pchan = BKE_pose_channel_find_name(par->pose, ob->parsubstr); | ||||
| if (!pchan || !pchan->bone) { | if (!pchan || !pchan->bone) { | ||||
| printf("Object %s with Bone parent: bone %s doesn't exist\n", ob->id.name + 2, ob->parsubstr); | CLOG_ERROR(&LOG, "Object %s with Bone parent: bone %s doesn't exist", ob->id.name + 2, ob->parsubstr); | ||||
| unit_m4(mat); | unit_m4(mat); | ||||
| return; | return; | ||||
| } | } | ||||
| /* get bone transform */ | /* get bone transform */ | ||||
| if (pchan->bone->flag & BONE_RELATIVE_PARENTING) { | if (pchan->bone->flag & BONE_RELATIVE_PARENTING) { | ||||
| /* the new option uses the root - expected behavior, but differs from old... */ | /* the new option uses the root - expected behavior, but differs from old... */ | ||||
| /* XXX check on version patching? */ | /* XXX check on version patching? */ | ||||
| ▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | #endif | ||||
| else { | else { | ||||
| /* use first index if its out of range */ | /* use first index if its out of range */ | ||||
| if (me_eval->totvert) { | if (me_eval->totvert) { | ||||
| copy_v3_v3(vec, me_eval->mvert[0].co); | copy_v3_v3(vec, me_eval->mvert[0].co); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| fprintf(stderr, | CLOG_ERROR(&LOG, "Evaluated mesh is needed to solve parenting, " | ||||
| "%s: Evaluated mesh is needed to solve parenting, " | "object position can be wrong now"); | ||||
| "object position can be wrong now\n", __func__); | |||||
| } | } | ||||
| } | } | ||||
| else if (ELEM(par->type, OB_CURVE, OB_SURF)) { | else if (ELEM(par->type, OB_CURVE, OB_SURF)) { | ||||
| ListBase *nurb; | ListBase *nurb; | ||||
| /* Unless there's some weird depsgraph failure the cache should exist. */ | /* Unless there's some weird depsgraph failure the cache should exist. */ | ||||
| BLI_assert(par->runtime.curve_cache != NULL); | BLI_assert(par->runtime.curve_cache != NULL); | ||||
| ▲ Show 20 Lines • Show All 2,028 Lines • Show Last 20 Lines | |||||