|
Blender
V2.59
|
00001 /* 00002 * $Id: MOD_fluidsim.c 35362 2011-03-05 10:29:10Z campbellbarton $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 * 00020 * The Original Code is Copyright (C) 2005 by the Blender Foundation. 00021 * All rights reserved. 00022 * 00023 * Contributor(s): Daniel Dunbar 00024 * Ton Roosendaal, 00025 * Ben Batt, 00026 * Brecht Van Lommel, 00027 * Campbell Barton 00028 * 00029 * ***** END GPL LICENSE BLOCK ***** 00030 * 00031 */ 00032 00038 #include "DNA_scene_types.h" 00039 #include "DNA_object_fluidsim.h" 00040 #include "DNA_object_types.h" 00041 00042 #include "BLI_utildefines.h" 00043 00044 00045 #include "BKE_cdderivedmesh.h" 00046 #include "BKE_modifier.h" 00047 00048 #include "depsgraph_private.h" 00049 00050 #include "MOD_util.h" 00051 #include "MOD_fluidsim_util.h" 00052 #include "MEM_guardedalloc.h" 00053 00054 /* Fluidsim */ 00055 static void initData(ModifierData *md) 00056 { 00057 FluidsimModifierData *fluidmd= (FluidsimModifierData*) md; 00058 00059 fluidsim_init(fluidmd); 00060 } 00061 static void freeData(ModifierData *md) 00062 { 00063 FluidsimModifierData *fluidmd= (FluidsimModifierData*) md; 00064 00065 fluidsim_free(fluidmd); 00066 } 00067 00068 static void copyData(ModifierData *md, ModifierData *target) 00069 { 00070 FluidsimModifierData *fluidmd= (FluidsimModifierData*) md; 00071 FluidsimModifierData *tfluidmd= (FluidsimModifierData*) target; 00072 00073 if(tfluidmd->fss) 00074 MEM_freeN(tfluidmd->fss); 00075 00076 tfluidmd->fss = MEM_dupallocN(fluidmd->fss); 00077 } 00078 00079 00080 00081 static DerivedMesh *applyModifier(ModifierData *md, Object *ob, 00082 DerivedMesh *dm, 00083 int useRenderParams, 00084 int isFinalCalc) 00085 { 00086 FluidsimModifierData *fluidmd= (FluidsimModifierData*) md; 00087 DerivedMesh *result = NULL; 00088 00089 /* check for alloc failing */ 00090 if(!fluidmd->fss) 00091 { 00092 initData(md); 00093 00094 if(!fluidmd->fss) 00095 return dm; 00096 } 00097 00098 result= fluidsimModifier_do(fluidmd, md->scene, ob, dm, useRenderParams, isFinalCalc); 00099 00100 return result ? result : dm; 00101 } 00102 00103 static void updateDepgraph( 00104 ModifierData *md, DagForest *forest, Scene *scene, 00105 Object *ob, DagNode *obNode) 00106 { 00107 FluidsimModifierData *fluidmd= (FluidsimModifierData*) md; 00108 Base *base; 00109 00110 if(fluidmd && fluidmd->fss) 00111 { 00112 if(fluidmd->fss->type == OB_FLUIDSIM_DOMAIN) 00113 { 00114 for(base = scene->base.first; base; base= base->next) 00115 { 00116 Object *ob1= base->object; 00117 if(ob1 != ob) 00118 { 00119 FluidsimModifierData *fluidmdtmp = (FluidsimModifierData *)modifiers_findByType(ob1, eModifierType_Fluidsim); 00120 00121 // only put dependancies from NON-DOMAIN fluids in here 00122 if(fluidmdtmp && fluidmdtmp->fss && (fluidmdtmp->fss->type!=OB_FLUIDSIM_DOMAIN)) 00123 { 00124 DagNode *curNode = dag_get_node(forest, ob1); 00125 dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Fluidsim Object"); 00126 } 00127 } 00128 } 00129 } 00130 } 00131 } 00132 00133 static int dependsOnTime(ModifierData *UNUSED(md)) 00134 { 00135 return 1; 00136 } 00137 00138 00139 ModifierTypeInfo modifierType_Fluidsim = { 00140 /* name */ "Fluidsim", 00141 /* structName */ "FluidsimModifierData", 00142 /* structSize */ sizeof(FluidsimModifierData), 00143 /* type */ eModifierTypeType_Nonconstructive, 00144 00145 /* flags */ eModifierTypeFlag_AcceptsMesh 00146 | eModifierTypeFlag_RequiresOriginalData 00147 | eModifierTypeFlag_Single, 00148 00149 /* copyData */ copyData, 00150 /* deformVerts */ NULL, 00151 /* deformMatrices */ NULL, 00152 /* deformVertsEM */ NULL, 00153 /* deformMatricesEM */ NULL, 00154 /* applyModifier */ applyModifier, 00155 /* applyModifierEM */ NULL, 00156 /* initData */ initData, 00157 /* requiredDataMask */ NULL, 00158 /* freeData */ freeData, 00159 /* isDisabled */ NULL, 00160 /* updateDepgraph */ updateDepgraph, 00161 /* dependsOnTime */ dependsOnTime, 00162 /* dependsOnNormals */ NULL, 00163 /* foreachObjectLink */ NULL, 00164 /* foreachIDLink */ NULL, 00165 };