Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/lattice_deform.c
| Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | |||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "BKE_curve.h" | #include "BKE_curve.h" | ||||
| #include "BKE_displist.h" | #include "BKE_displist.h" | ||||
| #include "BKE_editmesh.h" | #include "BKE_editmesh.h" | ||||
| #include "BKE_key.h" | #include "BKE_key.h" | ||||
| #include "BKE_lattice.h" | #include "BKE_lattice.h" | ||||
| #include "BKE_modifier.h" | #include "BKE_modifier.h" | ||||
| #include "BKE_object.h" | |||||
| #include "BKE_deform.h" | #include "BKE_deform.h" | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Lattice Deform API | /** \name Lattice Deform API | ||||
| * \{ */ | * \{ */ | ||||
| typedef struct LatticeDeformData { | typedef struct LatticeDeformData { | ||||
| /* Convert from object space to deform space */ | /* Convert from object space to deform space */ | ||||
| float latmat[4][4]; | float latmat[4][4]; | ||||
| /* Cached reference to the lattice to use for evaluation. When in edit mode this attribute | /* Cached reference to the lattice to use for evaluation. When in edit mode this attribute | ||||
| * is set to the edit mode lattice. */ | * is set to the edit mode lattice. */ | ||||
| const Lattice *lt; | const Lattice *lt; | ||||
| /* Preprocessed lattice points (converted to deform space). */ | /* Preprocessed lattice points (converted to deform space). */ | ||||
| float *latticedata; | float *latticedata; | ||||
| /* Prefetched DeformWeights of the lattice. */ | /* Prefetched DeformWeights of the lattice. */ | ||||
| float *lattice_weights; | float *lattice_weights; | ||||
| } LatticeDeformData; | } LatticeDeformData; | ||||
| LatticeDeformData *BKE_lattice_deform_data_create(const Object *oblatt, const Object *ob) | LatticeDeformData *BKE_lattice_deform_data_create(const Object *oblatt, const Object *ob) | ||||
| { | { | ||||
| /* we make an array with all differences */ | /* we make an array with all differences */ | ||||
| Lattice *lt = oblatt->data; | Lattice *lt = BKE_object_get_lattice(oblatt); | ||||
| BPoint *bp; | BPoint *bp; | ||||
| DispList *dl = oblatt->runtime.curve_cache ? | DispList *dl = oblatt->runtime.curve_cache ? | ||||
| BKE_displist_find(&oblatt->runtime.curve_cache->disp, DL_VERTS) : | BKE_displist_find(&oblatt->runtime.curve_cache->disp, DL_VERTS) : | ||||
| NULL; | NULL; | ||||
| const float *co = dl ? dl->verts : NULL; | const float *co = dl ? dl->verts : NULL; | ||||
| float *fp, imat[4][4]; | float *fp, imat[4][4]; | ||||
| float fu, fv, fw; | float fu, fv, fw; | ||||
| int u, v, w; | int u, v, w; | ||||
| float *latticedata; | float *latticedata; | ||||
| float *lattice_weights = NULL; | float *lattice_weights = NULL; | ||||
| float latmat[4][4]; | float latmat[4][4]; | ||||
| LatticeDeformData *lattice_deform_data; | LatticeDeformData *lattice_deform_data; | ||||
| if (lt->editlatt) { | |||||
| lt = lt->editlatt->latt; | |||||
| } | |||||
| bp = lt->def; | bp = lt->def; | ||||
| const int32_t num_points = lt->pntsu * lt->pntsv * lt->pntsw; | const int32_t num_points = lt->pntsu * lt->pntsv * lt->pntsw; | ||||
| /* We allocate one additional float for SSE2 optimizations. Without this | /* We allocate one additional float for SSE2 optimizations. Without this | ||||
| * the SSE2 instructions for the last item would read in unallocated memory. */ | * the SSE2 instructions for the last item would read in unallocated memory. */ | ||||
| fp = latticedata = MEM_mallocN(sizeof(float[3]) * num_points + sizeof(float), "latticedata"); | fp = latticedata = MEM_mallocN(sizeof(float[3]) * num_points + sizeof(float), "latticedata"); | ||||
| /* for example with a particle system: (ob == NULL) */ | /* for example with a particle system: (ob == NULL) */ | ||||
| ▲ Show 20 Lines • Show All 376 Lines • Show Last 20 Lines | |||||