Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/mball.c
| Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | |||||
| /* Functions */ | /* Functions */ | ||||
| /** Free (or release) any data used by this mball (does not free the mball itself). */ | /** Free (or release) any data used by this mball (does not free the mball itself). */ | ||||
| void BKE_mball_free(MetaBall *mb) | void BKE_mball_free(MetaBall *mb) | ||||
| { | { | ||||
| BKE_animdata_free((ID *)mb, false); | BKE_animdata_free((ID *)mb, false); | ||||
| BKE_mball_batch_cache_free(mb); | |||||
| MEM_SAFE_FREE(mb->mat); | MEM_SAFE_FREE(mb->mat); | ||||
| BLI_freelistN(&mb->elems); | BLI_freelistN(&mb->elems); | ||||
| if (mb->disp.first) BKE_displist_free(&mb->disp); | if (mb->disp.first) BKE_displist_free(&mb->disp); | ||||
| } | } | ||||
| void BKE_mball_init(MetaBall *mb) | void BKE_mball_init(MetaBall *mb) | ||||
| { | { | ||||
| Show All 29 Lines | |||||
| void BKE_mball_copy_data(Main *UNUSED(bmain), MetaBall *mb_dst, const MetaBall *mb_src, const int UNUSED(flag)) | void BKE_mball_copy_data(Main *UNUSED(bmain), MetaBall *mb_dst, const MetaBall *mb_src, const int UNUSED(flag)) | ||||
| { | { | ||||
| BLI_duplicatelist(&mb_dst->elems, &mb_src->elems); | BLI_duplicatelist(&mb_dst->elems, &mb_src->elems); | ||||
| mb_dst->mat = MEM_dupallocN(mb_src->mat); | mb_dst->mat = MEM_dupallocN(mb_src->mat); | ||||
| mb_dst->editelems = NULL; | mb_dst->editelems = NULL; | ||||
| mb_dst->lastelem = NULL; | mb_dst->lastelem = NULL; | ||||
| mb_dst->batch_cache = NULL; | |||||
| } | } | ||||
| MetaBall *BKE_mball_copy(Main *bmain, const MetaBall *mb) | MetaBall *BKE_mball_copy(Main *bmain, const MetaBall *mb) | ||||
| { | { | ||||
| MetaBall *mb_copy; | MetaBall *mb_copy; | ||||
| BKE_id_copy_ex(bmain, &mb->id, (ID **)&mb_copy, 0, false); | BKE_id_copy_ex(bmain, &mb->id, (ID **)&mb_copy, 0, false); | ||||
| return mb_copy; | return mb_copy; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 406 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /* **** Depsgraph evaluation **** */ | /* **** Depsgraph evaluation **** */ | ||||
| void BKE_mball_eval_geometry(const struct EvaluationContext *UNUSED(eval_ctx), | void BKE_mball_eval_geometry(const struct EvaluationContext *UNUSED(eval_ctx), | ||||
| MetaBall *UNUSED(mball)) | MetaBall *UNUSED(mball)) | ||||
| { | { | ||||
| } | } | ||||
| /* Draw Engine */ | |||||
| /* use for draw-manager only. */ | |||||
Severin: `const` should be used for passing arrays that should not be modified. Remember, they are… | |||||
| void BKE_mball_element_calc_display_m3x4(float r_scale_xform[3][4], | |||||
| const float obmat[4][4], | |||||
| const float local_pos[3]) | |||||
| { | |||||
| float world_pos[3], scamat[3][3]; | |||||
| mul_v3_m4v3(world_pos, obmat, local_pos); | |||||
| copy_m3_m4(scamat, obmat); | |||||
| { | |||||
| /* Get the normalized inverse matrix to extract only | |||||
| * the scale of Scamat */ | |||||
| float iscamat[3][3]; | |||||
| invert_m3_m3(iscamat, scamat); | |||||
| normalize_m3(iscamat); | |||||
| mul_m3_m3_post(scamat, iscamat); | |||||
| } | |||||
| copy_v3_v3(r_scale_xform[0], scamat[0]); | |||||
| copy_v3_v3(r_scale_xform[1], scamat[1]); | |||||
| copy_v3_v3(r_scale_xform[2], scamat[2]); | |||||
| r_scale_xform[0][3] = world_pos[0]; | |||||
| r_scale_xform[1][3] = world_pos[1]; | |||||
| r_scale_xform[2][3] = world_pos[2]; | |||||
| } | |||||
Done Inline Actionscould use copy_v3v3 here campbellbarton: could use copy_v3v3 here | |||||
| void (*BKE_mball_batch_cache_dirty_cb)(MetaBall *mb, int mode) = NULL; | |||||
| void (*BKE_mball_batch_cache_free_cb)(MetaBall *mb) = NULL; | |||||
| void BKE_mball_batch_cache_dirty(MetaBall *mb, int mode) | |||||
| { | |||||
| if (mb->batch_cache) { | |||||
| BKE_mball_batch_cache_dirty_cb(mb, mode); | |||||
| } | |||||
| } | |||||
| void BKE_mball_batch_cache_free(MetaBall *mb) | |||||
| { | |||||
| if (mb->batch_cache) { | |||||
| BKE_mball_batch_cache_free_cb(mb); | |||||
| } | |||||
| } | |||||
const should be used for passing arrays that should not be modified. Remember, they are basically non-const pointers otherwise.