Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/hair.c
| Show First 20 Lines • Show All 241 Lines • ▼ Show 20 Lines | if (reference) { | ||||
| flags |= LIB_ID_COPY_CD_REFERENCE; | flags |= LIB_ID_COPY_CD_REFERENCE; | ||||
| } | } | ||||
| Hair *result; | Hair *result; | ||||
| BKE_id_copy_ex(NULL, &hair_src->id, (ID **)&result, flags); | BKE_id_copy_ex(NULL, &hair_src->id, (ID **)&result, flags); | ||||
| return result; | return result; | ||||
| } | } | ||||
| static Hair *hair_evaluate_modifiers(struct Depsgraph *UNUSED(depsgraph), | static Hair *hair_evaluate_modifiers(struct Depsgraph *depsgraph, | ||||
| struct Scene *UNUSED(scene), | struct Scene *scene, | ||||
| Object *UNUSED(object), | Object *object, | ||||
| Hair *hair_input) | Hair *hair_input) | ||||
| { | { | ||||
| return hair_input; | Hair *hair = hair_input; | ||||
| /* Modifier evaluation modes. */ | |||||
| const bool use_render = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER); | |||||
| const int required_mode = use_render ? eModifierMode_Render : eModifierMode_Realtime; | |||||
| ModifierApplyFlag appflag = use_render ? MOD_APPLY_RENDER : MOD_APPLY_USECACHE; | |||||
JacquesLucke: `apply_flag` | |||||
| const ModifierEvalContext mectx = {depsgraph, object, appflag}; | |||||
| /* Get effective list of modifiers to execute. Some effects like shape keys | |||||
| * are added as virtual modifiers before the user created modifiers. */ | |||||
| VirtualModifierData virtualModifierData; | |||||
| ModifierData *md = modifiers_getVirtualModifierList(object, &virtualModifierData); | |||||
| /* Evaluate modifiers. */ | |||||
| for (; md; md = md->next) { | |||||
| const ModifierTypeInfo *mti = modifierType_getInfo(md->type); | |||||
| if (!modifier_isEnabled(scene, md, required_mode)) { | |||||
| continue; | |||||
| } | |||||
| if ((mti->type == eModifierTypeType_OnlyDeform) && | |||||
| (mti->flags & eModifierTypeFlag_AcceptsVertexCosOnly)) { | |||||
| /* Ensure we are not modifying the input. */ | |||||
| if (hair == hair_input) { | |||||
| hair = BKE_hair_copy_for_eval(hair, true); | |||||
| } | |||||
| /* Ensure we are not overwriting referenced data. */ | |||||
| CustomData_duplicate_referenced_layer(&hair->pdata, CD_LOCATION, hair->totpoint); | |||||
| BKE_hair_update_customdata_pointers(hair); | |||||
| /* Created deformed coordinates array on demand. */ | |||||
| mti->deformVerts(md, &mectx, NULL, hair->co, hair->totpoint); | |||||
| } | |||||
| else if (mti->modifyHair) { | |||||
| /* Ensure we are not modifying the input. */ | |||||
| if (hair == hair_input) { | |||||
| hair = BKE_hair_copy_for_eval(hair, true); | |||||
| } | |||||
| Hair *hair_next = mti->modifyHair(md, &mectx, hair); | |||||
| if (hair_next && hair_next != hair) { | |||||
| /* If the modifier returned a new hair, release the old one. */ | |||||
| if (hair != hair_input) { | |||||
| BKE_id_free(NULL, hair); | |||||
| } | |||||
| hair = hair_next; | |||||
| } | |||||
| } | |||||
| } | |||||
| return hair; | |||||
| } | } | ||||
| void BKE_hair_data_update(struct Depsgraph *depsgraph, struct Scene *scene, Object *object) | void BKE_hair_data_update(struct Depsgraph *depsgraph, struct Scene *scene, Object *object) | ||||
| { | { | ||||
| /* Free any evaluated data and restore original data. */ | /* Free any evaluated data and restore original data. */ | ||||
| BKE_object_free_derived_caches(object); | BKE_object_free_derived_caches(object); | ||||
| /* Evaluate modifiers. */ | /* Evaluate modifiers. */ | ||||
| Show All 25 Lines | |||||
apply_flag