Fluid control: WIP commit before weekend, not working is crashing on the first 3 frames

This commit is contained in:
Daniel Genrich
2008-07-25 18:57:16 +00:00
parent 9bf0bfcae7
commit d7fecc9e96
29 changed files with 1600 additions and 1493 deletions

View File

@@ -32,7 +32,7 @@ typedef struct elbeemSimulationSettings {
short version;
/* id number of simulation domain, needed if more than a
* single domain should be simulated */
short domainId;
short domainId; // unused within blender
/* geometrical extent */
float geoStart[3], geoSize[3];
@@ -187,6 +187,9 @@ void elbeemResetSettings(struct elbeemSimulationSettings*);
// start fluidsim init (returns !=0 upon failure)
int elbeemInit(void);
// frees fluidsim
int elbeemFree(void);
// start fluidsim init (returns !=0 upon failure)
int elbeemAddDomain(struct elbeemSimulationSettings*);

View File

@@ -57,6 +57,7 @@ void ControlParticles::initBlenderTest() {
initTime(0. , 1.);
}
// blender control object gets converted to mvm flui control object
int ControlParticles::initFromObject(ntlGeometryObjModel *model) {
vector<ntlTriangle> triangles;
vector<ntlVec3Gfx> vertices;
@@ -73,6 +74,7 @@ int ControlParticles::initFromObject(ntlGeometryObjModel *model) {
printf("a animated? %d\n", model->getIsAnimated());
printf("b animated? %d\n", model->getMeshAnimated());
*/
model->setGeoInitType(FGI_FLUID);
model->getTriangles(mCPSTimeStart, &triangles, &vertices, &normals, 1 );
@@ -137,7 +139,7 @@ int ControlParticles::initFromObject(ntlGeometryObjModel *model) {
// init first set, check dist
ControlParticleSet firstcps; //T
mPartSets.push_back(firstcps);
mPartSets[mPartSets.size()-1].time = (gfxReal)0.;
mPartSets[mPartSets.size()-1].time = mCPSTimeStart;
vector<bool> useCP;
for(int i=0; i<(int)inspos.size(); i++) {
@@ -1378,8 +1380,10 @@ void ControlParticles::calculateCpInfluenceOpt(ControlParticle *cp, LbmVec fluid
#if (CP_PROJECT2D==1) && (defined(MAIN_2D) || LBMDIM==2)
// fillFactor *= 2.0 *0.75 * pdistance; // 2d>3d sampling
#endif // (CP_PROJECT2D==1) && (defined(MAIN_2D) || LBMDIM==2)
LbmFloat signum = getInfluenceAttraction() > 0.0 ? 1.0 : -1.0;
cp->density += falloffAtt * fillFactor;
force->forceAtt += posDelta *cp->densityWeight *cp->influence;
force->forceAtt += posDelta *cp->densityWeight *cp->influence *signum;
force->weightAtt += falloffAtt*cp->densityWeight *cp->influence;
LbmFloat falloffVel = 0.; //CPKernel::kernel(cpfo * 1.0, pdistance);

View File

@@ -96,6 +96,13 @@ int elbeemInit() {
return 0;
}
// fluidsim end
extern "C"
int elbeemFree() {
return 0;
}
// start fluidsim init
extern "C"
int elbeemAddDomain(elbeemSimulationSettings *settings) {
@@ -253,6 +260,7 @@ int elbeemSimulate(void) {
if(getElbeemState() != SIMWORLD_STOP) {
// ok, we're done...
delete gpWorld;
gpWorld = NULL;
debMsgStd("elbeemSimulate",DM_NOTIFY, "El'Beem simulation done, time: "<<getTimeString(timeend-timestart)<<".\n", 2 );
} else {

View File

@@ -688,7 +688,8 @@ ntlScene::~ntlScene()
if(mpTree != NULL) delete mpTree;
// cleanup lists, only if this is the rendering cleanup scene
if(mSceneDel) {
if(mSceneDel)
{
for (vector<ntlGeometryClass*>::iterator iter = mGeos.begin();
iter != mGeos.end(); iter++) {
//errMsg("ntlScene::~ntlScene","Deleting obj "<<(*iter)->getName() );

View File

@@ -236,10 +236,15 @@ ntlWorld::~ntlWorld()
{
delete mpGlob->getRenderScene();
delete mpGlob->getSimScene();
delete mpGlob;
delete mpLightList;
delete mpPropList;
delete mpSims;
delete mpGlob;
// these get assigned to mpGlob but not freed there
delete mpLightList;
delete mpPropList; // materials
delete mpSims;
#ifndef NOGUI
if(mpOpenGLRenderer) delete mpOpenGLRenderer;
#endif // NOGUI
@@ -895,6 +900,8 @@ ntlRenderGlobals::ntlRenderGlobals() :
ntlRenderGlobals::~ntlRenderGlobals() {
if(mpOpenGlAttr) delete mpOpenGlAttr;
if(mpBlenderAttr) delete mpBlenderAttr;
}

View File

@@ -236,7 +236,6 @@ LbmFsgrSolver::initCpdata()
// dont load any file
cset->mContrPartFile = string("");
// TODO dg: switch to channels later
cset->mcForceAtt = obj->getCpsAttrFStr();
cset->mcRadiusAtt = obj->getCpsAttrFRad();
cset->mcForceVel = obj->getCpsVelFStr();
@@ -491,8 +490,8 @@ LbmFsgrSolver::handleCpdata()
// init for current time
for(int cpssi=0; cpssi<(int)mpControl->mCons.size(); cpssi++) {
ControlParticles *cparts = mpControl->mCons[cpssi]->mCparts;
LbmControlSet *cset = mpControl->mCons[cpssi];
cparts->setRadiusAtt(cset->mcRadiusAtt.get(mSimulationTime));
cparts->setRadiusVel(cset->mcRadiusVel.get(mSimulationTime));
cparts->setInfluenceAttraction(cset->mcForceAtt.get(mSimulationTime) );
@@ -506,18 +505,22 @@ LbmFsgrSolver::handleCpdata()
cparts->setInfluenceVelocity( cset->mcForceVel.get(mSimulationTime), mLevel[fineLev].timestep );
cparts->setLastOffset( vec2L(cset->mcCpOffset.get(mSimulationTime-mLevel[fineLev].timestep)) );
cparts->setLastScale( vec2L(cset->mcCpScale.get(mSimulationTime-mLevel[fineLev].timestep)) );
}
// check actual values
LbmFloat iatt = mpControl->mCons[0]->mCparts->getInfluenceAttraction();
LbmFloat iatt = ABS(mpControl->mCons[0]->mCparts->getInfluenceAttraction());
LbmFloat ivel = mpControl->mCons[0]->mCparts->getInfluenceVelocity();
LbmFloat imaxd = mpControl->mCons[0]->mCparts->getInfluenceMaxdist();
//errMsg("FINCIT","iatt="<<iatt<<" ivel="<<ivel<<" imaxd="<<imaxd);
for(int cpssi=1; cpssi<(int)mpControl->mCons.size(); cpssi++) {
LbmFloat iatt2 = mpControl->mCons[cpssi]->mCparts->getInfluenceAttraction();
LbmFloat iatt2 = ABS(mpControl->mCons[cpssi]->mCparts->getInfluenceAttraction());
LbmFloat ivel2 = mpControl->mCons[cpssi]->mCparts->getInfluenceVelocity();
LbmFloat imaxd2 = mpControl->mCons[cpssi]->mCparts->getInfluenceMaxdist();
if(iatt2 >iatt) iatt = iatt2;
// we allow negative attraction force here!
if(iatt2 > iatt) iatt = iatt2;
if(ivel2 >ivel) ivel = ivel2;
if(imaxd2>imaxd) imaxd= imaxd2;
//errMsg("FINCIT"," "<<cpssi<<" iatt2="<<iatt2<<" ivel2="<<ivel2<<" imaxd2="<<imaxd<<" NEW "<<" iatt="<<iatt<<" ivel="<<ivel<<" imaxd="<<imaxd);
@@ -581,6 +584,12 @@ LbmFsgrSolver::handleCpdata()
for(int cpssi=0; cpssi<(int)mpControl->mCons.size(); cpssi++) {
ControlParticles *cparts = mpControl->mCons[cpssi]->mCparts;
// ControlParticles *cpmotion = mpControl->mCons[cpssi]->mCpmotion;
// if control set is not active skip it
if((cparts->getControlTimStart() > mSimulationTime) || (cparts->getControlTimEnd() < mLastSimTime))
{
continue;
}
const LbmFloat velLatticeScale = mLevel[lev].timestep/mLevel[lev].nodeSize;
LbmFloat gsx = ((mvGeoEnd[0]-mvGeoStart[0])/(LbmFloat)mLevel[lev].lSizex);