void afxZodiacData::convertGradientRangeFromDegrees(Point2F& gradrange, const Point2F& gradrange_deg) { F32 x = mCos(mDegToRad(gradrange_deg.x)); F32 y = mCos(mDegToRad(gradrange_deg.y)); if (y > x) gradrange.set(x, y); else gradrange.set(y, x); }
TEST(Point2, SetMethods) { Point2F pt; pt.set(4.f, 2.f); EXPECT_FLOAT_EQ(4.f, pt.x); EXPECT_FLOAT_EQ(2.f, pt.y); auto lst = {0.f, 5.f}; pt.set(lst); EXPECT_FLOAT_EQ(0.f, pt.x); EXPECT_FLOAT_EQ(5.f, pt.y); pt.set(Point2F(9.f, 8.f)); EXPECT_FLOAT_EQ(9.f, pt.x); EXPECT_FLOAT_EQ(8.f, pt.y); }
void MaterialEditor::renderConnection(Connection* connection) { NVGcontext* vg = Link.Graphics.dglGetNVGContext(); if (vg) { Point2F mStart; Point2F mEnd; if ( connection->outputToMouse ) mEnd.set(lastMousePoint.x, lastMousePoint.y); else { Node* endNode = findNode(connection->inputNodeName); if ( !endNode || connection->inputIndex >= endNode->inputs.size() ) return; mEnd.set(endNode->inputs[connection->inputIndex].lastPosition.x, endNode->inputs[connection->inputIndex].lastPosition.y); } if ( connection->inputToMouse ) mStart.set(lastMousePoint.x, lastMousePoint.y); else { Node* startNode = findNode(connection->outputNodeName); if ( !startNode || connection->outputIndex >= startNode->outputs.size() ) return; mStart.set(startNode->outputs[connection->outputIndex].lastPosition.x, startNode->outputs[connection->outputIndex].lastPosition.y); } Point2F mControlPointA(mStart.x + 50, mStart.y); Point2F mControlPointB(mEnd.x - 50, mEnd.y); F32 diff = (mEnd.y - mStart.y) * 0.25f; mControlPointA.y -= diff; mControlPointB.y += diff; Link.NanoVG.nvgBeginPath(vg); Link.NanoVG.nvgMoveTo(vg, mStart.x, mStart.y); Link.NanoVG.nvgBezierTo(vg, mControlPointA.x, mControlPointA.y, mControlPointB.x, mControlPointB.y, mEnd.x, mEnd.y); Link.NanoVG.nvgStrokeColor(vg, Link.NanoVG.nvgRGBA(255, 255, 255, 200)); Link.NanoVG.nvgStrokeWidth(vg, 5.0f); Link.NanoVG.nvgStroke(vg); } }
void PSSMLightShadowMap::setShaderParameters(GFXShaderConstBuffer* params, LightingShaderConstants* lsc) { PROFILE_SCOPE( PSSMLightShadowMap_setShaderParameters ); AssertFatal(mNumSplits > 0 && mNumSplits <= MAX_SPLITS, avar("PSSMLightShadowMap::_setNumSplits() - Splits must be between 1 and %d!", MAX_SPLITS)); if ( lsc->mTapRotationTexSC->isValid() ) GFX->setTexture( lsc->mTapRotationTexSC->getSamplerRegister(), SHADOWMGR->getTapRotationTex() ); const ShadowMapParams *p = mLight->getExtended<ShadowMapParams>(); Point4F sx(Point4F::Zero), sy(Point4F::Zero), ox(Point4F::Zero), oy(Point4F::Zero), aXOff(Point4F::Zero), aYOff(Point4F::Zero); for (U32 i = 0; i < mNumSplits; i++) { sx[i] = mScaleProj[i].x; sy[i] = mScaleProj[i].y; ox[i] = mOffsetProj[i].x; oy[i] = mOffsetProj[i].y; } Point2F shadowMapAtlas; if (mNumSplits < 4) { shadowMapAtlas.x = 1.0f / (F32)mNumSplits; shadowMapAtlas.y = 1.0f; // 1xmNumSplits for (U32 i = 0; i < mNumSplits; i++) aXOff[i] = (F32)i * shadowMapAtlas.x; } else { shadowMapAtlas.set(0.5f, 0.5f); // 2x2 for (U32 i = 0; i < mNumSplits; i++) { if (i == 1 || i == 3) aXOff[i] = 0.5f; if (i > 1) aYOff[i] = 0.5f; } } params->setSafe(lsc->mScaleXSC, sx); params->setSafe(lsc->mScaleYSC, sy); params->setSafe(lsc->mOffsetXSC, ox); params->setSafe(lsc->mOffsetYSC, oy); params->setSafe(lsc->mAtlasXOffsetSC, aXOff); params->setSafe(lsc->mAtlasYOffsetSC, aYOff); params->setSafe(lsc->mAtlasScaleSC, shadowMapAtlas); Point4F lightParams( mLight->getRange().x, p->overDarkFactor.x, 0.0f, 0.0f ); params->setSafe( lsc->mLightParamsSC, lightParams ); params->setSafe( lsc->mFarPlaneScalePSSM, mFarPlaneScalePSSM); Point2F fadeStartLength(p->fadeStartDist, 0.0f); if (fadeStartLength.x == 0.0f) { // By default, lets fade the last half of the last split. fadeStartLength.x = (mSplitDist[mNumSplits-1] + mSplitDist[mNumSplits]) / 2.0f; } fadeStartLength.y = 1.0f / (mSplitDist[mNumSplits] - fadeStartLength.x); params->setSafe( lsc->mFadeStartLength, fadeStartLength); params->setSafe( lsc->mOverDarkFactorPSSM, p->overDarkFactor); // The softness is a factor of the texel size. params->setSafe( lsc->mShadowSoftnessConst, p->shadowSoftness * ( 1.0f / mTexSize ) ); }
//----------------------------------------------------------------------------- // texCoord //----------------------------------------------------------------------------- void texCoord2f( F32 x, F32 y ) { mCurTexCoord.set( x, y ); }