Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenloader/intern/writefile.c
| Context not available. | |||||
| #include "DNA_group_types.h" | #include "DNA_group_types.h" | ||||
| #include "DNA_gpencil_types.h" | #include "DNA_gpencil_types.h" | ||||
| #include "DNA_fileglobal_types.h" | #include "DNA_fileglobal_types.h" | ||||
| #include "DNA_fracture_types.h" | |||||
| #include "DNA_key_types.h" | #include "DNA_key_types.h" | ||||
| #include "DNA_lattice_types.h" | #include "DNA_lattice_types.h" | ||||
| #include "DNA_lamp_types.h" | #include "DNA_lamp_types.h" | ||||
| Context not available. | |||||
| #include "BKE_bpath.h" | #include "BKE_bpath.h" | ||||
| #include "BKE_curve.h" | #include "BKE_curve.h" | ||||
| #include "BKE_constraint.h" | #include "BKE_constraint.h" | ||||
| #include "BKE_fracture.h" // for writing a derivedmesh as shard | |||||
| #include "BKE_global.h" // for G | #include "BKE_global.h" // for G | ||||
| #include "BKE_library.h" // for set_listbasepointers | #include "BKE_library.h" // for set_listbasepointers | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| Context not available. | |||||
| writestruct(wd, DATA, "bDeformGroup", 1, defgroup); | writestruct(wd, DATA, "bDeformGroup", 1, defgroup); | ||||
| } | } | ||||
| /* need a prototype of that here...*/ | |||||
| static void write_customdata(WriteData *wd, ID *id, int count, CustomData *data, int partial_type, int partial_count); | |||||
| static void write_shard(WriteData* wd, Shard* s) | |||||
| { | |||||
| writestruct(wd, DATA, "Shard", 1, s); | |||||
| writestruct(wd, DATA, "MVert", s->totvert, s->mvert); | |||||
| writestruct(wd, DATA, "MPoly", s->totpoly, s->mpoly); | |||||
| writestruct(wd, DATA, "MLoop", s->totloop, s->mloop); | |||||
| write_customdata(wd, NULL, s->totvert, &s->vertData, -1, s->totvert); | |||||
| write_customdata(wd, NULL, s->totloop, &s->loopData, -1, s->totloop); | |||||
| write_customdata(wd, NULL, s->totpoly, &s->polyData, -1, s->totpoly); | |||||
| writedata(wd, DATA, sizeof(int)*s->neighbor_count, s->neighbor_ids); | |||||
| writedata(wd, DATA, sizeof(int), s->cluster_colors); | |||||
| } | |||||
| static void write_meshIsland(WriteData* wd, MeshIsland* mi) | |||||
| { | |||||
| DerivedMesh *dm = mi->physics_mesh; | |||||
| mi->temp = BKE_create_fracture_shard(dm->getVertArray(dm), dm->getPolyArray(dm), dm->getLoopArray(dm), | |||||
| dm->getNumVerts(dm), dm->getNumPolys(dm), dm->getNumLoops(dm), true); | |||||
| mi->temp = BKE_custom_data_to_shard(mi->temp, dm); | |||||
| writestruct(wd, DATA, "MeshIsland", 1, mi); | |||||
| writedata(wd, DATA, sizeof(struct BMVert*) * mi->vertex_count, mi->vertices); | |||||
| writedata(wd, DATA, sizeof(MVert*) * mi->vertex_count, mi->vertices_cached); | |||||
| writedata(wd, DATA, sizeof(float) * 3 * mi->vertex_count, mi->vertco); | |||||
| /* write derivedmesh as shard... */ | |||||
| mi->temp->next = NULL; | |||||
| mi->temp->prev = NULL; | |||||
| write_shard(wd, mi->temp); | |||||
| BKE_shard_free(mi->temp, true); | |||||
| mi->temp = NULL; | |||||
| writedata(wd, DATA, sizeof(short) * 3 * mi->vertex_count, mi->vertno); | |||||
| writestruct(wd, DATA, "RigidBodyOb", 1, mi->rigidbody); | |||||
| writedata(wd, DATA, sizeof(int) * mi->neighbor_count, mi->neighbor_ids); | |||||
| writestruct(wd, DATA, "BoundBox", 1, mi->bb); | |||||
| writedata(wd, DATA, sizeof(int) * mi->vertex_count, mi->vertex_indices); | |||||
| } | |||||
| static void write_modifiers(WriteData *wd, ListBase *modbase) | static void write_modifiers(WriteData *wd, ListBase *modbase) | ||||
| { | { | ||||
| ModifierData *md; | ModifierData *md; | ||||
| Context not available. | |||||
| if (modbase == NULL) return; | if (modbase == NULL) return; | ||||
| for (md=modbase->first; md; md= md->next) { | for (md=modbase->first; md; md= md->next) { | ||||
| ModifierTypeInfo *mti = modifierType_getInfo(md->type); | ModifierTypeInfo *mti = modifierType_getInfo(md->type); | ||||
| //printf("Saving %s\n", mti->structName); | |||||
| if (mti == NULL) return; | if (mti == NULL) return; | ||||
| writestruct(wd, DATA, mti->structName, 1, md); | writestruct(wd, DATA, mti->structName, 1, md); | ||||
| if (md->type==eModifierType_Hook) { | if (md->type==eModifierType_Hook) { | ||||
| HookModifierData *hmd = (HookModifierData*) md; | HookModifierData *hmd = (HookModifierData*) md; | ||||
| Context not available. | |||||
| if (wmd->cmap_curve) | if (wmd->cmap_curve) | ||||
| write_curvemapping(wd, wmd->cmap_curve); | write_curvemapping(wd, wmd->cmap_curve); | ||||
| } | } | ||||
| else if (md->type==eModifierType_LaplacianDeform) { | else if (md->type==eModifierType_LaplacianDeform) { | ||||
| LaplacianDeformModifierData *lmd = (LaplacianDeformModifierData*) md; | LaplacianDeformModifierData *lmd = (LaplacianDeformModifierData*) md; | ||||
| writedata(wd, DATA, sizeof(float)*lmd->total_verts * 3, lmd->vertexco); | writedata(wd, DATA, sizeof(float)*lmd->total_verts * 3, lmd->vertexco); | ||||
| } | } | ||||
| else if (md->type==eModifierType_Fracture) { | |||||
| int i = 0; | |||||
| FractureModifierData *fmd = (FractureModifierData*)md; | |||||
| FracMesh* fm = fmd->frac_mesh; | |||||
| if (fm) | |||||
| { | |||||
| MeshIsland *mi; | |||||
| Shard *s; | |||||
| if (fm->running == 0) | |||||
| { | |||||
| writestruct(wd, DATA, "FracMesh", 1, fm); | |||||
| writedata(wd, DATA, sizeof(Shard*) * fm->shard_count, fm->shard_map); | |||||
| for (i = 0; i < fm->shard_count; i++) { | |||||
| Shard *s = fm->shard_map[i]; | |||||
| /* next, prev not necessary in this case, because we use an array here */ | |||||
| s->next = NULL; | |||||
| s->prev = NULL; | |||||
| write_shard(wd, s); | |||||
| } | |||||
| for (s = fmd->islandShards.first; s; s = s->next) { | |||||
| write_shard(wd, s); | |||||
| } | |||||
| for (mi = fmd->meshIslands.first; mi; mi = mi->next) { | |||||
| write_meshIsland(wd, mi); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||