Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/crazyspace.cc
- This file was moved from source/blender/blenkernel/intern/crazyspace.c.
| Show First 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | static void set_crazy_vertex_quat(float r_quat[4], | ||||
| tan_calc_quat_v3(q2, vd_1, vd_2, vd_3); | tan_calc_quat_v3(q2, vd_1, vd_2, vd_3); | ||||
| sub_qt_qtqt(r_quat, q2, q1); | sub_qt_qtqt(r_quat, q2, q1); | ||||
| } | } | ||||
| static bool modifiers_disable_subsurf_temporary(struct Scene *scene, Object *ob) | static bool modifiers_disable_subsurf_temporary(struct Scene *scene, Object *ob) | ||||
| { | { | ||||
| bool disabled = false; | bool disabled = false; | ||||
| int cageIndex = BKE_modifiers_get_cage_index(scene, ob, NULL, 1); | int cageIndex = BKE_modifiers_get_cage_index(scene, ob, nullptr, 1); | ||||
| ModifierData *md = ob->modifiers.first; | ModifierData *md = static_cast<ModifierData *>(ob->modifiers.first); | ||||
| for (int i = 0; md && i <= cageIndex; i++, md = md->next) { | for (int i = 0; md && i <= cageIndex; i++, md = md->next) { | ||||
| if (md->type == eModifierType_Subsurf) { | if (md->type == eModifierType_Subsurf) { | ||||
| md->mode ^= eModifierMode_DisableTemporary; | md->mode ^= eModifierMode_DisableTemporary; | ||||
| disabled = true; | disabled = true; | ||||
| } | } | ||||
| } | } | ||||
| return disabled; | return disabled; | ||||
| } | } | ||||
| float (*BKE_crazyspace_get_mapped_editverts(struct Depsgraph *depsgraph, Object *obedit))[3] | float (*BKE_crazyspace_get_mapped_editverts(struct Depsgraph *depsgraph, Object *obedit))[3] | ||||
| { | { | ||||
| Scene *scene = DEG_get_input_scene(depsgraph); | Scene *scene = DEG_get_input_scene(depsgraph); | ||||
| Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); | Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); | ||||
| Object *obedit_eval = DEG_get_evaluated_object(depsgraph, obedit); | Object *obedit_eval = DEG_get_evaluated_object(depsgraph, obedit); | ||||
| Mesh *mesh_eval = obedit_eval->data; | Mesh *mesh_eval = static_cast<Mesh *>(obedit_eval->data); | ||||
| BMEditMesh *editmesh_eval = mesh_eval->edit_mesh; | BMEditMesh *editmesh_eval = mesh_eval->edit_mesh; | ||||
| /* disable subsurf temporal, get mapped cos, and enable it */ | /* disable subsurf temporal, get mapped cos, and enable it */ | ||||
| if (modifiers_disable_subsurf_temporary(scene_eval, obedit_eval)) { | if (modifiers_disable_subsurf_temporary(scene_eval, obedit_eval)) { | ||||
| /* need to make new derivemesh */ | /* need to make new derivemesh */ | ||||
| makeDerivedMesh(depsgraph, scene_eval, obedit_eval, &CD_MASK_BAREMESH); | makeDerivedMesh(depsgraph, scene_eval, obedit_eval, &CD_MASK_BAREMESH); | ||||
| } | } | ||||
| /* now get the cage */ | /* now get the cage */ | ||||
| Mesh *mesh_eval_cage = editbmesh_get_eval_cage_from_orig( | Mesh *mesh_eval_cage = editbmesh_get_eval_cage_from_orig( | ||||
| depsgraph, scene, obedit, &CD_MASK_BAREMESH); | depsgraph, scene, obedit, &CD_MASK_BAREMESH); | ||||
| const int nverts = editmesh_eval->bm->totvert; | const int nverts = editmesh_eval->bm->totvert; | ||||
| float(*vertexcos)[3] = MEM_mallocN(sizeof(*vertexcos) * nverts, "vertexcos map"); | float(*vertexcos)[3] = static_cast<float(*)[3]>( | ||||
| MEM_mallocN(sizeof(*vertexcos) * nverts, "vertexcos map")); | |||||
| mesh_get_mapped_verts_coords(mesh_eval_cage, vertexcos, nverts); | mesh_get_mapped_verts_coords(mesh_eval_cage, vertexcos, nverts); | ||||
| /* set back the flag, no new cage needs to be built, transform does it */ | /* set back the flag, no new cage needs to be built, transform does it */ | ||||
| modifiers_disable_subsurf_temporary(scene_eval, obedit_eval); | modifiers_disable_subsurf_temporary(scene_eval, obedit_eval); | ||||
| return vertexcos; | return vertexcos; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 115 Lines • ▼ Show 20 Lines | |||||
| int BKE_crazyspace_get_first_deform_matrices_editbmesh(struct Depsgraph *depsgraph, | int BKE_crazyspace_get_first_deform_matrices_editbmesh(struct Depsgraph *depsgraph, | ||||
| Scene *scene, | Scene *scene, | ||||
| Object *ob, | Object *ob, | ||||
| BMEditMesh *em, | BMEditMesh *em, | ||||
| float (**deformmats)[3][3], | float (**deformmats)[3][3], | ||||
| float (**deformcos)[3]) | float (**deformcos)[3]) | ||||
| { | { | ||||
| ModifierData *md; | ModifierData *md; | ||||
| Mesh *me_input = ob->data; | Mesh *me_input = static_cast<Mesh *>(ob->data); | ||||
| Mesh *me = NULL; | Mesh *me = nullptr; | ||||
| int i, a, modifiers_left_num = 0, verts_num = 0; | int i, a, modifiers_left_num = 0, verts_num = 0; | ||||
| int cageIndex = BKE_modifiers_get_cage_index(scene, ob, NULL, 1); | int cageIndex = BKE_modifiers_get_cage_index(scene, ob, nullptr, 1); | ||||
| float(*defmats)[3][3] = NULL, (*deformedVerts)[3] = NULL; | float(*defmats)[3][3] = nullptr, (*deformedVerts)[3] = nullptr; | ||||
| VirtualModifierData virtualModifierData; | VirtualModifierData virtualModifierData; | ||||
| ModifierEvalContext mectx = {depsgraph, ob, 0}; | ModifierEvalContext mectx = {depsgraph, ob, ModifierApplyFlag(0)}; | ||||
| BKE_modifiers_clear_errors(ob); | BKE_modifiers_clear_errors(ob); | ||||
| md = BKE_modifiers_get_virtual_modifierlist(ob, &virtualModifierData); | md = BKE_modifiers_get_virtual_modifierlist(ob, &virtualModifierData); | ||||
| /* compute the deformation matrices and coordinates for the first | /* compute the deformation matrices and coordinates for the first | ||||
| * modifiers with on cage editing that are enabled and support computing | * modifiers with on cage editing that are enabled and support computing | ||||
| * deform matrices */ | * deform matrices */ | ||||
| for (i = 0; md && i <= cageIndex; i++, md = md->next) { | for (i = 0; md && i <= cageIndex; i++, md = md->next) { | ||||
| const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type); | const ModifierTypeInfo *mti = BKE_modifier_get_info(static_cast<ModifierType>(md->type)); | ||||
| if (!editbmesh_modifier_is_enabled(scene, ob, md, me != NULL)) { | if (!editbmesh_modifier_is_enabled(scene, ob, md, me != nullptr)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (mti->type == eModifierTypeType_OnlyDeform && mti->deformMatricesEM) { | if (mti->type == eModifierTypeType_OnlyDeform && mti->deformMatricesEM) { | ||||
| if (!defmats) { | if (!defmats) { | ||||
| const int required_mode = eModifierMode_Realtime | eModifierMode_Editmode; | const int required_mode = eModifierMode_Realtime | eModifierMode_Editmode; | ||||
| CustomData_MeshMasks cd_mask_extra = CD_MASK_BAREMESH; | CustomData_MeshMasks cd_mask_extra = CD_MASK_BAREMESH; | ||||
| CDMaskLink *datamasks = BKE_modifier_calc_data_masks( | CDMaskLink *datamasks = BKE_modifier_calc_data_masks( | ||||
| scene, ob, md, &cd_mask_extra, required_mode, NULL, NULL); | scene, ob, md, &cd_mask_extra, required_mode, nullptr, nullptr); | ||||
| cd_mask_extra = datamasks->mask; | cd_mask_extra = datamasks->mask; | ||||
| BLI_linklist_free((LinkNode *)datamasks, NULL); | BLI_linklist_free((LinkNode *)datamasks, nullptr); | ||||
| me = BKE_mesh_wrapper_from_editmesh_with_coords(em, &cd_mask_extra, NULL, me_input); | me = BKE_mesh_wrapper_from_editmesh_with_coords(em, &cd_mask_extra, nullptr, me_input); | ||||
| deformedVerts = editbmesh_vert_coords_alloc(em, &verts_num); | deformedVerts = editbmesh_vert_coords_alloc(em, &verts_num); | ||||
| defmats = MEM_mallocN(sizeof(*defmats) * verts_num, "defmats"); | defmats = static_cast<float(*)[3][3]>( | ||||
| MEM_mallocN(sizeof(*defmats) * verts_num, "defmats")); | |||||
| for (a = 0; a < verts_num; a++) { | for (a = 0; a < verts_num; a++) { | ||||
| unit_m3(defmats[a]); | unit_m3(defmats[a]); | ||||
| } | } | ||||
| } | } | ||||
| mti->deformMatricesEM(md, &mectx, em, me, deformedVerts, defmats, verts_num); | mti->deformMatricesEM(md, &mectx, em, me, deformedVerts, defmats, verts_num); | ||||
| } | } | ||||
| else { | else { | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| for (; md && i <= cageIndex; md = md->next, i++) { | for (; md && i <= cageIndex; md = md->next, i++) { | ||||
| if (editbmesh_modifier_is_enabled(scene, ob, md, me != NULL) && | if (editbmesh_modifier_is_enabled(scene, ob, md, me != nullptr) && | ||||
| BKE_modifier_is_correctable_deformed(md)) { | BKE_modifier_is_correctable_deformed(md)) { | ||||
| modifiers_left_num++; | modifiers_left_num++; | ||||
| } | } | ||||
| } | } | ||||
| if (me) { | if (me) { | ||||
| BKE_id_free(NULL, me); | BKE_id_free(nullptr, me); | ||||
| } | } | ||||
| *deformmats = defmats; | *deformmats = defmats; | ||||
| *deformcos = deformedVerts; | *deformcos = deformedVerts; | ||||
| return modifiers_left_num; | return modifiers_left_num; | ||||
| } | } | ||||
| /** | /** | ||||
| * Crazy-space evaluation needs to have an object which has all the fields | * Crazy-space evaluation needs to have an object which has all the fields | ||||
| * evaluated, but the mesh data being at undeformed state. This way it can | * evaluated, but the mesh data being at undeformed state. This way it can | ||||
| * re-apply modifiers and also have proper pointers to key data blocks. | * re-apply modifiers and also have proper pointers to key data blocks. | ||||
| * | * | ||||
| * Similar to #BKE_object_eval_reset(), but does not modify the actual evaluated object. | * Similar to #BKE_object_eval_reset(), but does not modify the actual evaluated object. | ||||
| */ | */ | ||||
| static void crazyspace_init_object_for_eval(struct Depsgraph *depsgraph, | static void crazyspace_init_object_for_eval(struct Depsgraph *depsgraph, | ||||
| Object *object, | Object *object, | ||||
| Object *object_crazy) | Object *object_crazy) | ||||
| { | { | ||||
| Object *object_eval = DEG_get_evaluated_object(depsgraph, object); | Object *object_eval = DEG_get_evaluated_object(depsgraph, object); | ||||
| *object_crazy = *object_eval; | *object_crazy = blender::dna::shallow_copy(*object_eval); | ||||
| if (object_crazy->runtime.data_orig != NULL) { | if (object_crazy->runtime.data_orig != nullptr) { | ||||
| object_crazy->data = object_crazy->runtime.data_orig; | object_crazy->data = object_crazy->runtime.data_orig; | ||||
| } | } | ||||
| } | } | ||||
| static void crazyspace_init_verts_and_matrices(const Mesh *mesh, | static void crazyspace_init_verts_and_matrices(const Mesh *mesh, | ||||
| float (**deformmats)[3][3], | float (**deformmats)[3][3], | ||||
| float (**deformcos)[3]) | float (**deformcos)[3]) | ||||
| { | { | ||||
| int verts_num; | int verts_num; | ||||
| *deformcos = BKE_mesh_vert_coords_alloc(mesh, &verts_num); | *deformcos = BKE_mesh_vert_coords_alloc(mesh, &verts_num); | ||||
| *deformmats = MEM_callocN(sizeof(**deformmats) * verts_num, "defmats"); | *deformmats = static_cast<float(*)[3][3]>( | ||||
| MEM_callocN(sizeof(**deformmats) * verts_num, "defmats")); | |||||
| for (int a = 0; a < verts_num; a++) { | for (int a = 0; a < verts_num; a++) { | ||||
| unit_m3((*deformmats)[a]); | unit_m3((*deformmats)[a]); | ||||
| } | } | ||||
| BLI_assert(verts_num == mesh->totvert); | BLI_assert(verts_num == mesh->totvert); | ||||
| } | } | ||||
| static bool crazyspace_modifier_supports_deform_matrices(ModifierData *md) | static bool crazyspace_modifier_supports_deform_matrices(ModifierData *md) | ||||
| { | { | ||||
| if (ELEM(md->type, eModifierType_Subsurf, eModifierType_Multires)) { | if (ELEM(md->type, eModifierType_Subsurf, eModifierType_Multires)) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type); | const ModifierTypeInfo *mti = BKE_modifier_get_info(static_cast<ModifierType>(md->type)); | ||||
| return (mti->type == eModifierTypeType_OnlyDeform); | return (mti->type == eModifierTypeType_OnlyDeform); | ||||
| } | } | ||||
| static bool crazyspace_modifier_supports_deform(ModifierData *md) | static bool crazyspace_modifier_supports_deform(ModifierData *md) | ||||
| { | { | ||||
| const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type); | const ModifierTypeInfo *mti = BKE_modifier_get_info(static_cast<ModifierType>(md->type)); | ||||
| return (mti->type == eModifierTypeType_OnlyDeform); | return (mti->type == eModifierTypeType_OnlyDeform); | ||||
| } | } | ||||
| int BKE_sculpt_get_first_deform_matrices(struct Depsgraph *depsgraph, | int BKE_sculpt_get_first_deform_matrices(struct Depsgraph *depsgraph, | ||||
| Scene *scene, | Scene *scene, | ||||
| Object *object, | Object *object, | ||||
| float (**deformmats)[3][3], | float (**deformmats)[3][3], | ||||
| float (**deformcos)[3]) | float (**deformcos)[3]) | ||||
| { | { | ||||
| ModifierData *md; | ModifierData *md; | ||||
| Mesh *me_eval = NULL; | Mesh *me_eval = nullptr; | ||||
| float(*defmats)[3][3] = NULL, (*deformedVerts)[3] = NULL; | float(*defmats)[3][3] = nullptr, (*deformedVerts)[3] = nullptr; | ||||
| int modifiers_left_num = 0; | int modifiers_left_num = 0; | ||||
| VirtualModifierData virtualModifierData; | VirtualModifierData virtualModifierData; | ||||
| Object object_eval; | Object object_eval; | ||||
| crazyspace_init_object_for_eval(depsgraph, object, &object_eval); | crazyspace_init_object_for_eval(depsgraph, object, &object_eval); | ||||
| MultiresModifierData *mmd = get_multires_modifier(scene, &object_eval, 0); | MultiresModifierData *mmd = get_multires_modifier(scene, &object_eval, 0); | ||||
| const bool is_sculpt_mode = (object->mode & OB_MODE_SCULPT) != 0; | const bool is_sculpt_mode = (object->mode & OB_MODE_SCULPT) != 0; | ||||
| const bool has_multires = mmd != NULL && mmd->sculptlvl > 0; | const bool has_multires = mmd != nullptr && mmd->sculptlvl > 0; | ||||
| const ModifierEvalContext mectx = {depsgraph, &object_eval, 0}; | const ModifierEvalContext mectx = {depsgraph, &object_eval, ModifierApplyFlag(0)}; | ||||
| if (is_sculpt_mode && has_multires) { | if (is_sculpt_mode && has_multires) { | ||||
| *deformmats = NULL; | *deformmats = nullptr; | ||||
| *deformcos = NULL; | *deformcos = nullptr; | ||||
| return modifiers_left_num; | return modifiers_left_num; | ||||
| } | } | ||||
| md = BKE_modifiers_get_virtual_modifierlist(&object_eval, &virtualModifierData); | md = BKE_modifiers_get_virtual_modifierlist(&object_eval, &virtualModifierData); | ||||
| for (; md; md = md->next) { | for (; md; md = md->next) { | ||||
| if (!BKE_modifier_is_enabled(scene, md, eModifierMode_Realtime)) { | if (!BKE_modifier_is_enabled(scene, md, eModifierMode_Realtime)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (crazyspace_modifier_supports_deform_matrices(md)) { | if (crazyspace_modifier_supports_deform_matrices(md)) { | ||||
| const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type); | const ModifierTypeInfo *mti = BKE_modifier_get_info(static_cast<ModifierType>(md->type)); | ||||
| if (defmats == NULL) { | if (defmats == nullptr) { | ||||
| /* NOTE: Evaluated object is re-set to its original un-deformed state. */ | /* NOTE: Evaluated object is re-set to its original un-deformed state. */ | ||||
| Mesh *me = object_eval.data; | Mesh *me = static_cast<Mesh *>(object_eval.data); | ||||
| me_eval = BKE_mesh_copy_for_eval(me, true); | me_eval = BKE_mesh_copy_for_eval(me, true); | ||||
| crazyspace_init_verts_and_matrices(me_eval, &defmats, &deformedVerts); | crazyspace_init_verts_and_matrices(me_eval, &defmats, &deformedVerts); | ||||
| } | } | ||||
| if (mti->deformMatrices) { | if (mti->deformMatrices) { | ||||
| mti->deformMatrices(md, &mectx, me_eval, deformedVerts, defmats, me_eval->totvert); | mti->deformMatrices(md, &mectx, me_eval, deformedVerts, defmats, me_eval->totvert); | ||||
| } | } | ||||
| else { | else { | ||||
| Show All 10 Lines | if (!BKE_modifier_is_enabled(scene, md, eModifierMode_Realtime)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (crazyspace_modifier_supports_deform(md)) { | if (crazyspace_modifier_supports_deform(md)) { | ||||
| modifiers_left_num++; | modifiers_left_num++; | ||||
| } | } | ||||
| } | } | ||||
| if (me_eval != NULL) { | if (me_eval != nullptr) { | ||||
| BKE_id_free(NULL, me_eval); | BKE_id_free(nullptr, me_eval); | ||||
| } | } | ||||
| *deformmats = defmats; | *deformmats = defmats; | ||||
| *deformcos = deformedVerts; | *deformcos = deformedVerts; | ||||
| return modifiers_left_num; | return modifiers_left_num; | ||||
| } | } | ||||
| void BKE_crazyspace_build_sculpt(struct Depsgraph *depsgraph, | void BKE_crazyspace_build_sculpt(struct Depsgraph *depsgraph, | ||||
| Scene *scene, | Scene *scene, | ||||
| Object *object, | Object *object, | ||||
| float (**deformmats)[3][3], | float (**deformmats)[3][3], | ||||
| float (**deformcos)[3]) | float (**deformcos)[3]) | ||||
| { | { | ||||
| int totleft = BKE_sculpt_get_first_deform_matrices( | int totleft = BKE_sculpt_get_first_deform_matrices( | ||||
| depsgraph, scene, object, deformmats, deformcos); | depsgraph, scene, object, deformmats, deformcos); | ||||
| if (totleft) { | if (totleft) { | ||||
| /* There are deformation modifier which doesn't support deformation matrices calculation. | /* There are deformation modifier which doesn't support deformation matrices calculation. | ||||
| * Need additional crazy-space correction. */ | * Need additional crazy-space correction. */ | ||||
| Mesh *mesh = (Mesh *)object->data; | Mesh *mesh = (Mesh *)object->data; | ||||
| Mesh *mesh_eval = NULL; | Mesh *mesh_eval = nullptr; | ||||
| if (*deformcos == NULL) { | if (*deformcos == nullptr) { | ||||
| crazyspace_init_verts_and_matrices(mesh, deformmats, deformcos); | crazyspace_init_verts_and_matrices(mesh, deformmats, deformcos); | ||||
| } | } | ||||
| float(*deformedVerts)[3] = *deformcos; | float(*deformedVerts)[3] = *deformcos; | ||||
| float(*origVerts)[3] = MEM_dupallocN(deformedVerts); | float(*origVerts)[3] = static_cast<float(*)[3]>(MEM_dupallocN(deformedVerts)); | ||||
| float(*quats)[4]; | float(*quats)[4]; | ||||
| int i, deformed = 0; | int i, deformed = 0; | ||||
| VirtualModifierData virtualModifierData; | VirtualModifierData virtualModifierData; | ||||
| Object object_eval; | Object object_eval; | ||||
| crazyspace_init_object_for_eval(depsgraph, object, &object_eval); | crazyspace_init_object_for_eval(depsgraph, object, &object_eval); | ||||
| ModifierData *md = BKE_modifiers_get_virtual_modifierlist(&object_eval, &virtualModifierData); | ModifierData *md = BKE_modifiers_get_virtual_modifierlist(&object_eval, &virtualModifierData); | ||||
| const ModifierEvalContext mectx = {depsgraph, &object_eval, 0}; | const ModifierEvalContext mectx = {depsgraph, &object_eval, ModifierApplyFlag(0)}; | ||||
| for (; md; md = md->next) { | for (; md; md = md->next) { | ||||
| if (!BKE_modifier_is_enabled(scene, md, eModifierMode_Realtime)) { | if (!BKE_modifier_is_enabled(scene, md, eModifierMode_Realtime)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (crazyspace_modifier_supports_deform(md)) { | if (crazyspace_modifier_supports_deform(md)) { | ||||
| const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type); | const ModifierTypeInfo *mti = BKE_modifier_get_info(static_cast<ModifierType>(md->type)); | ||||
| /* skip leading modifiers which have been already | /* skip leading modifiers which have been already | ||||
| * handled in sculpt_get_first_deform_matrices */ | * handled in sculpt_get_first_deform_matrices */ | ||||
| if (mti->deformMatrices && !deformed) { | if (mti->deformMatrices && !deformed) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (mesh_eval == NULL) { | if (mesh_eval == nullptr) { | ||||
| mesh_eval = BKE_mesh_copy_for_eval(mesh, true); | mesh_eval = BKE_mesh_copy_for_eval(mesh, true); | ||||
| } | } | ||||
| mti->deformVerts(md, &mectx, mesh_eval, deformedVerts, mesh_eval->totvert); | mti->deformVerts(md, &mectx, mesh_eval, deformedVerts, mesh_eval->totvert); | ||||
| deformed = 1; | deformed = 1; | ||||
| } | } | ||||
| } | } | ||||
| quats = MEM_mallocN(mesh->totvert * sizeof(*quats), "crazy quats"); | quats = static_cast<float(*)[4]>(MEM_mallocN(mesh->totvert * sizeof(*quats), "crazy quats")); | ||||
| BKE_crazyspace_set_quats_mesh(mesh, origVerts, deformedVerts, quats); | BKE_crazyspace_set_quats_mesh(mesh, origVerts, deformedVerts, quats); | ||||
| for (i = 0; i < mesh->totvert; i++) { | for (i = 0; i < mesh->totvert; i++) { | ||||
| float qmat[3][3], tmat[3][3]; | float qmat[3][3], tmat[3][3]; | ||||
| quat_to_mat3(qmat, quats[i]); | quat_to_mat3(qmat, quats[i]); | ||||
| mul_m3_m3m3(tmat, qmat, (*deformmats)[i]); | mul_m3_m3m3(tmat, qmat, (*deformmats)[i]); | ||||
| copy_m3_m3((*deformmats)[i], tmat); | copy_m3_m3((*deformmats)[i], tmat); | ||||
| } | } | ||||
| MEM_freeN(origVerts); | MEM_freeN(origVerts); | ||||
| MEM_freeN(quats); | MEM_freeN(quats); | ||||
| if (mesh_eval != NULL) { | if (mesh_eval != nullptr) { | ||||
| BKE_id_free(NULL, mesh_eval); | BKE_id_free(nullptr, mesh_eval); | ||||
| } | } | ||||
| } | } | ||||
| if (*deformmats == NULL) { | if (*deformmats == nullptr) { | ||||
| int a, verts_num; | int a, verts_num; | ||||
| Mesh *mesh = (Mesh *)object->data; | Mesh *mesh = (Mesh *)object->data; | ||||
| *deformcos = BKE_mesh_vert_coords_alloc(mesh, &verts_num); | *deformcos = BKE_mesh_vert_coords_alloc(mesh, &verts_num); | ||||
| *deformmats = MEM_callocN(sizeof(*(*deformmats)) * verts_num, "defmats"); | *deformmats = static_cast<float(*)[3][3]>( | ||||
| MEM_callocN(sizeof(*(*deformmats)) * verts_num, "defmats")); | |||||
| for (a = 0; a < verts_num; a++) { | for (a = 0; a < verts_num; a++) { | ||||
| unit_m3((*deformmats)[a]); | unit_m3((*deformmats)[a]); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Crazyspace API | /** \name Crazyspace API | ||||
| * \{ */ | * \{ */ | ||||
| void BKE_crazyspace_api_eval(Depsgraph *depsgraph, | void BKE_crazyspace_api_eval(Depsgraph *depsgraph, | ||||
| Scene *scene, | Scene *scene, | ||||
| Object *object, | Object *object, | ||||
| struct ReportList *reports) | struct ReportList *reports) | ||||
| { | { | ||||
| if (object->runtime.crazyspace_deform_imats != NULL || | if (object->runtime.crazyspace_deform_imats != nullptr || | ||||
| object->runtime.crazyspace_deform_cos != NULL) { | object->runtime.crazyspace_deform_cos != nullptr) { | ||||
| return; | return; | ||||
| } | } | ||||
| if (object->type != OB_MESH) { | if (object->type != OB_MESH) { | ||||
| BKE_report(reports, | BKE_report(reports, | ||||
| RPT_ERROR, | RPT_ERROR, | ||||
| "Crazyspace transformation is only available for Mesh type of objects"); | "Crazyspace transformation is only available for Mesh type of objects"); | ||||
| return; | return; | ||||
| ▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines | |||||