00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef __SIM_SolverPop_h__
00015 #define __SIM_SolverPop_h__
00016
00017 #include "SIMZ_API.h"
00018 #include <SIM/SIM_OptionsUser.h>
00019 #include <SIM/SIM_SingleSolver.h>
00020 #include <POPNET/POPNET_Node.h>
00021 #include "SIMZ_Utils.h"
00022
00023 class GU_Detail;
00024 class SIM_Impacts;
00025 class SIM_DataFilter;
00026 class SIM_PopGeometry;
00027 class POP_ContextData;
00028
00029 #define SIM_NAME_INITIALSTATE PN_INITIALSTATE
00030 #define SIM_NAME_RANDOMSEED PN_RANDOMSEED
00031 #define SIM_NAME_OVERSAMPLE PN_OVERSAMPLE
00032 #define SIM_NAME_MAXPARTICLES PN_MAXPARTICLES
00033 #define SIM_NAME_REMOVEUNUSED PN_REMOVEUNUSED
00034 #define SIM_NAME_PATH1 PN_PATH1
00035 #define SIM_NAME_PATH2 PN_PATH2
00036 #define SIM_NAME_PATH3 PN_PATH3
00037 #define SIM_NAME_PATH4 PN_PATH4
00038
00039 #define SIM_NAME_COLLIDESTOP "collidestop"
00040 #define SIM_NAME_COLLIDEKILL "collidekill"
00041 #define SIM_NAME_COLLIDECONTINUE "collidecontinue"
00042 #define SIM_NAME_COLLIDESTICK "collidestick"
00043 #define SIM_NAME_COLLIDEBOUNCE "collidebounce"
00044
00045
00046 class SIMZ_API SIM_SolverPop : public SIM_SingleSolver,
00047 public SIM_OptionsUser
00048 {
00049 public:
00050
00051 GETSET_DATA_FUNCS_S(SIM_NAME_POPPATH, PopPath);
00052 GETSET_DATA_FUNCS_B(SIM_NAME_MAKEPOINTSPARTICLES, MakePointsParticles);
00053 GETSET_DATA_FUNCS_B(SIM_NAME_INHERITVELOCITY, InheritVelocity);
00054 GETSET_DATA_FUNCS_S(SIM_NAME_GENERATOR, Generator);
00055 GETSET_DATA_FUNCS_F(SIM_NAME_LIFESPAN, Lifespan);
00056 GETSET_DATA_FUNCS_S(SIM_NAME_COLLIDESTOP, CollideStop);
00057 GETSET_DATA_FUNCS_S(SIM_NAME_COLLIDEKILL, CollideKill);
00058 GETSET_DATA_FUNCS_S(SIM_NAME_COLLIDECONTINUE, CollideContinue);
00059 GETSET_DATA_FUNCS_S(SIM_NAME_COLLIDESTICK, CollideStick);
00060 GETSET_DATA_FUNCS_S(SIM_NAME_COLLIDEBOUNCE, CollideBounce);
00061
00062
00063 GETSET_DATA_FUNCS_S(SIM_NAME_INITIALSTATE, InitialState);
00064 GETSET_DATA_FUNCS_I(SIM_NAME_RANDOMSEED, RandomSeed);
00065 GETSET_DATA_FUNCS_I(SIM_NAME_OVERSAMPLE, OverSample);
00066 GETSET_DATA_FUNCS_I(SIM_NAME_MAXPARTICLES, MaxParticles);
00067 GETSET_DATA_FUNCS_B(SIM_NAME_REMOVEUNUSED, RemoveUnused);
00068 GETSET_DATA_FUNCS_S(SIM_NAME_PATH1, Path1);
00069 GETSET_DATA_FUNCS_S(SIM_NAME_PATH2, Path2);
00070 GETSET_DATA_FUNCS_S(SIM_NAME_PATH3, Path3);
00071 GETSET_DATA_FUNCS_S(SIM_NAME_PATH4, Path4);
00072
00073
00074 GET_DATA_FUNC_S("geo", GeometryName);
00075 GET_DATA_FUNC_B("doreapparticles", DoReapParticles);
00076 GET_DATA_FUNC_B("doapplyrules", DoApplyRules);
00077 GET_DATA_FUNC_B("suppresspos", SuppressPos);
00078 GET_DATA_FUNC_B("suppressvel", SuppressVel);
00079 GET_DATA_FUNC_B("suppressup", SuppressUp);
00080 GET_DATA_FUNC_B("suppressage", SuppressAge);
00081 GET_DATA_FUNC_B("suppressrot", SuppressRot);
00082 GET_DATA_FUNC_B("suppressangvel", SuppressAngVel);
00083 GET_DATA_FUNC_B("doprepparticles", DoPrepParticles);
00084 GET_DATA_FUNC_B("docookpop", DoCookPOP);
00085 GET_DATA_FUNC_B("docookfirst", DoCookFirst);
00086 GET_DATA_FUNC_B("doimpacts", DoImpacts);
00087 GET_DATA_FUNC_B("dodopforces", DoDopForces);
00088
00089 protected:
00090 explicit SIM_SolverPop(const SIM_DataFactory *factory);
00091 virtual ~SIM_SolverPop();
00092
00093 virtual SIM_Result solveSingleObjectSubclass(SIM_Engine &engine,
00094 SIM_Object &object,
00095 SIM_ObjectArray &feedbacktoobjects,
00096 const SIM_Time ×tep,
00097 bool newobject);
00098 virtual int getRequestedCacheSubclass();
00099 virtual void getImpulseMassMatrixSubclass(
00100 const SIM_Object &object,
00101 const UT_Vector3 &impulseworldpos,
00102 UT_DMatrix3 &immatrix) const;
00103 virtual void getPointImpulseMassMatrixSubclass(
00104 const SIM_Object &object,
00105 int ptnum, UT_DMatrix3 &immatrix) const;
00106 virtual void getDefaultColliderLabelSubclass(
00107 const SIM_Object &object,
00108 UT_String &label) const;
00109 virtual void getDefaultColliderSubclass(
00110 const SIM_Object &object,
00111 const UT_String &colliderlabel,
00112 UT_String &collidertype,
00113 bool &colliderreverseobjectroles) const;
00114
00115 private:
00116 SIM_PopGeometry *getGeometry(SIM_Object &obj);
00117 static const SIM_DopDescription *getSolverPopDopDescription();
00118
00119 void applySoftConstraintForces(SIM_Object &object,
00120 POP_ContextData &contextdata) const;
00121 void applyHardConstraintPositions(SIM_Object &object,
00122 POP_ContextData &contextdata,
00123 const UT_DMatrix4 &ixform) const;
00124 void applyShapeMatchForces(SIM_Object &object,
00125 POP_ContextData &contextdata,
00126 SIM_Time timeinc) const;
00127
00128 void respondToCollision(SIM_Engine &engine,
00129 SIM_Object &object,
00130 SIM_PopGeometry &popgeo,
00131 const SIM_ObjectArray &affectors,
00132 const UT_DMatrix4 &xform,
00133 const UT_DMatrix4 &ixform,
00134 const SIM_Impacts *impacts,
00135 int impactidx,
00136 int impactflags,
00137 int ptnum,
00138 bool hasidattribute) const;
00139 bool respondToCollisions(SIM_Engine &engine,
00140 SIM_Object &object,
00141 SIM_PopGeometry &popgeo,
00142 const SIM_ObjectArray &affectors,
00143 const UT_DMatrix4 &xform,
00144 const UT_DMatrix4 &ixform,
00145 const UT_DMatrix4 &posixform,
00146 const char *impactdataname,
00147 const SIM_DataFilter &fstop,
00148 const SIM_DataFilter &fkill,
00149 const SIM_DataFilter &fcont,
00150 const SIM_DataFilter &fstick,
00151 const SIM_DataFilter &fbounce,
00152 bool doinglastpopsubstep,
00153 bool checkforduplicates) const;
00154
00155
00156
00157 void createRequiredAttributes(GU_Detail *gdp) const;
00158
00159
00160
00161 void makePointsParticles(GU_Detail *gdp,
00162 const char *generator,
00163 fpreal lifespan) const;
00164
00165
00166
00167
00168
00169 void combineParticlePrimitives(GU_Detail &gdp);
00170
00171
00172
00173 void changeParticleStateFromImpacts(
00174 POP_ContextData &contextdata,
00175 const SIM_Impacts *impacts,
00176 int impactidx,
00177 int statechange,
00178 int ptnum) const;
00179 void createConstraintsFromImpacts(
00180 SIM_Engine &engine,
00181 SIM_Object &object,
00182 const SIM_ObjectArray &affectors,
00183 const SIM_Impacts *impacts,
00184 int impactidx,
00185 int ptnum,
00186 bool hasidattribute) const;
00187 void bounceParticlesFromImpacts(
00188 POP_ContextData &contextdata,
00189 const UT_DMatrix4 &xform,
00190 const UT_DMatrix4 &ixform,
00191 const SIM_Impacts *impacts,
00192 int impactidx,
00193 int ptnum) const;
00194
00195 DECLARE_STANDARD_GETCASTTOTYPE();
00196 DECLARE_DATAFACTORY(SIM_SolverPop,
00197 SIM_SingleSolver,
00198 "POP Solver",
00199 getSolverPopDopDescription());
00200 };
00201
00202 #endif
00203