void LLWLParamSet::updateCloudScrolling(void) { static LLTimer s_cloud_timer; F64 delta_t = s_cloud_timer.getElapsedTimeAndResetF64(); if(getEnableCloudScrollX()) { mCloudScrollXOffset += F32(delta_t * (getCloudScrollX() - 10.f) / 100.f); } if(getEnableCloudScrollY()) { mCloudScrollYOffset += F32(delta_t * (getCloudScrollY() - 10.f) / 100.f); } }
QuatF & Quat16::getQuatF( QuatF * q ) const { q->x = F32( x ) / F32(MAX_VAL); q->y = F32( y ) / F32(MAX_VAL); q->z = F32( z ) / F32(MAX_VAL); q->w = F32( w ) / F32(MAX_VAL); return *q; }
void GFXD3D9Device::setClipRect( const RectI &inRect ) { // We transform the incoming rect by the view // matrix first, so that it can be used to pan // and scale the clip rect. // // This is currently used to take tiled screenshots. Point3F pos( inRect.point.x, inRect.point.y, 0.0f ); Point3F extent( inRect.extent.x, inRect.extent.y, 0.0f ); getViewMatrix().mulP( pos ); getViewMatrix().mulV( extent ); RectI rect( pos.x, pos.y, extent.x, extent.y ); // Clip the rect against the renderable size. Point2I size = mCurrentRT->getSize(); RectI maxRect(Point2I(0,0), size); rect.intersect(maxRect); mClipRect = rect; F32 l = F32( mClipRect.point.x ); F32 r = F32( mClipRect.point.x + mClipRect.extent.x ); F32 b = F32( mClipRect.point.y + mClipRect.extent.y ); F32 t = F32( mClipRect.point.y ); // Set up projection matrix, static Point4F pt; pt.set(2.0f / (r - l), 0.0f, 0.0f, 0.0f); mTempMatrix.setColumn(0, pt); pt.set(0.0f, 2.0f/(t - b), 0.0f, 0.0f); mTempMatrix.setColumn(1, pt); pt.set(0.0f, 0.0f, 1.0f, 0.0f); mTempMatrix.setColumn(2, pt); pt.set((l+r)/(l-r), (t+b)/(b-t), 1.0f, 1.0f); mTempMatrix.setColumn(3, pt); setProjectionMatrix( mTempMatrix ); // Set up world/view matrix mTempMatrix.identity(); setWorldMatrix( mTempMatrix ); setViewport( mClipRect ); }
QuatF & QuatF::interpolate( const QuatF & q1, const QuatF & q2, F32 t ) { //----------------------------------- // Calculate the cosine of the angle: double cosOmega = q1.dot( q2 ); //----------------------------------- // adjust signs if necessary: F32 sign2; if ( cosOmega < 0.0 ) { cosOmega = -cosOmega; sign2 = -1.0f; } else sign2 = 1.0f; //----------------------------------- // calculate interpolating coeffs: double scale1, scale2; if ( (1.0 - cosOmega) > 0.00001 ) { // standard case double omega = mAcos(cosOmega); double sinOmega = mSin(omega); scale1 = mSin((1.0 - t) * omega) / sinOmega; scale2 = sign2 * mSin(t * omega) / sinOmega; } else { // if quats are very close, just do linear interpolation scale1 = 1.0 - t; scale2 = sign2 * t; } //----------------------------------- // actually do the interpolation: x = F32(scale1 * q1.x + scale2 * q2.x); y = F32(scale1 * q1.y + scale2 * q2.y); z = F32(scale1 * q1.z + scale2 * q2.z); w = F32(scale1 * q1.w + scale2 * q2.w); return *this; }
bool Win32RedBookDevice::getVolume(F32 * volume) { if(!mAcquired) { setLastError("Device has not been acquired"); return(false); } if(!mVolumeInitialized) { setLastError("Volume failed to initialize"); return(false); } U32 vol = 0; if(mUsingMixer) { mixerGetControlDetails(mVolumeDeviceId, &mMixerVolumeDetails, MIXER_GETCONTROLDETAILSF_VALUE); vol = mMixerVolumeValue.dwValue; } else auxGetVolume(mAuxVolumeDeviceId, (unsigned long *)&vol); vol &= 0xffff; *volume = F32(vol) / 65535.f; setLastError(""); return(true); }
/*virtual*/ void LLMediaDataClient::Responder::error(U32 status, const std::string& reason) { if (status == HTTP_SERVICE_UNAVAILABLE) { F32 retry_timeout = mRequest->getRetryTimerDelay(); mRequest->incRetryCount(); if (mRequest->getRetryCount() < mRequest->getMaxNumRetries()) { LL_INFOS("LLMediaDataClient") << *mRequest << " got SERVICE_UNAVAILABLE...retrying in " << retry_timeout << " seconds" << LL_ENDL; // Start timer (instances are automagically tracked by // InstanceTracker<> and LLEventTimer) new RetryTimer(F32(retry_timeout/*secs*/), this); } else { LL_INFOS("LLMediaDataClient") << *mRequest << " got SERVICE_UNAVAILABLE...retry count " << mRequest->getRetryCount() << " exceeds " << mRequest->getMaxNumRetries() << ", not retrying" << LL_ENDL; } } else { std::string msg = boost::lexical_cast<std::string>(status) + ": " + reason; LL_WARNS("LLMediaDataClient") << *mRequest << " http error(" << msg << ")" << LL_ENDL; } }
// // GetNearbyWalls // // Get walls within link distance of the given position // void WallObjType::GetNearbyWalls(Team *team, const Vector &p, WallObjList &list, WallObj *filter) { ASSERT(WorldCtrl::MetreOnMap(p.x, p.z)) // What range should we search in F32 range = F32(GetRangeStraight() + 1) * WorldCtrl::CellSize(); // Generate a unit iterator UnitObjIter::Tactical i(NULL, UnitObjIter::FilterData(team, Relation::ALLY, p, range)); UnitObj *obj; // Check each unit while ((obj = i.Next()) != NULL) { // Is this a wall if (WallObj *wall = Promote::Object<WallObjType, WallObj>(obj)) { // Should we add it if (wall != filter) { list.Append(wall); } } } }
void PGRAPH::ClearSurface(U32 mask) { // Avoid clearing empty surfaces if (surface.width == 0 || surface.height == 0) { return; } const F32 color[4] = { ((clear_color >> 24) & 0xFF) / 255.0f, // Red ((clear_color >> 16) & 0xFF) / 255.0f, // Green ((clear_color >> 8) & 0xFF) / 255.0f, // Blue ((clear_color >> 0) & 0xFF) / 255.0f, // Alpha }; const F32 depth = clear_depth / F32(0xFFFFFF); const U08 stencil = clear_stencil; if (mask & RSX_CLEAR_BIT_COLOR) { auto* colorTarget = getColorTarget(surface.colorOffset[0]); cmdBuffer->cmdClearColor(colorTarget, color); } if (mask & (RSX_CLEAR_BIT_DEPTH | RSX_CLEAR_BIT_STENCIL)) { // TODO: Depth-exclusive or stencil-exclusive clears are unimplemented auto* depthTarget = getDepthStencilTarget(surface.depthOffset); cmdBuffer->cmdClearDepthStencil(depthTarget, depth, stencil); } // TODO: Check if cmdBuffer is empty cmdBuffer->finalize(); cmdQueue->submit(cmdBuffer, fence); fence->wait(); cmdBuffer->reset(); }
// Return a measure of a player's strength. // Right now this is roughly a kill - death / kill + death ratio // Better might be: https://secure.wikimedia.org/wikipedia/en/wiki/Elo_rating_system F32 Statistics::getCalculatedRating() { // Total kills = mKills + mFratricides (but we won't count mFratricides) // Counted deaths = mDeaths - mSuicides (mSuicides are included in mDeaths and we want to ignore them) // Use F32 here so we don't underflow with U32 math; probably not necessary F32 deathsDueToEnemyAction = F32(mTotalDeaths) - F32(mTotalSuicides); F32 totalTotalKillsAndDeaths = F32(mTotalKills) + deathsDueToEnemyAction; // Initial case: you haven't killed or died -- go out and prove yourself, lad! if(totalTotalKillsAndDeaths == 0) return 0; // Standard case else return ((F32)mTotalKills - deathsDueToEnemyAction) / totalTotalKillsAndDeaths; }
bool StdClientProcessList::advanceTime( SimTime timeDelta ) { PROFILE_SCOPE( StdClientProcessList_AdvanceTime ); if ( doBacklogged( timeDelta ) ) return false; bool ret = Parent::advanceTime( timeDelta ); ProcessObject *obj = NULL; AssertFatal( mLastDelta >= 0.0f && mLastDelta <= 1.0f, "mLastDelta is not zero to one."); obj = mHead.mProcessLink.next; while ( obj != &mHead ) { if ( obj->isTicking() ) obj->interpolateTick( mLastDelta ); obj = obj->mProcessLink.next; } for (U32 i = 0; i < UpdateInterface::all.size(); i++) { Component *comp = dynamic_cast<Component*>(UpdateInterface::all[i]); if (!comp->isClientObject() || !comp->isActive()) continue; UpdateInterface::all[i]->interpolateTick(mLastDelta); } // Inform objects of total elapsed delta so they can advance // client side animations. F32 dt = F32(timeDelta) / 1000; // Update camera FX. gCamFXMgr.update( dt ); obj = mHead.mProcessLink.next; while ( obj != &mHead ) { obj->advanceTime( dt ); obj = obj->mProcessLink.next; } for (U32 i = 0; i < UpdateInterface::all.size(); i++) { Component *comp = dynamic_cast<Component*>(UpdateInterface::all[i]); if (comp) { if (!comp->isClientObject() || !comp->isActive()) continue; } UpdateInterface::all[i]->advanceTime(dt); } return ret; }
// // Adjust resource display // void ResourceObj::AdjustResource() { if (Mesh().curCycle) { Mesh().SetFrame((Mesh().curCycle->maxFrame - 1) * (1.0f - (F32(resource) * ResourceType()->GetResourceMaxInv()))); } }
AppIfl::AppIfl(const char * fullPath) { mIflFile = strnew(fullPath); // load in duration and names std::ifstream is; is.open(fullPath); char buffer[256]; char name[256]; S32 duration; while (is.good() && !is.eof()) { is.getline(buffer,sizeof(buffer)); S32 num = sscanf(buffer,"%s %i",name,&duration); if (num==1) { mNames.push_back(strnew(name)); mDurations.push_back(AppTime(1.0f/30.0f,0)); } else if (num==2) { mNames.push_back(strnew(name)); mDurations.push_back(AppTime(F32(duration)/30.0f,0)); } } }
void EnergyGaugeRenderer::render(S32 energy) { // Create fade static const F32 colors[] = { Colors::blue.r, Colors::blue.g, Colors::blue.b, 1, // Fade from Colors::blue.r, Colors::blue.g, Colors::blue.b, 1, Colors::cyan.r, Colors::cyan.g, Colors::cyan.b, 1, // Fade to Colors::cyan.r, Colors::cyan.g, Colors::cyan.b, 1, }; GaugeRenderer::render(energy, Ship::EnergyMax, colors, GaugeBottomMargin, GaugeHeight, Ship::EnergyCooldownThreshold); #ifdef SHOW_SERVER_SITUATION ServerGame *serverGame = GameManager::getServerGame(); if((serverGame && serverGame->getClientInfo(0)->getConnection()->getControlObject())) { S32 actDiff = static_cast<Ship *>(serverGame->getClientInfo(0)->getConnection()->getControlObject())->getEnergy(); S32 p = F32(actDiff) / Ship::EnergyMax * GaugeWidth; glColor(Colors::magenta); drawVertLine(xul + p, yul - SafetyLineExtend - 1, yul + GaugeHeight + SafetyLineExtend); //Or, perhaps, just this: //renderGauge(energy, Ship::EnergyMax, Colors::blue, Colors::cyan, GaugeBottomMargin, GaugeHeight); } #endif }
// // Process the recycler // void Base::Recycler::Process() { // Work out how much resource is pending from refunds U32 refund = 0; for (UnitObjList::Iterator u(&state.GetBase().GetManager().GetRefunds()); *u; ++u) { refund += U32(F32((**u)->GetResourceValue() * (**u)->UnitType()->GetRecyclePercentage())); } Object &object = state.GetBase().GetObject(); Team *team = object.GetTeam(); U32 resource = team->GetResourceStore(); // Do we have less cash now than the limit ? if ((resource + refund) < cash) { for (NList<Type>::Iterator t(&types); *t; ++t) { const NList<UnitObj> *units = team->GetUnitObjects((*t)->type->GetNameCrc()); if (units && units->GetCount() > (*t)->minimum) { // Order this unit to be recycled UnitObj *unit = units->GetHead(); Orders::Game::ClearSelected::Generate(object); Orders::Game::AddSelected::Generate(object, unit); Orders::Game::Recycle::Generate(object); state.GetBase().GetManager().AddRefund(unit); break; } } } }
// strait twisty beam // void BeamRenderPlain::Setup() { // get beam rendering class BeamRenderPlainClass * sc = (BeamRenderPlainClass *)proto; F32 t = paramAnim.Current().scale; if (t <= 1) { offset = sc->data.vector * t; } Quaternion r = angle * rotation; const Vector & p0 = particle->matrix.posit; Vector * p = points.data, * pe = points.data + points.count - 1; *p++ = p0; Vector dof = offset * (1.0f / F32(points.count - 1)), off = dof; //LOG_DIAG(("")) //LOG_DIAG(("")) //LOG_DIAG(("p: %f,%f,%f", p->x, p->y, p->z)); for (F32 h = 0; p < pe; p++, off += dof, r *= twist) { *p = p0 + off + r.GetRight() * sc->distance; //LOG_DIAG(("p: %f,%f,%f", p->x, p->y, p->z)); } *p = p0 + off; //LOG_DIAG(("p: %f,%f,%f", p->x, p->y, p->z)); }
bool ReadJoystick(F32 axes[MaxJoystickAxes], U32 &buttonMask, U32 &hatMask) { if(!gJoystickInit) return false; S32 i; for(i = 0; i < MaxJoystickAxes; i++) { ControllerElement *e = &gController.axes[i]; S32 elementValue = getElementValue(e); S32 diff = e->maxValue - e->minValue; if(diff != 0) { axes[i] = (elementValue - e->minValue) * 2 / F32(diff); axes[i] -= 1; } else axes[i] = 0; } buttonMask = 0; for(i = 0; i < gController.buttons.size(); i++) { ControllerElement *e = &gController.buttons[i]; S32 value = getElementValue(e); if(value) buttonMask |= (1 << i); } return true; }
SFXBuffer* SFXProfile::_createBuffer() { SFXBuffer* buffer = 0; // Try to create through SFXDevie. if( !mFilename.isEmpty() && SFX ) { buffer = SFX->_createBuffer( mFilename, mDescription ); if( buffer ) { #ifdef TORQUE_DEBUG const SFXFormat& format = buffer->getFormat(); Con::printf( "%s SFX: %s (%i channels, %i kHz, %.02f sec, %i kb)", mDescription->mIsStreaming ? "Streaming" : "Loaded", mFilename.c_str(), format.getChannels(), format.getSamplesPerSecond() / 1000, F32( buffer->getDuration() ) / 1000.0f, format.getDataLength( buffer->getDuration() ) / 1024 ); #endif } } // If that failed, load through SFXResource. if( !buffer ) { Resource< SFXResource >& resource = getResource(); if( resource != NULL && SFX ) { #ifdef TORQUE_DEBUG const SFXFormat& format = resource->getFormat(); Con::printf( "%s SFX: %s (%i channels, %i kHz, %.02f sec, %i kb)", mDescription->mIsStreaming ? "Streaming" : "Loading", resource->getFileName().c_str(), format.getChannels(), format.getSamplesPerSecond() / 1000, F32( resource->getDuration() ) / 1000.0f, format.getDataLength( resource->getDuration() ) / 1024 ); #endif ThreadSafeRef< SFXStream > sfxStream = resource->openStream(); buffer = SFX->_createBuffer( sfxStream, mDescription ); } } return buffer; }
// // Image::Notify // void Image::Notify(U32 crc) { switch (crc) { case 0xC3AC47E6: // "Render::PostIFace2" { F32 curr = Simulate(); // Calculate screen rectangle const ClipRect &rc = cineViewPort; ClipRect newRc; if (absolute) { if (absPos.x < 0) { newRc.p0.x = rc.p1.x - absSize.x + absPos.x; } else { newRc.p0.x = rc.p0.x + absPos.x; } if (absPos.y < 0) { newRc.p0.y = rc.p1.y - absSize.y + absPos.y; } else { newRc.p0.y = rc.p0.y + absPos.y; } newRc.p1 = newRc.p0 + absSize; } else { newRc.p0.x = rc.p0.x + Utils::FtoL(pos.x * F32(rc.Width())); newRc.p0.y = rc.p0.y + Utils::FtoL(pos.y * F32(rc.Height())); newRc.p1.x = rc.p0.x + Utils::FtoL((pos.x + size.x) * F32(rc.Width())); newRc.p1.y = rc.p0.y + Utils::FtoL((pos.y + size.y) * F32(rc.Height())); } IFace::RenderRectangle(newRc, clr, &texture, curr * IFace::data.alphaScale); return; } } }
void AtlasOldMesher::updateBounds() { // Reset our bounds! mBounds.minExtents.set(F32_MAX, F32_MAX, F32_MAX); mBounds.maxExtents.set(-F32_MAX, -F32_MAX, -F32_MAX); // First, iterate over our verts and our bounds. for(S32 i=0; i<mVerts.size(); i++) { S16 z; if(mVerts[i].special) z = mVerts[i].z; else z = mHeight->sampleRead(mVerts[i].pos); Point3F v( mVerts[i].pos.x * mHeight->mSampleSpacing, mVerts[i].pos.y * mHeight->mSampleSpacing, z * mHeight->mVerticalScale); if(i) { mBounds.maxExtents.setMax(v); mBounds.minExtents.setMin(v); if(z < mMinZ) mMinZ = z; if(z > mMaxZ) mMaxZ = z; } else { mMaxZ = mMinZ = z; mBounds.maxExtents = mBounds.minExtents = v; } } // Calculate quantization for compression. Point3F boxExtents(mBounds.len_x() / 2.f, mBounds.len_y() / 2.f, mBounds.len_z() / 2.f); boxExtents.setMax(Point3F(1, 1, 1)); // Make sure we don't bottom out... // Use (1 << 14) values in both positive and negative // directions. Wastes just under 1 bit, but the total range // is [-2^14, 2^14], which is 2^15+1 values. This is good -- // fits nicely w/ 2^N+1 dimensions of binary-triangle-tree // vertex locations. mCompressionFactor.x = F32(1<<14) / boxExtents.x; mCompressionFactor.y = F32(1<<14) / boxExtents.y; mCompressionFactor.z = F32(1<<14) / boxExtents.z; }
//---------------------------------------------------------------------------- // Create ring //---------------------------------------------------------------------------- SplashRing Splash::createRing() { SplashRing ring; U32 numPoints = mDataBlock->numSegments + 1; Point3F ejectionAxis( 0.0, 0.0, 1.0 ); Point3F axisx; if (mFabs(ejectionAxis.z) < 0.999f) mCross(ejectionAxis, Point3F(0, 0, 1), &axisx); else mCross(ejectionAxis, Point3F(0, 1, 0), &axisx); axisx.normalize(); for( U32 i=0; i<numPoints; i++ ) { F32 t = F32(i) / F32(numPoints); AngAxisF thetaRot( axisx, mDataBlock->ejectionAngle * (M_PI / 180.0)); AngAxisF phiRot( ejectionAxis, t * (M_PI * 2.0)); Point3F pointAxis = ejectionAxis; MatrixF temp; thetaRot.setMatrix(&temp); temp.mulP(pointAxis); phiRot.setMatrix(&temp); temp.mulP(pointAxis); Point3F startOffset = axisx; temp.mulV( startOffset ); startOffset *= mDataBlock->startRadius; SplashRingPoint point; point.position = getPosition() + startOffset; point.velocity = pointAxis * mDataBlock->velocity; ring.points.push_back( point ); } ring.color = mDataBlock->colors[0]; ring.lifetime = mDataBlock->ringLifetime; ring.elapsedTime = 0.0; ring.v = mDataBlock->texFactor * mFmod( mElapsedTime, 1.0 ); return ring; }
//-------------------------------------------------------------------------- /// Function to draw a set of boxes blending throughout an array of colors void GuiColorPickerCtrl::drawBlendRangeBox(RectI &bounds, bool vertical, U8 numColors, ColorI *colors) { GFX->setStateBlock(mStateBlock); S32 l = bounds.point.x, r = bounds.point.x + bounds.extent.x + 4; S32 t = bounds.point.y, b = bounds.point.y + bounds.extent.y + 4; // Calculate increment value S32 x_inc = int(mFloor((r - l) / F32(numColors-1))); S32 y_inc = int(mFloor((b - t) / F32(numColors-1))); for( U16 i = 0;i < numColors - 1; i++ ) { // This is not efficent, but then again it doesn't really need to be. -pw PrimBuild::begin( GFXTriangleFan, 4 ); if (!vertical) // Horizontal (+x) { // First color PrimBuild::color( colors[i] ); PrimBuild::vertex2i( l, t ); PrimBuild::vertex2i( l, b ); // Second color PrimBuild::color( colors[i+1] ); PrimBuild::vertex2i( l + x_inc, b ); PrimBuild::vertex2i( l + x_inc, t ); l += x_inc; } else // Vertical (+y) { // First color PrimBuild::color( colors[i] ); PrimBuild::vertex2i( l, t ); PrimBuild::vertex2i( r, t ); // Second color PrimBuild::color( colors[i+1] ); PrimBuild::vertex2i( r, t + y_inc ); PrimBuild::vertex2i( l, t + y_inc ); t += y_inc; } PrimBuild::end(); } }
F32 CameraSpline::advanceTime(F32 t, S32 delta_ms) { buildTimeMap(); Knot k; value(t, &k, false); F32 dist = getDistance(t) + k.mSpeed * (F32(delta_ms) / 1000.0f); return getTime(dist); }
void GuiSliderCtrl::onMouseDown(const GuiEvent &event) { if ( !mActive || !mAwake || !mVisible ) return; mouseLock(); setFirstResponder(); mDepressed = true; Point2I curMousePos = globalToLocalCoord( event.mousePoint ); F32 value; if (getWidth() >= getHeight()) value = F32(curMousePos.x-mShiftPoint) / F32(getWidth()-mShiftExtent)*(mRange.y-mRange.x) + mRange.x; else value = F32(curMousePos.y) / F32(getHeight())*(mRange.y-mRange.x) + mRange.x; _updateThumb( value, mSnap || ( event.modifier & SI_SHIFT ) ); }
// // Letterbox::Notify // void Letterbox::Notify(U32 crc) { switch (crc) { case 0xF530E366: // "Render::PreRender" { F32 curr = Simulate(); // Modify the viewport S32 x = Vid::backBmp.Width(); S32 y = Vid::backBmp.Height(); S32 viewY = (x * 9) >> 4; S32 bordY = (y - viewY) >> 1; currPixels = bordY - Utils::FtoLNearest(F32(bordY) * curr); if (bordY > 0) { // Enter letterbox mode viewport.SetSize(0, currPixels, x, y - (currPixels << 1)); Vid::CurCamera().Setup( viewport); } else { viewport.SetSize(0, 0, Vid::backBmp.Width(), Vid::backBmp.Height()); } //LOG_DIAG(("viewport=%d,%d,%d,%d", viewport.p0.x, viewport.p0.z, viewport.p1.x, viewport.p1.z)) // cineViewPort should reflect current view inside borders cineViewPort = viewport; // Setup full viewport parameters fullvp.Set(0, 0, x, y); ClipRect rc; return; } case 0xCEEF613F: // "Render::PostIFace1" { Vid::ClipScreen(); // full screen clipping // Draw border ClipRect rc; rc.Set(0, 0, fullvp.p1.x, currPixels); Vid::RenderRectangle( rc, 0xff000000, NULL, RS_BLEND_DEF, Vid::sortNORMAL0, 0, 1, TRUE); rc.Set(0, fullvp.p1.y - currPixels, fullvp.p1.x, fullvp.p1.y); Vid::RenderRectangle( rc, 0xff000000, NULL, RS_BLEND_DEF, Vid::sortNORMAL0, 0, 1, TRUE); Vid::ClipRestore(); // restore letterbox clipping return; } } }
// // SetVolume // // Sets the current redbook audio volume // void SetVolume(F32 volume) { if (initialized && driver) { AIL_redbook_set_volume ( driver, Clamp<S32>(MIN_VOLUME, S32((volume * F32(MAX_VOLUME)) + 0.5F), MAX_VOLUME) ); } }
bool isEqualQ16(const Quaternion & a, const Quaternion &b) { U16 MAX_VAL = 0x7fff; // convert components to 16 bit, then test for equality S16 x, y, z, w; x = ((S16)(a.x() * F32(MAX_VAL))) - ((S16)(b.x() * F32(MAX_VAL))); y = ((S16)(a.y() * F32(MAX_VAL))) - ((S16)(b.y() * F32(MAX_VAL))); z = ((S16)(a.z() * F32(MAX_VAL))) - ((S16)(b.z() * F32(MAX_VAL))); w = ((S16)(a.w() * F32(MAX_VAL))) - ((S16)(b.w() * F32(MAX_VAL))); return (x==0) && (y==0) && (z==0) && (w==0); }
/////////////////////////////////////////////////////////////////////////////// /// \brief Called when the mouse is moved while a particular mouse button is /// pressed. /// /// \details Updates the active object's rotation so that it appears rotated /// relative to start position of the drag. /// /// Right and left mouse button dragging both have the same effect. /// Drag to the left or up to rotate CCW or right or down to rotate /// CW. /// /// \param button The mouse button that is pressed. /// start The position of the mouse when the drag operation started. /// end The current position of the mouse.} void RotateEditorMode::onDragUpdate(I32 button, const vec2& start, const vec2& end) { EditorMode::onDragUpdate(button, start, end); if (active_entity_ && (button == GLFW_MOUSE_BUTTON_LEFT || button == GLFW_MOUSE_BUTTON_RIGHT)) { vec2 delta = end - start; active_entity_->getTransform().setRotation(original_rotation_ + F32(3 * (delta.x + delta.y) / editor_.getZoom())); } }
// // Render a spline curve // void Spline(CubicSpline &curve, Color c, Bool normals, U32 normalMesh) { const U32 STEPS = 10; if (curve.length < 1e-4F) { return; } F32 step = curve.length / F32(STEPS); Vector v0 = curve.Step(0.0F); Vector v1, tangent; for (U32 i = 1; i <= STEPS; i++) { v1 = curve.Step(F32(i) * step, &tangent); // Draw the line FatLine(v0, v1, c, 0.15F); // Draw normals if (normals) { F32 veloc = tangent.Magnitude(); Matrix m = Matrix::I; m.posit = v1; // Normalize if (veloc > 1e-4) { tangent *= 1.0F / veloc; m.SetFromFront(tangent); } Common::Display::Mesh(normalMesh, m, c); // "TerrainMarker" } // Swap points v0 = v1; } }
// // Constructor // SpyObjType::SpyObjType(const char *name, FScope *fScope) : UnitObjType(name, fScope) { // Get specific config scope fScope = fScope->GetFunction(SCOPE_CONFIG); // Resources to steal per second, convert to per cycle resourceRate = Utils::FtoL(StdLoad::TypeF32(fScope, "ResourceRate", F32(GameTime::CYCLESPERSECOND), Range<F32>::positive) * GameTime::INTERVAL); // Level to reduce power to powerLevel = StdLoad::TypeF32(fScope, "PowerLevel", 0.5F, Range<F32>::percentage); // Power units to steal per second, convert to per cycle powerRate = Utils::FtoL(StdLoad::TypeF32(fScope, "PowerRate", F32(GameTime::CYCLESPERSECOND), Range<F32>::positive) * GameTime::INTERVAL); // Time delay from being compromised to being executed surrenderCycles = Utils::FtoL(StdLoad::TypeF32(fScope, "SurrenderDelay", 6.0F, Range<F32>::positive) * F32(GameTime::CYCLESPERSECOND)); // Load the morphing properties properties.Load(fScope, "Properties", FALSE); }
//---------------------------------------------------------------------------- // Emit rings //---------------------------------------------------------------------------- void Splash::emitRings( F32 dt ) { mTimeSinceLastRing += dt; S32 numNewRings = (S32) (mTimeSinceLastRing * F32(mDataBlock->ejectionFreq)); mTimeSinceLastRing -= numNewRings / mDataBlock->ejectionFreq; for( S32 i=numNewRings-1; i>=0; i-- ) { F32 t = F32(i) / F32(numNewRings); t *= dt; t += mTimeSinceLastRing; SplashRing ring = createRing(); updateRing( ring, t ); ringList.pushBack( ring ); } }