void VehicleManagerDemo::buildLandscape() { if (1) { // // Create the ground we'll drive on. // { hkpRigidBodyCinfo groundInfo; // // Set the if condition to 0 if you want to test the heightfield // if ( 1 ) { FlatLand* fl = new FlatLand(); m_track = fl; groundInfo.m_shape = fl->createMoppShapeForSpu(); groundInfo.m_position.set(5.0f, -2.0f, 5.0f); groundInfo.m_collisionFilterInfo = hkpGroupFilter::calcFilterInfo( GROUND_LAYER, 0 ); } { groundInfo.m_motionType = hkpMotion::MOTION_FIXED; groundInfo.m_friction = 0.5f; hkpRigidBody* groundbody = new hkpRigidBody(groundInfo); m_world->addEntity(groundbody); groundbody->removeReference(); } groundInfo.m_shape->removeReference(); } } if (1) { hkVector4 halfExtents(10.0f, 0.1f, 10.0f); hkVector4 startPos(-240.0f, -7.8f, 0.0f); hkVector4 diffPos (30.0f, 0.0f, 0.0f); createDodgeBoxes(5, halfExtents, startPos, diffPos); } if (1) { hkVector4 halfExtents(10.0f, 0.05f, 10.0f); hkVector4 startPos(-240.0f, -7.85f, 30.0f); hkVector4 diffPos (30.0f, 0.0f, 0.0f); createDodgeBoxes(5, halfExtents, startPos, diffPos); } if (1) { int gridSize = 1 + int(hkMath::sqrt( hkReal(m_env->m_cpuMhz/100) )); createRagdollGrid( m_world, gridSize, gridSize, 4.0f, 4.0f, m_ragdolls ); } }
QList<QPointF> QLogicCircuitShapeConnector::defaultConnector() const { QList<QPointF> points; QList<QPointF> sections; QLineF line(startPos(), endPos()); QLineF lineEnd; QLineF lineStart; line = QLineF(startPos(), endPos()); lineStart.setP1(startPos()); lineEnd.setP1(endPos()); switch(orientationAtStart()){ case QDiagramToolkit::East: if (line.dx() < 20){ lineStart.setP2(startPos() + QPointF(20, 0)); lineEnd.setP2(lineEnd.p1() - QPointF(20, 0)); sections << QPointF(lineStart.p2().x(), lineStart.p1().y() + line.dy() / 2) << QPointF(lineEnd.p2().x(), lineEnd.p2().y() - line.dy() / 2); } else { lineStart.setP2(lineStart.p1() + QPointF(line.dx() / 2 , 0)); lineEnd.setP2(QPointF(lineStart.p2().x(), lineEnd.p1().y())); } break; case QDiagramToolkit::West: if (line.dx() > -20){ lineStart.setP2(startPos() - QPointF(20, 0)); lineEnd.setP2(lineEnd.p1() + QPointF(20, 0)); sections << QPointF(lineStart.p2().x(), lineStart.p1().y() + line.dy() / 2) << QPointF(lineEnd.p2().x(), lineEnd.p2().y() - line.dy() / 2); } else { lineStart.setP2(lineStart.p1() + QPointF(line.dx() / 2 , 0)); lineEnd.setP2(QPointF(lineStart.p2().x(), lineEnd.p1().y())); } break; default: break; } points.append(lineStart.p1()); points.append(lineStart.p2()); QListIterator<QPointF> it(sections); while(it.hasNext()){ points.append(it.next()); } points.append(lineEnd.p2()); points.append(lineEnd.p1()); return points; }
/////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Split several parts of a string // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// void dataHandlerDateTimeBase::split(const std::wstring& timeString, const std::wstring& separators, std::vector<std::wstring> *pComponents) const { PUNTOEXE_FUNCTION_START(L"dataHandlerDateTimeBase::split"); if(timeString.empty()) { return; } for(size_t startPos(0), sepPos(timeString.find_first_of(separators)); /* empty */; sepPos = timeString.find_first_of(separators, startPos)) { if(sepPos == timeString.npos) { pComponents->push_back(timeString.substr(startPos)); break; } pComponents->push_back(timeString.substr(startPos, sepPos - startPos)); startPos = ++sepPos; if(startPos == timeString.size()) { pComponents->push_back(L""); break; } } PUNTOEXE_FUNCTION_END(); }
bool NavGrid::FindPath(const CU::Vector3f& aStartPoint, const CU::Vector3f& aEndPoint, CU::GrowingArray<CU::Vector2f>& aOutPath) { CU::Vector2i startPos(static_cast<int>(aStartPoint.x), static_cast<int>(aStartPoint.z)); CU::Vector2i endPos(static_cast<int>(aEndPoint.x), static_cast<int>(aEndPoint.z)); return FindPath(startPos, endPos, aOutPath); }
void GridEmitter::update( double relative_time, ParticleArray *particles ) { // Saving up particles until there are enough saved up to emit in the grid: const double possible_particles = (relative_time - last_emit_time) * p_rate + left_over; if ( possible_particles >= p_N && (particles->getMaxLength() - particles->getLength()) >= p_N ) { // Set the last emit time, and compensate for the "residue particle(s)". last_emit_time = relative_time - ( possible_particles - p_N ) / p_rate; left_over = 0; // Emit: for ( int p = 0; p < p_N; p++ ) { const Vector2d pos = startPos( p ); const Vector2d vel = startVel( p ); if ( channel->outsideBox( pos ) == P_INSIDE ) particles->add( Particle( pos, vel ) ); else left_over++; } } }
QPainterPath Connection::path(bool only_bezier) const { QPointF start = startPos(); QPointF end = endPos(); float length = 50; if (end.x() <= start.x()) { length += (start.x() - end.x()) / 2; } QPainterPath p; p.moveTo(start); if (only_bezier) p.moveTo(start + QPointF(15, 0)); else p.lineTo(start + QPointF(15, 0)); p.cubicTo(QPointF(start.x() + length, start.y()), QPointF(end.x() - length, end.y()), QPointF(end.x() - 15, end.y())); if (!only_bezier) p.lineTo(end); return p; }
/* ------------------------------------------------------------------------------- Class: CStifSectionParser Method: GetNextItemLineL Description: Parses a next line for items parsing with a tag. If start tag is empty the parsing starts beging of the section. Parameters: const TDesC& aTag: in: Indicates parsing start point TTagToReturnValue aTagIndicator: in: Will aTag included to the returned object(For default the tag will be added) Return Values: CStifItemParser* : pointer to CStifItemParser object NULL will return if iLineIndicator is false NULL will return if ParseStartAndEndPos() method returns -1 NULL will return if length is 0 or negative NULL will return if iStartPos is 0 Errors/Exceptions: Leaves if called CStifItemParser::NewL method fails Status: Approved ------------------------------------------------------------------------------- */ EXPORT_C CStifItemParser* CStifSectionParser::GetNextItemLineL( const TDesC& aTag, TTagToReturnValue aTagIndicator ) { // GetLine() or GetItemLineL() method is not called if ( !iLineIndicator ) { __TRACE( KInfo, ( _L( "STIFPARSER: GetNextItemLineL method returns a NULL" ) ) ); return NULL; } TInt startPos( 0 ); TInt endPos( 0 ); TInt length( 0 ); TInt ret = ParseStartAndEndPos( iSection, aTag, aTagIndicator, startPos, endPos, length ); // No parsing found if ( KErrNone != ret || length <= 0 || startPos < 0 ) { __TRACE( KInfo, ( _L( "STIFPARSER: GetNextItemLineL method returns a NULL" ) ) ); return NULL; } CStifItemParser* line = CStifItemParser::NewL( iSection, startPos, length ); return line; }
void KexiAnimatedLayout::Private::animateTo(QWidget* destination) { QWidget *from = q->currentWidget(); Q_ASSERT(destination && from); destinationWidget = destination; if (from == destinationWidget) return; if (!(KexiUtils::graphicEffectsLevel() & KexiUtils::SimpleAnimationEffects)) { // animations not allowed: switch to destination widget immediately animationFinished(); return; } bool toRight = q->currentIndex() < q->indexOf(destinationWidget); hide(); setParent(from); QSize s(from->parentWidget()->size()); QPoint startPos(toRight ? QPoint(0, 0) : QPoint(s.width(), 0)); QPoint endPos(toRight ? QPoint(s.width(), 0) : QPoint(0, 0)); animation.setStartValue(-startPos); animation.setEndValue(-endPos); buffer = QPixmap(s.width() * 2, s.height()); buffer.fill(Qt::white); from->render(&buffer, startPos); //qDebug() << s << from->geometry() << destinationWidget->geometry(); destinationWidget->resize(from->size()); // needed because destination could // have been never displayed destinationWidget->render(&buffer, endPos); resize(buffer.size()); move(animation.startValue().toPoint().x(), animation.startValue().toPoint().y()); show(); animation.start(); }
/* ------------------------------------------------------------------------------- Class: CStifSectionParser Method: GetNextLine Description: Get a line Search an item from the section and return rest of the line. Parameters: TPtr& aLine: inout: Parsed line Return Values: TInt: Error code Errors/Exceptions: None Status: Approved ------------------------------------------------------------------------------- */ EXPORT_C TInt CStifSectionParser::GetNextLine( TPtrC& aLine ) { TInt ret( KErrNone ); // GetLine() or GetItemLineL() method is not called if ( !iLineIndicator ) { return KErrNotReady; } TInt startPos( 0 ); TInt endPos( 0 ); TInt length( 0 ); // tagIndicator has no meaning in this method TTagToReturnValue tagIndicator( ETag ); ret = ParseStartAndEndPos( iSection, KNullDesC, tagIndicator, startPos, endPos, length ); if ( KErrNone != ret ) { // Nothing to parse return ret; } aLine.Set( &iSection[startPos], length ); return KErrNone; }
void AbstractClipItem::resizeEnd(int posx, bool /*emitChange*/) { GenTime durationDiff = GenTime(posx, m_fps) - endPos(); if (durationDiff == GenTime()) return; if (cropDuration() + durationDiff <= GenTime()) { durationDiff = GenTime() - (cropDuration() - GenTime(3, m_fps)); } m_info.cropDuration += durationDiff; m_info.endPos += durationDiff; setRect(0, 0, cropDuration().frames(m_fps) - 0.02, rect().height()); if (durationDiff > GenTime()) { QList <QGraphicsItem *> collisionList = collidingItems(Qt::IntersectsItemBoundingRect); bool fixItem = false; for (int i = 0; i < collisionList.size(); ++i) { if (!collisionList.at(i)->isEnabled()) continue; QGraphicsItem *item = collisionList.at(i); if (item->type() == type() && item->pos().x() > pos().x()) { GenTime diff = static_cast<AbstractClipItem*>(item)->startPos() - startPos(); if (fixItem == false || diff < m_info.cropDuration) { fixItem = true; m_info.cropDuration = diff; } } } if (fixItem) setRect(0, 0, cropDuration().frames(m_fps) - 0.02, rect().height()); } }
/* ------------------------------------------------------------------------------- Class: CStifSectionParser Method: GetLine Description: Get a line. Search an item from the section and return rest of the line. If start tag is empty the parsing starts beging of the section. Parameters: const TDesC& aTag: in: Indicates parsing start point TPtr& aLine: inout: Parsed line TTagToReturnValue aTagIndicator: in: Will aTag included to the returned value(For default the tag will be added) Return Values: TInt: Error code Errors/Exceptions: None Status: Approved ------------------------------------------------------------------------------- */ EXPORT_C TInt CStifSectionParser::GetLine( const TDesC& aTag, TPtrC& aLine, TTagToReturnValue aTagIndicator ) { TInt ret( KErrNone ); if ( 0 == iSection.Length() ) { return KErrNotFound; } // Indicator that GetLine has been used iLineIndicator = ETrue; TInt startPos( 0 ); TInt endPos( 0 ); TInt length( 0 ); iSkipAndMarkPos = 0; ret = ParseStartAndEndPos( iSection, aTag, aTagIndicator, startPos, endPos, length ); if ( KErrNone != ret ) { // Nothing to parse return ret; } aLine.Set( &iSection[startPos], length ); return KErrNone; }
EmpirePricesWindow::EmpirePricesWindow(Widget *parent, int id, const Rect &rectangle, PlayerCityPtr city) : Window( parent, rectangle, "", id ) { setupUI( ":/gui/empireprices.gui" ); city::TradeOptions& ctrade = city->tradeOptions(); Font font = Font::create( FONT_1 ); Point startPos( 140, 50 ); for( int i=Good::wheat; i < Good::prettyWine; i++ ) { if( i == Good::fish || i == Good::denaries) { continue; } Good::Type gtype = (Good::Type)i; Picture goodIcon = GoodHelper::picture( gtype ); new Image( this, startPos, goodIcon ); std::string priceStr = StringHelper::format( 0xff, "%d", ctrade.buyPrice( gtype ) ); Label* lb = new Label( this, Rect( startPos + Point( 0, 34 ), Size( 24, 24 ) ), priceStr ); lb->setFont( font ); priceStr = StringHelper::format( 0xff, "%d", ctrade.sellPrice( gtype ) ); lb = new Label( this, Rect( startPos + Point( 0, 58 ), Size( 24, 24 ) ), priceStr ); lb->setFont( font ); startPos += Point( 30, 0 ); } }
/* ------------------------------------------------------------------------------- Class: CStifSectionParser Method: GetItemLineL Description: Parses a line for items parsing. If start tag is empty the parsing starts beging of the section. Parameters: const TDesC& aTag: in: Indicates parsing start point. TTagToReturnValue aTagIndicator: in: Will aTag included to the returned object(For default the tag will be added) Return Values: CStifItemParser* : pointer to CStifItemParser object NULL will return if ParseStartAndEndPos() method returns -1 NULL will return if length is 0 or negative NULL will return if iStartPos is 0 Errors/Exceptions: Leaves if called CStifItemParser::NewL method fails Status: Approved ------------------------------------------------------------------------------- */ EXPORT_C CStifItemParser* CStifSectionParser::GetItemLineL( const TDesC& aTag, TTagToReturnValue aTagIndicator ) { TInt startPos( 0 ); TInt endPos( 0 ); TInt length( 0 ); // Indicator that GetItemLineL has been used iLineIndicator = ETrue; iSkipAndMarkPos = 0; TInt ret = ParseStartAndEndPos( iSection, aTag, aTagIndicator, startPos, endPos, length ); // No parsing found if ( KErrNone != ret || length <= 0 || startPos < 0 ) { __TRACE( KInfo, ( _L( "STIFPARSER: GetItemLineL method returns a NULL" ) ) ); return NULL; } CStifItemParser* line = CStifItemParser::NewL( iSection, startPos, length ); return line; }
float SCurveData::GetCurveValue(float fProgress, float fStartTime, float fEndTime, const SCurveKey* pStartKey, const SCurveKey* pEndKey) const { BEATS_ASSERT(BEATS_FLOAT_GREATER_EQUAL_EPSILON(fProgress, fStartTime, 0.001f) && BEATS_FLOAT_LESS_EQUAL_EPSILON(fProgress, fEndTime, 0.001f)); BEATS_ASSERT(BEATS_FLOAT_GREATER_EQUAL_EPSILON(fStartTime, 0, 0.001f) && BEATS_FLOAT_LESS_EQUAL_EPSILON(fEndTime, 1.0f, 0.001f)); static const float UNITY_YX_RATE = 0.625f; // The curve value depends on the coordinate rate: height / width CVec2 startPos(fStartTime, pStartKey->m_fValue * UNITY_YX_RATE); CVec2 endPos(fEndTime, pEndKey->m_fValue * UNITY_YX_RATE); static const float UNITY_MAGIC_FACTOR = 0.333333f; float tangLengthX = fabs(fStartTime - fEndTime) * UNITY_MAGIC_FACTOR; float tangLengthY = tangLengthX; float tgOut = pStartKey->m_fOutSlope * UNITY_YX_RATE; float tgIn = pEndKey->m_fInSlope * UNITY_YX_RATE; CVec2 startCtrlPos = startPos; CVec2 endCtrlPos = endPos; startCtrlPos.X() += tangLengthX; startCtrlPos.Y() += tangLengthY * tgOut; endCtrlPos.X() -= tangLengthX; endCtrlPos.Y() -= tangLengthY * tgIn; float s = (fProgress - fStartTime) / (fEndTime - fStartTime); float s2 = s * s; float s3 = s2 * s; float h1 = -s3 + 3 * s2 - 3 * s + 1; float h2 = s3; float h3 = 3 * s3 - 6 * s2 + 3 * s; float h4 = -3 * s3 + 3 * s2; CVec2 ret = startPos * h1 + endPos * h2 + startCtrlPos * h3 + endCtrlPos * h4; BEATS_ASSERT(fabs(fProgress - ret.X()) < 0.0001f); return ret.Y() / UNITY_YX_RATE; }
void MainWindow::expand() { // qDebug() << "expand"; const QPoint finishPos(0, 0); if (m_mainPanel->pos() == finishPos && m_mainPanel->size() == this->size()) return; resetPanelEnvironment(true); if (m_panelShowAni->state() == QPropertyAnimation::Running) return m_panelShowAni->setEndValue(finishPos); const QSize size = m_settings->windowSize(); QPoint startPos(0, 0); switch (m_settings->position()) { case Top: startPos.setY(-size.height()); break; case Bottom: startPos.setY(size.height()); break; case Left: startPos.setX(-size.width()); break; case Right: startPos.setX(size.width()); break; } m_panelHideAni->stop(); m_panelShowAni->setStartValue(startPos); m_panelShowAni->setEndValue(finishPos); m_panelShowAni->start(); }
void AbstractClipItem::resizeEnd(int posx, bool /*emitChange*/) { GenTime durationDiff = GenTime(posx, m_fps) - endPos(); if (durationDiff == GenTime()) return; if (cropDuration() + durationDiff <= GenTime()) { durationDiff = GenTime() - (cropDuration() - GenTime(3, m_fps)); } m_info.cropDuration += durationDiff; m_info.endPos += durationDiff; setRect(0, 0, cropDuration().frames(m_fps) - 0.02, rect().height()); if (durationDiff > GenTime()) { QList <QGraphicsItem *> collisionList = collidingItems(Qt::IntersectsItemBoundingRect); bool fixItem = false; for (int i = 0; i < collisionList.size(); ++i) { if (!collisionList.at(i)->isEnabled()) continue; QGraphicsItem *item = collisionList.at(i); if (item->type() == type() && item->pos().x() > pos().x()) { //kDebug() << "///////// COLLISION DETECTED!!!!!!!!!"; //kDebug() << "///////// CURRENT: " << startPos().frames(25) << "x" << endPos().frames(25) << ", RECT: " << rect() << "-" << pos(); //kDebug() << "///////// COLLISION: " << ((AbstractClipItem *)item)->startPos().frames(25) << "x" << ((AbstractClipItem *)item)->endPos().frames(25) << ", RECT: " << ((AbstractClipItem *)item)->rect() << "-" << item->pos(); GenTime diff = ((AbstractClipItem *)item)->startPos() - startPos(); if (fixItem == false || diff < m_info.cropDuration) { fixItem = true; m_info.cropDuration = diff; } } } if (fixItem) setRect(0, 0, cropDuration().frames(m_fps) - 0.02, rect().height()); } }
/* ------------------------------------------------------------------------------- Class: CStifSectionParser Method: GetNextLine Description: Get a line with tag Search a next line with the required tag from the section. If start tag is empty the parsing starts beging of the section. Parameters: const TDesC& aTag: in: Indicates parsing start point TPtr& aLine: inout: Parsed line TTagToReturnValue aTagIndicator: in: Will aTag included to the returned value(For default the tag will be added) Return Values: TInt: Error code Errors/Exceptions: None Status: Approved ------------------------------------------------------------------------------- */ EXPORT_C TInt CStifSectionParser::GetNextLine( const TDesC& aTag, TPtrC& aLine, TTagToReturnValue aTagIndicator ) { TInt ret( KErrNone ); // GetLine() or GetItemLineL() method is not called if ( !iLineIndicator ) { return KErrNotReady; } TInt startPos( 0 ); TInt endPos( 0 ); TInt length( 0 ); ret = ParseStartAndEndPos( iSection, aTag, aTagIndicator, startPos, endPos, length ); if ( KErrNone != ret ) { // Nothing to parse return ret; } aLine.Set( &iSection[startPos], length ); return KErrNone; }
void TCellKeyframeSelection::copyCellsKeyframes() { TCellKeyframeData *data = new TCellKeyframeData(); // Copy cells int r0, c0, r1, c1; m_cellSelection->getSelectedCells(r0, c0, r1, c1); if (!isEmpty()) { int colCount = c1 - c0 + 1; int rowCount = r1 - r0 + 1; if (colCount <= 0 || rowCount <= 0) return; TXsheet *xsh = m_xsheetHandle->getXsheet(); TCellData *cellData = new TCellData(); cellData->setCells(xsh, r0, c0, r1, c1); data->setCellData(cellData); } // Copy keyframes if (!isEmpty()) { QClipboard *clipboard = QApplication::clipboard(); TXsheet *xsh = m_xsheetHandle->getXsheet(); TKeyframeData *keyframeData = new TKeyframeData(); TKeyframeData::Position startPos(r0, c0); keyframeData->setKeyframes(m_keyframeSelection->getSelection(), xsh, startPos); data->setKeyframeData(keyframeData); } // Set the cliboard QClipboard *clipboard = QApplication::clipboard(); clipboard->setMimeData(data, QClipboard::Clipboard); }
QRectF TOPPASEdge::boundingRect() const { qreal min_x = startPos().x() < endPos().x() ? startPos().x() : endPos().x(); qreal min_y = startPos().y() < endPos().y() ? startPos().y() : endPos().y(); qreal max_x = startPos().x() > endPos().x() ? startPos().x() : endPos().x(); qreal max_y = startPos().y() > endPos().y() ? startPos().y() : endPos().y(); return QRectF(QPointF(min_x - 11.0, min_y - 11.0), QPointF(max_x + 11.0, max_y + 11.0)); }
/**************************************************************** * Generate Maze ****************************************************************/ void PhotoMaze :: huntAndKill(){ Vec2D<int> startPos((int)(ofRandom(1)*rw), (int)(ofRandom(1)*rh)); while (startPos.x != -1) { rWalk(startPos); startPos = hunt(); } fillImage(); }
bool gkRecast::findPath(PDT_NAV_MESH navMesh, const gkVector3& from, const gkVector3& to, const gkVector3& polyPickExt, int maxPathPolys, PATH_POINTS& path, unsigned short includeFlags, unsigned short excludeFlags) { GK_ASSERT(!(includeFlags & excludeFlags) && "includeFlags with excludeFlags cannot overlap"); if (navMesh.get() && navMesh->m_p) { gkVector3 startPos(from); gkVector3 endPos(to); std::swap(startPos.y, startPos.z); std::swap(endPos.y, endPos.z); dtQueryFilter filter; filter.includeFlags = includeFlags; filter.excludeFlags = excludeFlags; dtPolyRef startRef = navMesh->m_p->findNearestPoly(startPos.ptr(), polyPickExt.ptr(), &filter, 0); dtPolyRef endRef = navMesh->m_p->findNearestPoly(endPos.ptr(), polyPickExt.ptr(), &filter, 0); if (startRef && endRef) { utArray<dtPolyRef> polys; polys.resize(maxPathPolys); int npolys = navMesh->m_p->findPath(startRef, endRef, startPos.ptr(), endPos.ptr(), &filter, polys.ptr(), maxPathPolys); if (npolys > 1) { path.clear(); utArray<gkScalar> straightPath; straightPath.resize(maxPathPolys * 3); int nstraightPath = navMesh->m_p->findStraightPath(startPos.ptr(), endPos.ptr(), polys.ptr(), npolys, straightPath.ptr(), 0, 0, maxPathPolys); std::swap(startPos.y, startPos.z); std::swap(endPos.y, endPos.z); gkVector3 point; for (int i = 0; i < nstraightPath * 3; i += 3) { point.x = straightPath[i]; point.y = straightPath[i+2]; point.z = straightPath[i+1]; path.push_back(point); } return true; } } } return false; }
QPainterPath TOPPASEdge::shape() const { QPainterPath shape_1; shape_1.moveTo(startPos() + QPointF(-10, -10)); shape_1.lineTo(endPos() + QPointF(-10, -10)); shape_1.lineTo(endPos() + QPointF(10, 10)); shape_1.lineTo(startPos() + QPointF(10, 10)); shape_1.closeSubpath(); QPainterPath shape_2; shape_2.moveTo(startPos() + QPointF(-10, 10)); shape_2.lineTo(endPos() + QPointF(-10, 10)); shape_2.lineTo(endPos() + QPointF(10, -10)); shape_2.lineTo(startPos() + QPointF(10, -10)); shape_2.closeSubpath(); return shape_1.united(shape_2); }
float POVRayParser::ParseFloat(std::string& token) { std::string startChars("-.0123456789"); std::string endChars("0123456789"); std::string::size_type startPos(token.find_first_of(startChars)); std::string::size_type stopPos(token.find_last_of(endChars)+1); token = token.substr(startPos, stopPos - startPos); return boost::lexical_cast<float>(token); }
void RefactorerWindow::setSelectionInfo() { QString sel = "Inter: "; sel += QString::number( startPos()); sel += " - "; sel += QString::number( endPos() ); sel += " Impl: "; sel += QString::number( ui->implementationText->textCursor().selectionStart()); sel += " - "; sel += QString::number( ui->implementationText->textCursor().selectionEnd() ); statusBar()->showMessage(sel); }
QDomElement Transition::toXML() { m_parameters.setAttribute(QStringLiteral("type"), transitionTag()); //m_transitionParameters.setAttribute("inverted", invertTransition()); m_parameters.setAttribute(QStringLiteral("transition_atrack"), track()); m_parameters.setAttribute(QStringLiteral("transition_btrack"), m_transitionTrack); m_parameters.setAttribute(QStringLiteral("start"), startPos().frames(m_fps)); m_parameters.setAttribute(QStringLiteral("end"), endPos().frames(m_fps)); m_parameters.setAttribute(QStringLiteral("force_track"), m_forceTransitionTrack); m_parameters.setAttribute(QStringLiteral("automatic"), m_automaticTransition); return m_parameters.cloneNode().toElement(); }
bool IdSpecParser::parse(vespalib::stringref s) { bool retval(false); size_t pos(eatWhite(s.data(), s.size())); if (pos+1 < s.size()) { if (icmp(s[pos], 'i') && icmp(s[pos+1],'d')) { pos += 2; if (pos < s.size()) { switch (s[pos]) { case '.': { int widthBits(-1); int divisionBits(-1); size_t startPos(++pos); for (;(pos < s.size()) && (tolower(s[pos]) >= 'a') && (tolower(s[pos]) <= 'z'); pos++); size_t len(pos - startPos); if (((len == 4) && (strncasecmp(&s[startPos], "user", 4) == 0 || strncasecmp(&s[startPos], "type", 4) == 0)) || ((len == 5) && (strncasecmp(&s[startPos], "group", 5) == 0)) || ((len == 6) && (strncasecmp(&s[startPos], "scheme", 6) == 0)) || ((len == 8) && (strncasecmp(&s[startPos], "specific", 8) == 0)) || ((len == 9) && (strncasecmp(&s[startPos], "namespace", 9) == 0))) { retval = true; setValue(ValueNode::UP(new IdValueNode(_bucketIdFactory, "id", s.substr(startPos, len), widthBits, divisionBits))); } else { pos = startPos; } } break; case '!': case '<': case '>': case '=': case '\t': case '\n': case '\r': case ' ': { retval = true; setValue(ValueNode::UP(new IdValueNode(_bucketIdFactory, "id", ""))); } break; default: break; } } } } setRemaining(s.substr(pos)); return retval; }
size_t CNode::endPos() { switch(mpNode->type) { case GUMBO_NODE_ELEMENT: return mpNode->v.element.end_pos.offset; case GUMBO_NODE_TEXT: return mpNode->v.text.original_text.length + startPos(); default: return 0; } }
void GridEmitter::init( ParticleArray *particles ) { for ( int p = 0; p < p_N; p++ ) { const Vector2d pos = startPos( p ); const Vector2d vel = startVel( p ); if ( channel->outsideBox( pos ) == P_INSIDE ) particles->add( Particle( pos, vel ) ); else left_over++; } }
void TargetDirectionHypothesis::saveResults() { Hypothesis::saveResults(); osg::Vec2 startPos(mStartPos.x(), mStartPos.y()); for (unsigned int i=0; i < mCommands.size(); i++) { HypothesisResult* r = mResults[i]->getResult(); r->setLabel(getName() + "TargetDir" + boost::lexical_cast<std::string>(i)); r->addTarget(mBlueUnits[i]); std::vector<osg::Vec2> path; path.push_back(startPos); path.push_back(osg::Vec2(mEndPos[i].x(), mEndPos[i].y())); r->addPoints(path, HypothesisResult::WORLD); } }
void plAnimatedMovementStrategy::IRecalcLinearVelocity(float elapsed, hsMatrix44 &prevMat, hsMatrix44 &curMat) { hsPoint3 startPos(0.0f, 0.0f, 0.0f); // default position (at start of anim) hsPoint3 prevPos = prevMat.GetTranslate(); // position previous frame hsPoint3 nowPos = curMat.GetTranslate(); // position current frame hsVector3 prev2Now = (hsVector3)(nowPos - prevPos); // frame-to-frame delta if (fabs(prev2Now.fX) < 0.0001f && fabs(prev2Now.fY) < 0.0001f && fabs(prev2Now.fZ) < 0.0001f) { fAnimLinearVel.Set(0.f, 0.f, 0.f); } else { hsVector3 start2Now = (hsVector3)(nowPos - startPos); // start-to-frame delta float prev2NowMagSqr = prev2Now.MagnitudeSquared(); float start2NowMagSqr = start2Now.MagnitudeSquared(); float dot = prev2Now.InnerProduct(start2Now); // HANDLING ANIMATION WRAPPING: // the vector from the animation origin to the current frame should point in roughly // the same direction as the vector from the previous animation position to the // current animation position. // // If they don't agree (dot < 0,) then we probably mpst wrapped around. // The right answer would be to compare the current frame to the start of // the anim loop, but it's cheaper to cheat and use the previous frame's velocity. if (dot > 0.0f) { prev2Now /= elapsed; float xfabs = fabs(prev2Now.fX); float yfabs = fabs(prev2Now.fY); float zfabs = fabs(prev2Now.fZ); static const float maxVel = 20.0f; bool valid = xfabs < maxVel && yfabs < maxVel && zfabs < maxVel; if (valid) { fAnimLinearVel = prev2Now; } } } }