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