Example #1
0
/**
 * \return List of bezier spline segments which together represent this curve.
 */
QList<RSpline> RSpline::getBezierSegments() const {
    // spline is a single bezier segment:
    if (countControlPoints()==getDegree()+1) {
        return QList<RSpline>() << *this;
    }

    updateInternal();

    QList<RSpline> ret;
#ifndef R_NO_OPENNURBS
    ON_NurbsCurve* dup = dynamic_cast<ON_NurbsCurve*>(curve.DuplicateCurve());
    if (dup==NULL) {
        return ret;
    }

    dup->MakePiecewiseBezier();
    for (int i=0; i<=dup->CVCount() - dup->Order(); ++i) {
        ON_BezierCurve bc;
        if (!dup->ConvertSpanToBezier(i, bc)) {
            continue;
        }

        QList<RVector> ctrlPts;
        for (int cpi=0; cpi<bc.CVCount(); cpi++) {
            ON_3dPoint onp;
            bc.GetCV(cpi, onp);
            ctrlPts.append(RVector(onp.x, onp.y, onp.z));
        }
        ret.append(RSpline(ctrlPts, degree));
    }
    delete dup;
 #endif

    return ret;
}
Example #2
0
/**
 * Reset time varying state vars and recompute decay.
 */
void ISynapse::reset() {
	psr = 0.0;
	assert( updateInternal() );
	u = DEFAULT_U;
	r = 1.0;
	lastSpike = ULONG_MAX;
}
Example #3
0
QList<RVector> RSpline::getDiscontinuities() const {
    updateInternal();

    QList<RVector> ret;

#ifndef R_NO_OPENNURBS
    if (isValid()) {
        for (int c=0; c<=11; c++) {
            double t0=getTMin();
            double t1=getTMax();
            bool found;
            do {
                double t;
                found = curve.GetNextDiscontinuity((ON::continuity)c, t0, t1, &t);
                if (found) {
                    ret.append(getPointAt(t));
                    t0=t;
                }
            } while(found);
        }
    }
#endif

    return ret;
}
Example #4
0
bool PartEmitter::update() {
	if (!_running) {
		return STATUS_OK;
	} else {
		return updateInternal(BaseEngine::getTimer()->getTime(), BaseEngine::getTimer()->getTimeDelta());
	}
}
Example #5
0
/**
 * \return List of RLines describing this spline.
 */
QList<QSharedPointer<RShape> > RSpline::getExploded(int segments) const {
    if (!exploded.isEmpty() && segments==-1) {
        return exploded;
    }

    //qDebug() << "RSpline::getExploded: segments: " << segments;
    //RDebug::printBacktrace("getExploded:    ");

    //##boundingBox = RBox();

    updateInternal();

    exploded.clear();

    if (!isValid()) {
        //qWarning() << "RSpline::getExploded: invalid spline";
        return exploded;
    }

    if (segments==-1) {
        segments = 8;
    }

    double tMin = getTMin();
    double tMax = getTMax();

    double step = getTDelta() / (controlPoints.size() * segments);

    RVector p1;
    RVector prev = RVector::invalid;
    for (double t = tMin; t<tMax+(step/2.0); t+=step) {
        double tc = qMin(t, tMax);
        p1 = getPointAt(tc);

        if (RMath::isNaN(p1.x) || RMath::isNaN(p1.y)) {
            continue;
        }

        if (prev.isValid()) {
            RLine* line = new RLine(prev, p1);
            exploded.append(QSharedPointer<RShape>(line));
        }
        prev = p1;

        //##boundingBox.growToInclude(p1);
    }

    p1 = getEndPoint();
    if (!RMath::isNaN(p1.x) && !RMath::isNaN(p1.y)) {
        if (prev.isValid()) {
            RLine* line = new RLine(prev, p1);
            // prevent zero length line at the end:
            if (line->getLength()>1.0e-4) {
                exploded.append(QSharedPointer<RShape>(line));
            }
        }
    }

    return exploded;
}
Example #6
0
void TUIManager<T>::update()
{
    PROFILE_ENTRY("UI System");

    {
        PROFILE_ENTRY("UpdateUI");
        updateInternal( mRoot.mChild );
    }
}
Example #7
0
void TUIManager<T>::updateInternal( TUICore<T>* ui )
{
    while ( ui )
    {
        if ( ui->isEnable() )
            ui->update();

        updateInternal( ui->getChild() );
        ui = ui->mNext;
    }
}
Example #8
0
double RSpline::getTMax() const {
    updateInternal();

    if (isValid()) {
#ifndef R_NO_OPENNURBS
        return curve.Domain().Max();
#endif
    }

    return 0.0;
}
Example #9
0
QList<double> RSpline::getActualKnotVector() const {
#ifndef R_NO_OPENNURBS
    updateInternal();
    QList<double> ret;
    for (int i=0; i<curve.KnotCount(); ++i) {
        ret.append(curve.Knot(i));
    }
    return ret;
#else
    return QList<double>();
#endif
}
Example #10
0
/**
 * \return Point on spline at given position t (0..1).
 */
RVector RSpline::getPointAt(double t) const {
    updateInternal();
#ifndef R_NO_OPENNURBS
    ON_3dPoint p = curve.PointAt(t);
    if (p.IsUnsetPoint()) {
        return RVector::invalid;
    }
    return RVector(p.x, p.y);
#else
    return RVector::invalid;
#endif
}
Example #11
0
/**
 * \return Tangent angle of spline at end point.
 */
double RSpline::getDirection2() const {
    if (!isValid()) {
        return 0.0;
    }
    updateInternal();

#ifndef R_NO_OPENNURBS
    ON_3dVector ontan = curve.TangentAt(getTMax());
    RVector rtan(ontan.x, ontan.y);
    return RMath::getNormalizedAngle(rtan.getAngle() + M_PI);
#else
    return 0.0;
#endif
}
Example #12
0
/**
 * \return Control points of internal spline representation (may be closed).
 */
QList<RVector> RSpline::getControlPointsWrapped() const {
    QList<RVector> ret;

    updateInternal();

#ifndef R_NO_OPENNURBS
    ON_3dPoint onp;
    for (int i=0; i<curve.CVCount(); ++i) {
        curve.GetCV(i, onp);
        ret.append(RVector(onp.x, onp.y));
    }
#endif

    return ret;
}
Example #13
0
void WindowingSystem::update(Time dt) {
    auto topLevelWidget = getTopLevelWidget();
    topLevelWidget->updateInternal();

    // if it's clean, mark it dirty
    drawContext.vbo->changeState(VBOs::Clean, VBOs::Dirty);

    // if it's dirty (explicitly, or because we just moved it from clean), start updating
    if (drawContext.vbo->changeState(VBOs::Dirty, VBOs::Updating)) {
        drawContext.vbo->clear();

        drawContext.revision++;
        topLevelWidget->draw(drawContext);

        posit(drawContext.vbo->changeState(VBOs::Updating, VBOs::Updated), "Could not move windowing vbo to updated");
    }
}
Example #14
0
/** Sets a parameter of the algorithm.
    \param name Name of the parameter.
    \param value Value to set for the parameter. */
void Algorithm::setParameter(string name, double value) {
  map<string, double*>::iterator p;

  // Look if this is a valid parameter
  p = params.find(name);
  if (p != params.end()) {
    // Set the parameter
    double* dest = p->second;
    *dest = value;

    // Update internal state of the filter
    updateInternal();
  }
  else {
    // Error
    TheCsimError.add("Algorithm::setParameter: Unrecognized parameter %s!\n", name.c_str());
  }
}
Example #15
0
void RSpline::copySpline(const RSpline& other) {
    this->degree = other.degree;
    this->periodic = other.periodic;
    this->controlPoints = other.controlPoints;
    this->fitPoints = other.fitPoints;
    this->knotVector = other.knotVector;
    this->weights = other.weights;
    this->tangentStart = other.tangentStart;
    this->tangentEnd = other.tangentEnd;
    this->boundingBox = other.boundingBox;
    bool d = other.dirty;

    // do NOT copy curve member (copying of ON_NurbsCurve is broken, segfaults).
    dirty = true;
    updateInternal();

    // if original was not dirty, copy cached exploded representation:
    if (!d) {
        this->exploded = other.exploded;
    }
}
Example #16
0
//==============================================================================
void Frustum::resetTransform(const Transform& trf)
{
	m_trf = trf;

	if(m_frustumDirty)
	{
		// Update everything
		updateInternal();
	}
	else
	{
		// Inform the child about the change
		onTransform();

		// Transform the planes
		for(U i = 0; i < m_planesL.getSize(); ++i)
		{
			m_planesW[i] = m_planesL[i].getTransformed(m_trf);
		}
	}
}
Example #17
0
bool PartEmitter::start() {
	for (uint32 i = 0; i < _particles.size(); i++) {
		_particles[i]->_isDead = true;
	}
	_running = true;
	_batchesGenerated = 0;


	if (_overheadTime > 0) {
		uint32 delta = 500;
		int steps = _overheadTime / delta;
		uint32 currentTime = BaseEngine::getTimer()->getTime() - _overheadTime;

		for (int i = 0; i < steps; i++) {
			updateInternal(currentTime, delta);
			currentTime += delta;
		}
		_overheadTime = 0;
	}

	return STATUS_OK;
}
Example #18
0
void StateMachineApp::update() {
    updateInternal();

    if(currentState)
        currentState->update();
}
void SelectionMarkerController::onMarkerMoveEnd()
{
    updateInternal();
}