예제 #1
0
 void minimum(const eVector4 &v)
 {
     x = eMin(x, v.x);
     y = eMin(y, v.y);
     z = eMin(z, v.z);
     w = eMin(w, v.w);
 }
예제 #2
0
void eProfilerZone::updateStats()
{
    eArray<eF32> &hist = m_stats.history;

    hist.append(getSelfTimeMs());
    while (hist.size() >= eProfilerZoneStats::MAX_SAMPLES)
        hist.removeAt(0);

    m_stats.max = hist[0];
    m_stats.min = hist[0];
    m_stats.mean = hist[0];

    for (eU32 k=1; k<hist.size(); k++)
    {
        const eF32 v = hist[k];
        m_stats.max = eMax(m_stats.max, v);
        m_stats.min = eMin(m_stats.min, v);
        m_stats.mean += v;
    }

    eASSERT(!hist.isEmpty());
    m_stats.mean /= (eF32)hist.size();

    eF32 var = 0.0f;
    for (eU32 k=1; k<hist.size(); k++)
        var += eSqr(hist[k]-m_stats.mean);

    m_stats.stdDev = (hist.size() > 1 ? eSqrt(var/(eF32)(hist.size()-1)) : 0.0f);
}
예제 #3
0
PCPtr getHalo(const ofVec3f& min, const ofVec3f& max, const float& haloSize, const PCPtr& cloudSrc)
{
	PCPtr trimmedCloud (new PC());
	vector<int> indices;
	ofVec3f vMin = min - haloSize;
	ofVec3f vMax = max + haloSize;

	Eigen::Vector4f eMax(vMax.x,vMax.y,vMax.z,1);
	Eigen::Vector4f eMin(vMin.x,vMin.y,vMin.z,1);
	
	pcl::getPointsInBox(*cloudSrc,eMin,eMax,indices);
			
	for(int i = 0; i < indices.size(); i++)
		trimmedCloud->push_back(cloudSrc->at(indices.at(i)));
	return trimmedCloud;
}
예제 #4
0
eBool eLight::activateScissor(const eSize &viewport, const eCamera &cam) const
{
    eRect rect(0, 0, viewport.x, viewport.y);
    const eVector3 viewPos = m_pos*cam.getViewMatrix();

    // negate z because original code was for OpenGL
    // (right-handed coordinate system, but DirectX
    // uses a left-handed one)
    const eVector3 l(viewPos.x, viewPos.y, -viewPos.z);
    const eVector3 ll(l.x*l.x, l.y*l.y, l.z*l.z);
    const eF32 r = m_range;
    const eF32 rr = r*r;
    const eF32 e0 = 1.2f;
    const eF32 e1 = 1.2f*cam.getAspectRatio();

    eF32 d = rr*ll.x-(ll.x+ll.z)*(rr-ll.z);
    if (d >= 0.0f)
    {
        d = eSqrt(d);

        const eF32 nx0 = (r*l.x +d)/(ll.x+ll.z);
        const eF32 nx1 = (r*l.x-d)/(ll.x+ll.z);
        const eF32 nz0 = (r-nx0*l.x)/l.z;
        const eF32 nz1 = (r-nx1*l.x)/l.z;
        const eF32 pz0 = (ll.x+ll.z-rr)/(l.z-(nz0/nx0)*l.x);
        const eF32 pz1 = (ll.x+ll.z-rr)/(l.z-(nz1/nx1)*l.x);

        if (pz0 < 0.0f)
        {
            const eF32 fx = nz0*e0/nx0;
            const eInt ix = eFtoL((fx+1.0f)*(eF32)viewport.x*0.5f);
            const eF32 px = -pz0*nz0/nx0;

            if (px < l.x)
                rect.x0 = eMax(rect.x0, ix);
            else
                rect.x1 = eMin(rect.x1, ix);
        }

        if (pz1 < 0.0f)
        {
            const eF32 fx = nz1*e0/nx1;
            const eInt ix = eFtoL((fx+1.0f)*(eF32)viewport.x*0.5f);
            const eF32 px = -pz1*nz1/nx1;

            if (px < l.x)
                rect.x0 = eMax(rect.x0, ix);
            else
                rect.x1 = eMin(rect.x1, ix);
        }
    }

    d = rr*ll.y-(ll.y+ll.z)*(rr-ll.z);
    if (d >= 0.0f)
    {
        d = eSqrt(d);

        const eF32 ny0 = (r*l.y +d)/(ll.y+ll.z);
        const eF32 ny1 = (r*l.y-d)/(ll.y+ll.z);
        const eF32 nz0 = (r-ny0*l.y)/l.z;
        const eF32 nz1 = (r-ny1*l.y)/l.z;
        const eF32 pz0 = (ll.y+ll.z-rr)/(l.z-(nz0/ny0)*l.y);
        const eF32 pz1 = (ll.y+ll.z-rr)/(l.z-(nz1/ny1)*l.y);

        if (pz0 < 0.0f)
        {
            const eF32 fy = nz0*e1/ny0;
            const eInt iy = eFtoL((fy+1.0f)*(eF32)viewport.y*0.5f);
            const eF32 py = -pz0*nz0/ny0;

            if (py < l.y)
                rect.y0 = eMax(rect.y0, iy);
            else
                rect.y1 = eMin(rect.y1, iy);
        }

        if (pz1 < 0.0f)
        {
            const eF32 fy = nz1*e1/ny1;
            const eInt iy = eFtoL((fy+1.0f)*(eF32)viewport.y*0.5f);
            const eF32 py = -pz1*nz1/ny1;

            if (py < l.y)
                rect.y0 = eMax(rect.y0, iy);
            else
                rect.y1 = eMin(rect.y1, iy);
        }
    }

    // finally check calculated rect and set if it's valid
    const eInt n = rect.getWidth()*rect.getHeight();
    if (n <= 0)
        return eFALSE;

    eRenderState &rs = eGfx->getRenderState();

    if (n == viewport.x*viewport.y || rect.x0 > rect.x1 || rect.y0 > rect.y1)
        rs.scissorTest = eFALSE;
    else
    {
        rs.scissorRect = eRect(rect.x0, viewport.y-rect.y1, rect.x1, viewport.y-rect.y0);
        rs.scissorTest = eTRUE;
    }

    return eTRUE;
}