void plAvBrainCritter::IStartBehavior() { if ((fNextMode >= fBehaviors.Count()) || (fNextMode < 0)) return; // invalid fNextMode // fade in our behavior CritterBehavior* behavior = (CritterBehavior*)fBehaviors[fNextMode]; behavior->SetStrength(1.f, fFadingNextBehavior ? behavior->FadeInLength() : 0.f); // if we start at a random point, do so if (behavior->RandomStartPoint()) { float newStart = sRandom.RandZeroToOne() * behavior->GetAnimLength(); behavior->SetAnimTime(newStart); } // clean up the internal variables fCurMode = fNextMode; fNextMode = -1; }
hsBool plDynaRippleVSMgr::IRippleFromShape(const plPrintShape* shape, hsBool force) { if( !ICheckRTMat() ) return false; if( !shape ) return false; hsBool retVal = false; plDynaDecalInfo& info = IGetDecalInfo(uintptr_t(shape), shape->GetKey()); const hsMatrix44& shapeL2W = shape->GetOwner()->GetLocalToWorld(); plConst(float) kMinDist(2.0f); plConst(float) kMinTime(1.5f); double t = hsTimer::GetSysSeconds(); float dt = float(t - info.fLastTime) * sRand.RandZeroToOne(); hsBool longEnough = (dt >= kMinTime); hsPoint3 xlate = shapeL2W.GetTranslate(); hsBool farEnough = (hsVector3(&info.fLastPos, &xlate).Magnitude() > kMinDist); if( force || longEnough || farEnough ) { hsPoint3 pos = shapeL2W.GetTranslate(); // We'll perturb the position a little so it doesn't look quite so regular, // but we perturb it more if we're just standing still hsVector3 randPert(sRand.RandMinusOneToOne(), sRand.RandMinusOneToOne(), 0); randPert.Normalize(); if( !farEnough ) { plConst(float) kRandPert = 0.5f; randPert *= kRandPert; } else { plConst(float) kRandPert = 0.15f; randPert *= kRandPert; } pos += randPert; // Are we potentially touching the water? float waterHeight = fWaveSetBase->GetHeight(); if( (pos.fZ - fScale.fZ * shape->GetHeight() < waterHeight) &&(pos.fZ + fScale.fZ * shape->GetHeight() > waterHeight) ) { hsVector3 dir(fWaveSetBase->GetWindDir()); hsVector3 up(0.f, 0.f, 1.f); float wid = hsMaximum(shape->GetWidth(), shape->GetLength()); plConst(float) kMaxWaterDepth(1000.f); hsVector3 size(wid * fScale.fX, wid * fScale.fY, kMaxWaterDepth); fCutter->SetLength(size); fCutter->Set(pos, dir, up); hsBool hit = ICutoutTargets(t); if( hit ) { info.fLastTime = t; info.fLastPos = shapeL2W.GetTranslate(); retVal = true; } else { retVal = false; // No-effect else just for break points. } } } return retVal; }