WIP commit to introduce channels

This commit is contained in:
Daniel Genrich 2008-07-07 14:36:33 +00:00
parent d3745d70a5
commit e409c2463d
11 changed files with 146 additions and 62 deletions

@ -163,11 +163,14 @@ typedef struct elbeemMesh {
float cpsTimeStart;
float cpsTimeEnd;
// TODO dg: change to channels
float attractforceStrength;
float attractforceRadius;
float velocityforceStrength;
float velocityforceRadius;
int channelSizeAttractforceStrength;
float *channelAttractforceStrength;
int channelSizeAttractforceRadius;
float *channelAttractforceRadius;
int channelSizeVelocityforceStrength;
float *channelVelocityforceStrength;
int channelSizeVelocityforceRadius;
float *channelVelocityforceRadius;
} elbeemMesh;
// API functions

@ -164,10 +164,14 @@ void elbeemResetMesh(elbeemMesh *mesh) {
mesh->cpsTimeStart = 0;
mesh->cpsTimeEnd = 0;
mesh->attractforceStrength = 0;
mesh->attractforceRadius = 0;
mesh->velocityforceStrength = 0;
mesh->velocityforceRadius = 0;
mesh->channelSizeAttractforceStrength = 0;
mesh->channelAttractforceStrength = NULL;
mesh->channelSizeAttractforceRadius = 0;
mesh->channelAttractforceRadius = NULL;
mesh->channelSizeVelocityforceStrength = 0;
mesh->channelVelocityforceStrength = NULL;
mesh->channelSizeVelocityforceRadius = 0;
mesh->channelVelocityforceRadius = NULL;
}
int globalMeshCounter = 1;
@ -211,10 +215,6 @@ int elbeemAddMesh(elbeemMesh *mesh) {
/* fluid control features */
obj->setCpsTimeStart(mesh->cpsTimeStart);
obj->setCpsTimeEnd(mesh->cpsTimeEnd);
obj->setAttractForceStrength(mesh->attractforceStrength);
obj->setAttractForceRadius(mesh->attractforceRadius);
obj->setVelocityForceStrength(mesh->velocityforceStrength);
obj->setVelocityForceRadius(mesh->velocityforceRadius);
if((mesh->volumeInitType<VOLUMEINIT_VOLUME)||(mesh->volumeInitType>VOLUMEINIT_BOTH)) mesh->volumeInitType = VOLUMEINIT_VOLUME;
obj->setVolumeInit(mesh->volumeInitType);
@ -224,7 +224,11 @@ int elbeemAddMesh(elbeemMesh *mesh) {
mesh->channelSizeRotation, mesh->channelRotation,
mesh->channelSizeScale, mesh->channelScale,
mesh->channelSizeActive, mesh->channelActive,
mesh->channelSizeInitialVel, mesh->channelInitialVel
mesh->channelSizeInitialVel, mesh->channelInitialVel,
mesh->channelSizeAttractforceStrength, mesh->channelAttractforceStrength,
mesh->channelSizeAttractforceRadius, mesh->channelAttractforceRadius,
mesh->channelSizeVelocityforceStrength, mesh->channelVelocityforceStrength,
mesh->channelSizeVelocityforceRadius, mesh->channelVelocityforceRadius
);
obj->setLocalCoordInivel( mesh->localInivelCoords );

@ -41,7 +41,8 @@ ntlGeometryObject::ntlGeometryObject() :
mCachedMovPoints(), mCachedMovNormals(),
mTriangleDivs1(), mTriangleDivs2(), mTriangleDivs3(),
mMovPntsInited(-100.0), mMaxMovPnt(-1),
mcGeoActive(1.)
mcGeoActive(1.),
mcAttrFStr(0.),mcAttrFRad(0.), mcVelFStr(0.), mcVelFRad(0.)
{
};
@ -331,7 +332,11 @@ void ntlGeometryObject::sceneAddTriangleNoVert(int *trips,
void ntlGeometryObject::initChannels(
int nTrans, float *trans, int nRot, float *rot, int nScale, float *scale,
int nAct, float *act, int nIvel, float *ivel
int nAct, float *act, int nIvel, float *ivel,
int nAttrFStr, float *attrFStr,
int nAttrFRad, float *attrFRad,
int nVelFStr, float *velFStr,
int nVelFRad, float *velFRad
) {
const bool debugInitc=true;
if(debugInitc) { debMsgStd("ntlGeometryObject::initChannels",DM_MSG,"nt:"<<nTrans<<" nr:"<<nRot<<" ns:"<<nScale, 10);
@ -345,6 +350,12 @@ void ntlGeometryObject::initChannels(
if((act)&&(nAct>0)) { ADD_CHANNEL_FLOAT(mcGeoActive, nAct, act); }
if((ivel)&&(nIvel>0)) { ADD_CHANNEL_VEC(mcInitialVelocity, nIvel, ivel); }
/* fluid control channels */
if((attrFStr)&&(nAttrFStr>0)) { printf("added!\n"); ADD_CHANNEL_FLOAT(mcAttrFStr, nAttrFStr, attrFStr); }
if((attrFRad)&&(nAttrFRad>0)) { ADD_CHANNEL_FLOAT(mcAttrFRad, nAttrFRad, attrFRad); }
if((velFStr)&&(nVelFStr>0)) { ADD_CHANNEL_FLOAT(mcVelFStr, nAct, velFStr); }
if((velFRad)&&(nVelFRad>0)) { ADD_CHANNEL_FLOAT(mcVelFRad, nVelFRad, velFRad); }
checkIsAnimated();
if(debugInitc) {
@ -567,7 +578,7 @@ void ntlGeometryObject::initMovingPoints(double time, gfxReal featureSize) {
}
}
if( (this-getMeshAnimated())
if( (this->getMeshAnimated())
|| (mcTrans.accessValues().size()>1) // VALIDATE
|| (mcRot.accessValues().size()>1)
|| (mcScale.accessValues().size()>1)

@ -109,28 +109,21 @@ class ntlGeometryObject : public ntlGeometryClass
inline float getCpsTimeEnd() const { return mCpsTimeEnd; }
inline void setCpsTimeEnd(float set) { mCpsTimeEnd=set; }
/*! Set/get the particle control set attract force strength */
inline float getAttractForceStrength() const { return mAttractforceStrength; }
inline void setAttractForceStrength(float set) { mAttractforceStrength=set; }
/*! Set/get the particle control set attract force radius */
inline float getAttractForceRadius() const { return mAttractforceRadius; }
inline void setAttractForceRadius(float set) { mAttractforceRadius=set; }
/*! Set/get the particle control set velocity force strength */
inline float getVelocityForceStrength() const { return mVelocityforceStrength; }
inline void setVelocityForceStrength(float set) { mVelocityforceStrength=set; }
/*! Set/get the particle control set velocity force radius */
inline float getVelocityForceRadius() const { return mVelocityforceRadius; }
inline void setVelocityForceRadius(float set) { mVelocityforceRadius=set; }
inline AnimChannel<float> getCpsAttrFStr() const { return mcAttrFStr; }
inline AnimChannel<float> getCpsAttrFRad() const { return mcAttrFRad; }
inline AnimChannel<float> getCpsVelFStr() const { return mcVelFStr; }
inline AnimChannel<float> getCpsVelFRad() const { return mcVelFRad; }
/****************************************/
/*! Init channels from float arrays (for elbeem API) */
void initChannels(
int nTrans, float *trans, int nRot, float *rot, int nScale, float *scale,
int nAct, float *act, int nIvel, float *ivel
int nAct, float *act, int nIvel, float *ivel,
int nAttrFStr, float *attrFStr,
int nAttrFRad, float *attrFRad,
int nVelFStr, float *velFStr,
int nVelFRad, float *velFRad
);
/*! is the object animated? */
@ -234,13 +227,8 @@ class ntlGeometryObject : public ntlGeometryClass
/* fluid control settings */
float mCpsTimeStart;
float mCpsTimeEnd
;
// TODO dg: change to channels
float mAttractforceStrength;
float mAttractforceRadius;
float mVelocityforceStrength;
float mVelocityforceRadius;
float mCpsTimeEnd;
AnimChannel<float> mcAttrFStr, mcAttrFRad, mcVelFStr, mcVelFRad;
public:

@ -234,10 +234,10 @@ LbmFsgrSolver::initCpdata()
cset->mContrPartFile = string("");
// TODO dg: switch to channels later
cset->mcForceAtt = AnimChannel<float>(obj->getAttractForceStrength());
cset->mcRadiusAtt = AnimChannel<float>(obj->getAttractForceRadius());
cset->mcForceVel = AnimChannel<float>(obj->getVelocityForceStrength());
cset->mcRadiusVel = AnimChannel<float>(obj->getVelocityForceRadius());
cset->mcForceAtt = obj->getCpsAttrFStr();
cset->mcRadiusAtt = obj->getCpsAttrFRad();
cset->mcForceVel = obj->getCpsVelFStr();
cset->mcRadiusVel = obj->getCpsVelFRad();
cset->mCparts->setCPSTimeStart(obj->getCpsTimeStart());
cset->mCparts->setCPSTimeEnd(obj->getCpsTimeEnd());

@ -696,16 +696,16 @@ bool LbmFsgrSolver::initializeSolverMemory()
// restrict max. chunk of 1 mem block to 1GB for windos
bool memBlockAllocProblem = false;
double maxWinMemChunk = 1100.*1024.*1024.;
double maxMacMemChunk = 1200.*1024.*1024.;
double maxDefaultMemChunk = 2.*1024.*1024.*1024.;
//std::cerr<<" memEstFine "<< memEstFine <<" maxWin:" <<maxWinMemChunk <<" maxMac:" <<maxMacMemChunk ; // DEBUG
#ifdef WIN32
double maxWinMemChunk = 1100.*1024.*1024.;
if(memEstFine> maxWinMemChunk) {
memBlockAllocProblem = true;
}
#endif // WIN32
#ifdef __APPLE__
double maxMacMemChunk = 1200.*1024.*1024.;
if(memEstFine> maxMacMemChunk) {
memBlockAllocProblem = true;
}

@ -175,7 +175,9 @@ int fluidsim_ar[FLUIDSIM_TOTIPO]= {
FLUIDSIM_VISC, FLUIDSIM_TIME,
FLUIDSIM_GRAV_X , FLUIDSIM_GRAV_Y , FLUIDSIM_GRAV_Z ,
FLUIDSIM_VEL_X , FLUIDSIM_VEL_Y , FLUIDSIM_VEL_Z ,
FLUIDSIM_ACTIVE
FLUIDSIM_ACTIVE,
FLUIDSIM_ATTR_FORCE_STR, FLUIDSIM_ATTR_FORCE_RADIUS,
FLUIDSIM_VEL_FORCE_STR, FLUIDSIM_VEL_FORCE_RADIUS,
};
int part_ar[PART_TOTIPO]= {

@ -336,8 +336,8 @@ typedef short IPO_Channel;
/* ******************** */
/* fluidsim ipos NT */
#define FLUIDSIM_TOTIPO 9
#define FLUIDSIM_TOTNAM 9
#define FLUIDSIM_TOTIPO 13
#define FLUIDSIM_TOTNAM 13
#define FLUIDSIM_VISC 1
#define FLUIDSIM_TIME 2
@ -352,6 +352,11 @@ typedef short IPO_Channel;
#define FLUIDSIM_ACTIVE 9
#define FLUIDSIM_ATTR_FORCE_STR 10
#define FLUIDSIM_ATTR_FORCE_RADIUS 11
#define FLUIDSIM_VEL_FORCE_STR 12
#define FLUIDSIM_VEL_FORCE_RADIUS 13
/* ******************** */
/* particle ipos */
#define PART_TOTIPO 19

@ -489,19 +489,40 @@ static void make_part_editipo(SpaceIpo *si)
}
// copied from make_seq_editipo
static void make_fluidsim_editipo(SpaceIpo *si) // NT
static void make_fluidsim_editipo(SpaceIpo *si, Object *ob) // NT
{
EditIpo *ei;
int a;
char *name;
ei= si->editipo= MEM_callocN(FLUIDSIM_TOTIPO*sizeof(EditIpo), "fluidsim_editipo");
si->totipo = FLUIDSIM_TOTIPO;
for(a=0; a<FLUIDSIM_TOTIPO; a++) {
FluidsimSettings *fss= ob->fluidsimSettings;
int numipos = FLUIDSIM_TOTIPO;
int ipo_start_index = 0;
// we don't need all fluid ipos for all types! - dg
if(fss->type == OB_FLUIDSIM_CONTROL)
{
numipos = 4; // there are 4 fluid control ipos
ipo_start_index = 9;
}
else if(fss->type == OB_FLUIDSIM_DOMAIN)
{
numipos = 5; // there are 5 ipos for fluid domains
}
else
{
numipos = 4; // there are 4 for the rest
ipo_start_index = 5;
}
ei= si->editipo= MEM_callocN(numipos*sizeof(EditIpo), "fluidsim_editipo");
si->totipo = numipos;
for(a=ipo_start_index; a<numipos; a++) {
//fprintf(stderr,"FSINAME %d %d \n",a,fluidsim_ar[a], (int)(getname_fluidsim_ei(fluidsim_ar[a])) );
name = getname_fluidsim_ei(fluidsim_ar[a]);
strcpy(ei->name, name);
ei->adrcode= fluidsim_ar[a];
ei->col= ipo_rainbow(a, FLUIDSIM_TOTIPO);
ei->col= ipo_rainbow(a, numipos);
ei->icu= find_ipocurve(si->ipo, ei->adrcode);
if(ei->icu) {
ei->flag = ei->icu->flag;
@ -962,7 +983,7 @@ static void make_editipo(void)
else if(G.sipo->blocktype==ID_FLUIDSIM) {
if (ob) { // NT
ob->ipowin= ID_FLUIDSIM;
make_fluidsim_editipo(G.sipo);
make_fluidsim_editipo(G.sipo, ob);
}
}
else if(G.sipo->blocktype==ID_PA) {

@ -100,7 +100,7 @@ char *snd_ic_names[SND_TOTNAM] = { "Vol", "Pitch", "Pan", "Atten" };
char *ac_ic_names[AC_TOTNAM] = {"LocX", "LocY", "LocZ", "ScaleX", "ScaleY",
"ScaleZ", "QuatW", "QuatX", "QuatY", "QuatZ"};
char *ic_name_empty[1] ={ "" };
char *fluidsim_ic_names[FLUIDSIM_TOTNAM] = { "Fac-Visc", "Fac-Time", "GravX","GravY","GravZ", "VelX","VelY","VelZ", "Active" };
char *fluidsim_ic_names[FLUIDSIM_TOTNAM] = { "Fac-Visc", "Fac-Time", "GravX","GravY","GravZ", "VelX","VelY","VelZ", "Active", "AttrForceStr", "AttrForceRad", "VelForceStr", "VelForceRad" };
char *part_ic_names[PART_TOTNAM] = { "E_Freq", "E_Life", "E_Speed", "E_Angular", "E_Size",
"Angular", "Size", "Drag", "Brown", "Damp", "Length", "Clump",
"GravX", "GravY", "GravZ", "KinkAmp", "KinkFreq", "KinkShape", "BBTilt"};

@ -314,6 +314,10 @@ void fluidsimGetGeometryObjFilename(struct Object *ob, char *dst) { //, char *sr
FS_FREE_ONECHANNEL(channelObjMove[i][2],"channelObjMove2"); \
FS_FREE_ONECHANNEL(channelObjInivel[i],"channelObjInivel"); \
FS_FREE_ONECHANNEL(channelObjActive[i],"channelObjActive"); \
FS_FREE_ONECHANNEL(channelAttractforceStrength[i],"channelAttractforceStrength"); \
FS_FREE_ONECHANNEL(channelAttractforceRadius[i],"channelAttractforceRadius"); \
FS_FREE_ONECHANNEL(channelVelocityforceStrength[i],"channelVelocityforceStrength"); \
FS_FREE_ONECHANNEL(channelVelocityforceRadius[i],"channelVelocityforceRadius"); \
} \
} // end FS FREE CHANNELS
@ -532,6 +536,12 @@ void fluidsimBake(struct Object *ob)
float *channelObjInivel[256]; // initial velocities
float *channelObjActive[256]; // obj active channel
/* fluid control channels */
float *channelAttractforceStrength[256];
float *channelAttractforceRadius[256];
float *channelVelocityforceStrength[256];
float *channelVelocityforceRadius[256];
if(getenv(strEnvName)) {
int dlevel = atoi(getenv(strEnvName));
elbeemSetDebugLevel(dlevel);
@ -716,6 +726,10 @@ void fluidsimBake(struct Object *ob)
channelObjMove[i][0] = channelObjMove[i][1] = channelObjMove[i][2] = NULL;
channelObjInivel[i] = NULL;
channelObjActive[i] = NULL;
channelAttractforceStrength[i] = NULL;
channelAttractforceRadius[i] = NULL;
channelVelocityforceStrength[i] = NULL;
channelVelocityforceRadius[i] = NULL;
}
allchannelSize = G.scene->r.efra; // always use till last frame
aniFrameTime = (domainSettings->animEnd - domainSettings->animStart)/(double)noFrames;
@ -881,9 +895,32 @@ void fluidsimBake(struct Object *ob)
}
}
{
int attrFSIcu[1] = { FLUIDSIM_ATTR_FORCE_STR };
int attrFRIcu[1] = { FLUIDSIM_ATTR_FORCE_RADIUS };
int velFSIcu[1] = { FLUIDSIM_VEL_FORCE_STR };
int velFRIcu[1] = { FLUIDSIM_VEL_FORCE_RADIUS };
float attrFSDefs[1];
float attrFRDefs[1];
float velFSDefs[1];
float velFRDefs[1];
attrFSDefs[0] = obit->fluidsimSettings->attractforceStrength;
attrFRDefs[0] = obit->fluidsimSettings->attractforceRadius;
velFSDefs[0] = obit->fluidsimSettings->velocityforceStrength;
velFRDefs[0] = obit->fluidsimSettings->velocityforceRadius;
fluidsimInitChannel( &channelAttractforceStrength[o], allchannelSize, timeAtFrame, attrFSIcu,attrFSDefs, obit->fluidsimSettings->ipo, CHANNEL_FLOAT );
fluidsimInitChannel( &channelAttractforceRadius[o], allchannelSize, timeAtFrame, attrFRIcu,attrFRDefs, obit->fluidsimSettings->ipo, CHANNEL_FLOAT );
fluidsimInitChannel( &channelVelocityforceStrength[o], allchannelSize, timeAtFrame, velFSIcu,velFSDefs, obit->fluidsimSettings->ipo, CHANNEL_FLOAT );
fluidsimInitChannel( &channelVelocityforceRadius[o], allchannelSize, timeAtFrame, velFRIcu,velFRDefs, obit->fluidsimSettings->ipo, CHANNEL_FLOAT );
}
fluidsimInitChannel( &channelObjInivel[o], allchannelSize, timeAtFrame, inivelIcu,inivelDefs, obit->fluidsimSettings->ipo, CHANNEL_VEC );
fluidsimInitChannel( &channelObjActive[o], allchannelSize, timeAtFrame, activeIcu,activeDefs, obit->fluidsimSettings->ipo, CHANNEL_FLOAT );
channelObjCount++;
}
@ -1028,7 +1065,7 @@ void fluidsimBake(struct Object *ob)
fsmesh.obstaclePartslip = obit->fluidsimSettings->partSlipValue;
fsmesh.volumeInitType = obit->fluidsimSettings->volumeInitType;
fsmesh.obstacleImpactFactor = obit->fluidsimSettings->surfaceSmoothing; // misused value
/*
if(fsmesh.type == OB_FLUIDSIM_CONTROL)
{
// control fluids will get exported as whole
@ -1037,11 +1074,24 @@ void fluidsimBake(struct Object *ob)
fsmesh.cpsTimeStart = obit->fluidsimSettings->cpsTimeStart;
fsmesh.cpsTimeEnd = obit->fluidsimSettings->cpsTimeEnd;
fsmesh.attractforceStrength = obit->fluidsimSettings->attractforceStrength;
fsmesh.attractforceRadius = obit->fluidsimSettings->attractforceRadius;
fsmesh.velocityforceStrength = obit->fluidsimSettings->velocityforceStrength;
fsmesh.velocityforceRadius = obit->fluidsimSettings->velocityforceRadius;
}*/
fsmesh.channelSizeAttractforceRadius =
fsmesh.channelSizeVelocityforceStrength =
fsmesh.channelSizeVelocityforceRadius =
fsmesh.channelSizeAttractforceStrength = allchannelSize;
fsmesh.channelAttractforceRadius = channelAttractforceStrength[o];
fsmesh.channelAttractforceRadius = channelAttractforceRadius[o];
fsmesh.channelVelocityforceStrength = channelVelocityforceStrength[o];
fsmesh.channelVelocityforceRadius = channelVelocityforceRadius[o];
}
else
{
// set channels to 0
fsmesh.channelAttractforceStrength =
fsmesh.channelAttractforceRadius =
fsmesh.channelVelocityforceStrength =
fsmesh.channelVelocityforceRadius = NULL;
}
// animated meshes
if(deform) {