SwapType ChainArray::swap(uint id1, uint id2) { uint hId = std::max(id1, id2); uint lId = std::min(id1, id2); State stateh = lastState(hId); State statel = lastState(lId); // Determine if we accept this swap bool swapped = acceptSwap(stateh, statel, beta_[hId], beta_[lId]); // Save the swap only on the lower temperature chain if (swapped) { std::swap(stateh, statel); statel.swapType = SwapType::Accept; setLastState(hId, stateh); setLastState(lId, statel); } else { statel.swapType = SwapType::Reject; setLastState(lId, statel); } return swapped ? SwapType::Accept : SwapType::Reject; }
bool GroundPlane::prepRenderImage( SceneState* state, const U32 stateKey, const U32, const bool ) { PROFILE_SCOPE( GroundPlane_prepRenderImage ); if( isLastState( state, stateKey ) ) return false; setLastState( state, stateKey ); if( !state->isObjectRendered( this ) || !mMaterial ) return false; PROFILE_SCOPE( GroundPlane_prepRender ); // Update the geometry. createGeometry( state->getFrustum() ); if( mVertexBuffer.isNull() ) return false; // Add a render instance. RenderPassManager* pass = state->getRenderPass(); MeshRenderInst* ri = pass->allocInst< MeshRenderInst >(); ri->type = RenderPassManager::RIT_Mesh; ri->vertBuff = &mVertexBuffer; ri->primBuff = &mPrimitiveBuffer; ri->prim = &mPrimitive; ri->matInst = mMaterial; ri->objectToWorld = pass->allocUniqueXform( mRenderObjToWorld ); ri->worldToCamera = pass->allocSharedXform(RenderPassManager::View); ri->projection = pass->allocSharedXform(RenderPassManager::Projection); ri->visibility = 1.0f; ri->translucentSort = ( ri->matInst->getMaterial()->isTranslucent() ); // NOTICE: SFXBB is removed and refraction is disabled! //ri->backBuffTex = GFX->getSfxBackBuffer(); ri->defaultKey = ( U32 ) mMaterial; // TODO: Get the best lights for the plane in a better // way.... maybe the same way as we do for terrain? ri->lights[0] = state->getLightManager()->getDefaultLight(); if( ri->translucentSort ) ri->type = RenderPassManager::RIT_Translucent; pass->addInst( ri ); return true; }
bool Sun::prepRenderImage( SceneState *state, const U32 stateKey, const U32, const bool ) { if ( isLastState( state, stateKey ) ) return false; setLastState( state, stateKey ); if ( !state->isObjectRendered( this ) || !(state->isDiffusePass() || state->isReflectPass()) ) return false; // Render instance for Corona effect. if ( mCoronaEnabled && mCoronaTexture.isValid() ) { ObjectRenderInst *ri = state->getRenderPass()->allocInst<ObjectRenderInst>(); ri->renderDelegate.bind( this, &Sun::_renderCorona ); ri->type = RenderPassManager::RIT_Sky; // Render after sky objects and before CloudLayer! ri->defaultKey = 5; ri->defaultKey2 = 0; state->getRenderPass()->addInst( ri ); } // LightFlareData handles rendering flare effects. if ( mFlareData ) { mFlareState.fullBrightness = mBrightness; mFlareState.scale = mFlareScale; mFlareState.lightInfo = mLight; Point3F lightPos = state->getCameraPosition() - state->getFarPlane() * mLight->getDirection() * 0.9f; mFlareState.lightMat.identity(); mFlareState.lightMat.setPosition( lightPos ); F32 dist = ( lightPos - state->getCameraPosition() ).len(); F32 radius = ( dist / ( GFX->getViewport().extent.x / 640.0 ) ) / 2; radius *= mCoronaScale; radius = ( radius / dist ) * state->getWorldToScreenScale().y; mFlareState.worldRadius = radius; mFlareData->prepRender( state, &mFlareState ); } return false; }
bool RenderObjectExample::prepRenderImage( SceneState *state, const U32 stateKey, const U32 startZone, const bool modifyBaseZoneState) { // Do a little prep work if needed if ( mVertexBuffer.isNull() ) createGeometry(); // Make sure we haven't already been processed by this state if ( isLastState( state, stateKey ) ) return false; // Update our state setLastState(state, stateKey); // If we are actually rendered then create and submit our RenderInst if ( state->isObjectRendered( this ) ) { // Allocate an ObjectRenderInst so that we can submit it to the RenderPassManager ObjectRenderInst *ri = state->getRenderPass()->allocInst<ObjectRenderInst>(); // Now bind our rendering function so that it will get called ri->renderDelegate.bind( this, &RenderObjectExample::render ); // Set our RenderInst as a standard object render ri->type = RenderPassManager::RIT_Object; // Set our sorting keys to a default value ri->defaultKey = 0; ri->defaultKey2 = 0; // Submit our RenderInst to the RenderPassManager state->getRenderPass()->addInst( ri ); } return false; }
//-------------------------------------------------------------------------- bool Projectile::prepRenderImage(SceneState* state, const U32 stateKey, const U32 /*startZone*/, const bool /*modifyBaseState*/) { if (isLastState(state, stateKey)) return false; setLastState(state, stateKey); if (mHidden == true || mFadeValue <= (1.0/255.0)) return false; // This should be sufficient for most objects that don't manage zones, and // don't need to return a specialized RenderImage... if (state->isObjectRendered(this)) { if ( mDataBlock->lightDesc ) { mDataBlock->lightDesc->prepRender( state, &mLightState, getRenderTransform() ); } /* if ( mFlareData ) { mFlareState.fullBrightness = mDataBlock->lightDesc->mBrightness; mFlareState.scale = mFlareScale; mFlareState.lightInfo = mLight; mFlareState.lightMat = getTransform(); mFlareData->prepRender( state, &mFlareState ); } */ prepBatchRender( state ); } return false; }
bool DecalManager::prepRenderImage(SceneState* state, const U32 stateKey, const U32 /*startZone*/, const bool /*modifyBaseState*/) { PROFILE_SCOPE( DecalManager_RenderDecals ); if ( !smDecalsOn || !mData ) return false; if (isLastState(state, stateKey)) return false; setLastState(state, stateKey); if ( !state->isDiffusePass() && !state->isReflectPass() ) return false; PROFILE_START( DecalManager_RenderDecals_SphereTreeCull ); // Grab this before anything here changes it. mCuller = state->getFrustum(); // Populate vector of decal instances to be rendered with all // decals from visible decal spheres. mDecalQueue.clear(); const Vector<DecalSphere*> &grid = mData->getGrid(); for ( U32 i = 0; i < grid.size(); i++ ) { const DecalSphere *decalSphere = grid[i]; const SphereF &worldSphere = decalSphere->mWorldSphere; if ( !mCuller.sphereInFrustum( worldSphere.center, worldSphere.radius ) ) continue; // TODO: If each sphere stored its largest decal instance we // could do an LOD step on it here and skip adding any of the // decals in the sphere. mDecalQueue.merge( decalSphere->mItems ); } PROFILE_END(); PROFILE_START( DecalManager_RenderDecals_Update ); const U32 &curSimTime = Sim::getCurrentTime(); const Point2I &viewportExtent = state->getViewportExtent(); Point3F cameraOffset; F32 decalSize, pixelRadius; U32 delta, diff; DecalInstance *dinst; // Loop through DecalQueue once for preRendering work. // 1. Update DecalInstance fade (over time) // 2. Clip geometry if flagged to do so. // 3. Calculate lod - if decal is far enough away it will not render. for ( U32 i = 0; i < mDecalQueue.size(); i++ ) { dinst = mDecalQueue[i]; // LOD calculation. // See TSShapeInstance::setDetailFromDistance for more // information on these calculations. decalSize = getMax( dinst->mSize, 0.001f ); pixelRadius = dinst->calcPixelRadius( state ); // Need to clamp here. if ( pixelRadius < dinst->calcEndPixRadius( viewportExtent ) ) { mDecalQueue.erase_fast( i ); i--; continue; } // We're gonna try to render this decal... so do any // final adjustments to it before rendering. // Update fade and delete expired. if ( !( dinst->mFlags & PermanentDecal || dinst->mFlags & CustomDecal ) ) { delta = ( curSimTime - dinst->mCreateTime ); if ( delta > dinst->mDataBlock->lifeSpan ) { diff = delta - dinst->mDataBlock->lifeSpan; dinst->mVisibility = 1.0f - (F32)diff / (F32)dinst->mDataBlock->fadeTime; if ( dinst->mVisibility <= 0.0f ) { mDecalQueue.erase_fast( i ); removeDecal( dinst ); i--; continue; } } } // Build clipped geometry for this decal if needed. if ( dinst->mFlags & ClipDecal/* && !( dinst->mFlags & CustomDecal ) */) { // Turn off the flag so we don't continually try to clip // if it fails. if(!clipDecal( dinst )) { dinst->mFlags = dinst->mFlags & ~ClipDecal; if ( !(dinst->mFlags & CustomDecal) ) { // Clipping failed to get any geometry... // Remove it from the render queue. mDecalQueue.erase_fast( i ); i--; // If the decal is one placed at run-time (not the editor) // then we should also permanently delete the decal instance. if ( !(dinst->mFlags & SaveDecal) ) { removeDecal( dinst ); } } // If this is a decal placed by the editor it will be // flagged to attempt clipping again the next time it is // modified. For now we just skip rendering it. continue; } } // If we get here and the decal still does not have any geometry // skip rendering it. It must be an editor placed decal that failed // to clip any geometry but has not yet been flagged to try again. if ( !dinst->mVerts || dinst->mVertCount == 0 || dinst->mIndxCount == 0 ) { mDecalQueue.erase_fast( i ); i--; continue; } // F32 alpha = pixelRadius / (dinst->mDataBlock->startPixRadius * decalSize) - 1.0f; if ( dinst->mFlags & CustomDecal ) { alpha = mClampF( alpha, 0.0f, 1.0f ); alpha *= dinst->mVisibility; } else alpha = mClampF( alpha * dinst->mVisibility, 0.0f, 1.0f ); // for ( U32 v = 0; v < dinst->mVertCount; v++ ) dinst->mVerts[v].color.set( 255, 255, 255, alpha * 255.0f ); } PROFILE_END(); if ( mDecalQueue.empty() ) return false; // Sort queued decals... // 1. Editor decals - in render priority order first, creation time second, and material third. // 2. Dynamic decals - in render priority order first and creation time second. // // With the constraint that decals with different render priority cannot // be rendered together in the same draw call. PROFILE_START( DecalManager_RenderDecals_Sort ); dQsort( mDecalQueue.address(), mDecalQueue.size(), sizeof(DecalInstance*), cmpDecalRenderOrder ); PROFILE_END(); PROFILE_SCOPE( DecalManager_RenderDecals_RenderBatch ); mPrimBuffs.clear(); mVBs.clear(); RenderPassManager *renderPass = state->getRenderPass(); // Base render instance for convenience we use for convenience. // Data shared by all instances we allocate below can be copied // from the base instance at the same time. MeshRenderInst baseRenderInst; baseRenderInst.clear(); MatrixF *tempMat = renderPass->allocUniqueXform( MatrixF( true ) ); MathUtils::getZBiasProjectionMatrix( gDecalBias, mCuller, tempMat ); baseRenderInst.projection = tempMat; baseRenderInst.objectToWorld = &MatrixF::Identity; baseRenderInst.worldToCamera = renderPass->allocSharedXform(RenderPassManager::View); baseRenderInst.type = RenderPassManager::RIT_Decal; // Make it the sort distance the max distance so that // it renders after all the other opaque geometry in // the prepass bin. baseRenderInst.sortDistSq = F32_MAX; // Get the best lights for the current camera position. LightManager *lm = state->getLightManager(); if ( lm ) { lm->setupLights( NULL, mCuller.getPosition(), mCuller.getTransform().getForwardVector(), mCuller.getFarDist() ); lm->getBestLights( baseRenderInst.lights, 4 ); lm->resetLights(); } Vector<DecalBatch> batches; DecalBatch *currentBatch = NULL; // Loop through DecalQueue collecting them into render batches. for ( U32 i = 0; i < mDecalQueue.size(); i++ ) { DecalInstance *decal = mDecalQueue[i]; DecalData *data = decal->mDataBlock; Material *mat = data->getMaterial(); if ( currentBatch == NULL ) { // Start a new batch, beginning with this decal. batches.increment(); currentBatch = &batches.last(); currentBatch->startDecal = i; currentBatch->decalCount = 1; currentBatch->iCount = decal->mIndxCount; currentBatch->vCount = decal->mVertCount; currentBatch->mat = mat; currentBatch->matInst = decal->mDataBlock->getMaterialInstance(); currentBatch->priority = decal->getRenderPriority(); currentBatch->dynamic = !(decal->mFlags & SaveDecal); continue; } if ( currentBatch->iCount + decal->mIndxCount >= smMaxIndices || currentBatch->vCount + decal->mVertCount >= smMaxVerts || currentBatch->mat != mat || currentBatch->priority != decal->getRenderPriority() || decal->mCustomTex ) { // End batch. currentBatch = NULL; i--; continue; } // Add on to current batch. currentBatch->decalCount++; currentBatch->iCount += decal->mIndxCount; currentBatch->vCount += decal->mVertCount; } // Loop through batches allocating buffers and submitting render instances. for ( U32 i = 0; i < batches.size(); i++ ) { DecalBatch ¤tBatch = batches[i]; // Allocate buffers... GFXVertexBufferHandle<DecalVertex> vb; vb.set( GFX, currentBatch.vCount, GFXBufferTypeDynamic ); DecalVertex *vpPtr = vb.lock(); GFXPrimitiveBufferHandle pb; pb.set( GFX, currentBatch.iCount, 0, GFXBufferTypeDynamic ); U16 *pbPtr; pb.lock( &pbPtr ); // Copy data into the buffers from all decals in this batch... U32 lastDecal = currentBatch.startDecal + currentBatch.decalCount; U32 voffset = 0; U32 ioffset = 0; // This is an ugly hack for ProjectedShadow! GFXTextureObject *customTex = NULL; for ( U32 j = currentBatch.startDecal; j < lastDecal; j++ ) { DecalInstance *dinst = mDecalQueue[j]; for ( U32 k = 0; k < dinst->mIndxCount; k++ ) { *( pbPtr + ioffset + k ) = dinst->mIndices[k] + voffset; } ioffset += dinst->mIndxCount; dMemcpy( vpPtr + voffset, dinst->mVerts, sizeof( DecalVertex ) * dinst->mVertCount ); voffset += dinst->mVertCount; // Ugly hack for ProjectedShadow! if ( (dinst->mFlags & CustomDecal) && dinst->mCustomTex != NULL ) customTex = *dinst->mCustomTex; } AssertFatal( ioffset == currentBatch.iCount, "bad" ); AssertFatal( voffset == currentBatch.vCount, "bad" ); pb.unlock(); vb.unlock(); // DecalManager must hold handles to these buffers so they remain valid, // we don't actually use them elsewhere. mPrimBuffs.push_back( pb ); mVBs.push_back( vb ); // Submit render inst... MeshRenderInst *ri = renderPass->allocInst<MeshRenderInst>(); *ri = baseRenderInst; ri->primBuff = &mPrimBuffs.last(); ri->vertBuff = &mVBs.last(); ri->matInst = currentBatch.matInst; ri->prim = renderPass->allocPrim(); ri->prim->type = GFXTriangleList; ri->prim->minIndex = 0; ri->prim->startIndex = 0; ri->prim->numPrimitives = currentBatch.iCount / 3; ri->prim->startVertex = 0; ri->prim->numVertices = currentBatch.vCount; // Ugly hack for ProjectedShadow! if ( customTex ) ri->miscTex = customTex; // The decal bin will contain render instances for both decals and decalRoad's. // Dynamic decals render last, then editor decals and roads in priority order. // DefaultKey is sorted in descending order. ri->defaultKey = currentBatch.dynamic ? 0xFFFFFFFF : (U32)currentBatch.priority; ri->defaultKey2 = 1;//(U32)lastDecal->mDataBlock; renderPass->addInst( ri ); } return false; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), absoluteAfterAxisAdj(false), checkLogWrite(false), sliderPressed(false), sliderTo(0.0), sliderZCount(0) { // Setup our application information to be used by QSettings QCoreApplication::setOrganizationName(COMPANY_NAME); QCoreApplication::setOrganizationDomain(DOMAIN_NAME); QCoreApplication::setApplicationName(APPLICATION_NAME); // required if passing the object by reference into signals/slots qRegisterMetaType<Coord3D>("Coord3D"); qRegisterMetaType<PosItem>("PosItem"); qRegisterMetaType<ControlParams>("ControlParams"); ui->setupUi(this); readSettings(); info("%s has started", GRBL_CONTROLLER_NAME_AND_VERSION); // see http://blog.qt.digia.com/2010/06/17/youre-doing-it-wrong/ // The thread points out that the documentation for QThread is wrong :) and // you should NOT subclass from QThread and override run(), rather, // attach your QOBJECT to a thread and use events (signals/slots) to communicate. gcode.moveToThread(&gcodeThread); timer.moveToThread(&timerThread); ui->lcdWorkNumberX->setDigitCount(8); ui->lcdMachNumberX->setDigitCount(8); ui->lcdWorkNumberY->setDigitCount(8); ui->lcdMachNumberY->setDigitCount(8); ui->lcdWorkNumberZ->setDigitCount(8); ui->lcdMachNumberZ->setDigitCount(8); //buttons connect(ui->btnOpenPort,SIGNAL(clicked()),this,SLOT(openPort())); connect(ui->btnGRBL,SIGNAL(clicked()),this,SLOT(setGRBL())); connect(ui->DecXBtn,SIGNAL(clicked()),this,SLOT(decX())); connect(ui->DecYBtn,SIGNAL(clicked()),this,SLOT(decY())); connect(ui->DecZBtn,SIGNAL(clicked()),this,SLOT(decZ())); connect(ui->IncXBtn,SIGNAL(clicked()),this,SLOT(incX())); connect(ui->IncYBtn,SIGNAL(clicked()),this,SLOT(incY())); connect(ui->IncZBtn,SIGNAL(clicked()),this,SLOT(incZ())); connect(ui->btnSetHome,SIGNAL(clicked()),this,SLOT(setHome())); connect(ui->Command,SIGNAL(editingFinished()),this,SLOT(gotoXYZ())); connect(ui->Begin,SIGNAL(clicked()),this,SLOT(begin())); connect(ui->openFile,SIGNAL(clicked()),this,SLOT(openFile())); connect(ui->Stop,SIGNAL(clicked()),this,SLOT(stop())); connect(ui->SpindleOn,SIGNAL(toggled(bool)),this,SLOT(toggleSpindle())); connect(ui->chkRestoreAbsolute,SIGNAL(toggled(bool)),this,SLOT(toggleRestoreAbsolute())); connect(ui->actionOptions,SIGNAL(triggered()),this,SLOT(getOptions())); connect(ui->actionExit,SIGNAL(triggered()),this,SLOT(close())); connect(ui->actionAbout,SIGNAL(triggered()),this,SLOT(showAbout())); connect(ui->btnResetGrbl,SIGNAL(clicked()),this,SLOT(grblReset())); connect(ui->btnUnlockGrbl,SIGNAL(clicked()),this,SLOT(grblUnlock())); connect(ui->btnGoHomeSafe,SIGNAL(clicked()),this,SLOT(goHomeSafe())); connect(ui->verticalSliderZJog,SIGNAL(valueChanged(int)),this,SLOT(zJogSliderDisplay(int))); connect(ui->verticalSliderZJog,SIGNAL(sliderPressed()),this,SLOT(zJogSliderPressed())); connect(ui->verticalSliderZJog,SIGNAL(sliderReleased()),this,SLOT(zJogSliderReleased())); connect(this, SIGNAL(sendFile(QString)), &gcode, SLOT(sendFile(QString))); connect(this, SIGNAL(openPort(QString,QString)), &gcode, SLOT(openPort(QString,QString))); connect(this, SIGNAL(closePort(bool)), &gcode, SLOT(closePort(bool))); connect(this, SIGNAL(sendGcode(QString)), &gcode, SLOT(sendGcode(QString))); connect(this, SIGNAL(gotoXYZ(QString)), &gcode, SLOT(gotoXYZ(QString))); connect(this, SIGNAL(axisAdj(char, float, bool, bool, int)), &gcode, SLOT(axisAdj(char, float, bool, bool, int))); connect(this, SIGNAL(setResponseWait(ControlParams)), &gcode, SLOT(setResponseWait(ControlParams))); connect(this, SIGNAL(shutdown()), &gcodeThread, SLOT(quit())); connect(this, SIGNAL(shutdown()), &timerThread, SLOT(quit())); connect(this, SIGNAL(setProgress(int)), ui->progressFileSend, SLOT(setValue(int))); connect(this, SIGNAL(setRuntime(QString)), ui->outputRuntime, SLOT(setText(QString))); connect(this, SIGNAL(sendSetHome()), &gcode, SLOT(grblSetHome())); connect(this, SIGNAL(sendGrblReset()), &gcode, SLOT(sendGrblReset())); connect(this, SIGNAL(sendGrblUnlock()), &gcode, SLOT(sendGrblUnlock())); connect(this, SIGNAL(goToHome()), &gcode, SLOT(goToHome())); connect(this, SIGNAL(setItems(QList<PosItem>)), ui->wgtVisualizer, SLOT(setItems(QList<PosItem>))); connect(&gcode, SIGNAL(sendMsg(QString)),this,SLOT(receiveMsg(QString))); connect(&gcode, SIGNAL(portIsClosed(bool)), this, SLOT(portIsClosed(bool))); connect(&gcode, SIGNAL(portIsOpen(bool)), this, SLOT(portIsOpen(bool))); connect(&gcode, SIGNAL(addList(QString)),this,SLOT(receiveList(QString))); connect(&gcode, SIGNAL(addListFull(QStringList)),this,SLOT(receiveListFull(QStringList))); connect(&gcode, SIGNAL(addListOut(QString)),this,SLOT(receiveListOut(QString))); connect(&gcode, SIGNAL(stopSending()), this, SLOT(stopSending())); connect(&gcode, SIGNAL(setCommandText(QString)), ui->Command, SLOT(setText(QString))); connect(&gcode, SIGNAL(setProgress(int)), ui->progressFileSend, SLOT(setValue(int))); connect(&gcode, SIGNAL(adjustedAxis()), this, SLOT(adjustedAxis())); connect(&gcode, SIGNAL(resetTimer(bool)), &timer, SLOT(resetTimer(bool))); connect(&gcode, SIGNAL(enableGrblDialogButton()), this, SLOT(enableGrblDialogButton())); connect(&gcode, SIGNAL(updateCoordinates(Coord3D,Coord3D)), this, SLOT(updateCoordinates(Coord3D,Coord3D))); connect(&gcode, SIGNAL(setLastState(QString)), ui->outputLastState, SLOT(setText(QString))); connect(&gcode, SIGNAL(setUnitsWork(QString)), ui->outputUnitsWork, SLOT(setText(QString))); connect(&gcode, SIGNAL(setUnitsMachine(QString)), ui->outputUnitsMachine, SLOT(setText(QString))); connect(&gcode, SIGNAL(setLivePoint(double, double, bool)), ui->wgtVisualizer, SLOT(setLivePoint(double, double, bool))); connect(&gcode, SIGNAL(setVisCurrLine(int)), ui->wgtVisualizer, SLOT(setVisCurrLine(int))); connect(&timer, SIGNAL(setRuntime(QString)), ui->outputRuntime, SLOT(setText(QString))); timerThread.start(); gcodeThread.start(); ui->comboStep->addItem("0.01"); ui->comboStep->addItem("0.1"); ui->comboStep->addItem("1"); ui->comboStep->addItem("10"); ui->comboStep->setCurrentIndex(2); ui->statusList->setUniformItemSizes(true); // Does not work correctly for horizontal scrollbar: //MyItemDelegate *scrollDelegate = new MyItemDelegate(ui->statusList); //scrollDelegate->setWidth(600); //ui->statusList->setItemDelegate(scrollDelegate); scrollStatusTimer.start(); // Cool utility class off Google code that enumerates COM ports in platform-independent manner QList<QextPortInfo> ports = QextSerialEnumerator::getPorts(); int portIndex = -1; for (int i = 0; i < ports.size(); i++) { ui->cmbPort->addItem(ports.at(i).portName.toLocal8Bit().constData()); if (ports.at(i).portName == lastOpenPort) portIndex = i; //diag("port name: %s\n", ports.at(i).portName.toLocal8Bit().constData()); //diag("friendly name: %s\n", ports.at(i).friendName.toLocal8Bit().constData()); //diag("physical name: %s\n", ports.at(i).physName.toLocal8Bit().constData()); //diag("enumerator name: %s\n", ports.at(i).enumName.toLocal8Bit().constData()); //diag("===================================\n\n"); } if (portIndex >= 0) { // found matching port ui->cmbPort->setCurrentIndex(portIndex); } else if (lastOpenPort.size() > 0) { // did not find matching port // This code block is used to restore a port to view that isn't visible to QextSerialEnumerator ui->cmbPort->addItem(lastOpenPort.toLocal8Bit().constData()); if (ports.size() > 0) ui->cmbPort->setCurrentIndex(ports.size()); else ui->cmbPort->setCurrentIndex(0); } int baudRates[] = { 9600, 19200, 38400, 57600, 115200 }; int baudRateCount = sizeof baudRates / sizeof baudRates[0]; int baudRateIndex = 0; for (int i = 0; i < baudRateCount; i++) { QString baudRate = QString::number(baudRates[i]); ui->comboBoxBaudRate->addItem(baudRate); if (baudRate == lastBaudRate) { baudRateIndex = i; } } ui->comboBoxBaudRate->setCurrentIndex(baudRateIndex); ui->tabAxisVisualizer->setEnabled(false); ui->groupBoxSendFile->setEnabled(true); ui->groupBoxManualGCode->setEnabled(false); ui->Begin->setEnabled(false); ui->Stop->setEnabled(false); ui->progressFileSend->setEnabled(false); ui->outputRuntime->setEnabled(false); ui->labelRuntime->setEnabled(false); ui->btnGRBL->setEnabled(false); ui->btnSetHome->setEnabled(false); ui->btnResetGrbl->setEnabled(false); ui->btnUnlockGrbl->setEnabled(false); ui->btnGoHomeSafe->setEnabled(false); styleSheet = ui->btnOpenPort->styleSheet(); ui->statusList->setEnabled(true); ui->openFile->setEnabled(true); this->setWindowTitle(GRBL_CONTROLLER_NAME_AND_VERSION); QSettings settings; QString useAggrPreload = settings.value(SETTINGS_USE_AGGRESSIVE_PRELOAD, "true").value<QString>(); controlParams.useAggressivePreload = useAggrPreload == "true"; if (!controlParams.useAggressivePreload && !promptedAggrPreload) { QMessageBox msgBox; msgBox.setText("You appear to have upgraded to the latest version of Grbl Controller. " "Please be aware that as of version 3.4 the default behavior of sending commands " "to Grbl has been changed to send them as fast as possible (Aggressive preload mode).\n\n" "Your settings have been changed to enable this mode. Why? Because it provides the most " "optimal use of Grbl and greatly reduces the time to finish a typical job.\n\n" "What does this mean to you? " "Arc commands will now run smoother and faster than before, which may " "cause your spindle to work slightly harder, so please run some tests first. " "Alternately, go to the Options dialog and manually disable Aggressive Preload"); msgBox.exec(); controlParams.useAggressivePreload = true; settings.setValue(SETTINGS_USE_AGGRESSIVE_PRELOAD, controlParams.useAggressivePreload); } promptedAggrPreload = true; emit setResponseWait(controlParams); }
bool DecalRoad::prepRenderImage( SceneState* state, const U32 stateKey, const U32 startZone, const bool modifyBaseZoneState) { if ( mNodes.size() <= 1 || isLastState(state, stateKey) || mBatches.size() == 0 || !mMatInst || state->isShadowPass() ) return false; // Set Last State. setLastState( state, stateKey ); // Is Object Rendered? if ( !state->isObjectRendered( this ) ) return false; RenderPassManager *renderPass = state->getRenderPass(); // Debug RenderInstance // Only when editor is open. if ( smEditorOpen ) { ObjectRenderInst *ri = renderPass->allocInst<ObjectRenderInst>(); ri->type = RenderPassManager::RIT_Object; ri->renderDelegate.bind( this, &DecalRoad::_debugRender ); state->getRenderPass()->addInst( ri ); } // Normal Road RenderInstance // Always rendered when the editor is not open // otherwise obey the smShowRoad flag if ( !smShowRoad && smEditorOpen ) return false; const Frustum &frustum = state->getFrustum(); MeshRenderInst coreRI; coreRI.clear(); coreRI.objectToWorld = &MatrixF::Identity; coreRI.worldToCamera = renderPass->allocSharedXform(RenderPassManager::View); MatrixF *tempMat = renderPass->allocUniqueXform( MatrixF( true ) ); MathUtils::getZBiasProjectionMatrix( gDecalBias, frustum, tempMat ); coreRI.projection = tempMat; coreRI.type = RenderPassManager::RIT_Decal; coreRI.matInst = mMatInst; coreRI.vertBuff = &mVB; coreRI.primBuff = &mPB; // Make it the sort distance the max distance so that // it renders after all the other opaque geometry in // the prepass bin. coreRI.sortDistSq = F32_MAX; // Get the light manager and setup lights LightManager *lm = state->getLightManager(); if ( lm ) { lm->setupLights( this, getWorldSphere() ); lm->getBestLights( coreRI.lights, 8 ); } U32 startBatchIdx = -1; U32 endBatchIdx = 0; for ( U32 i = 0; i < mBatches.size(); i++ ) { // TODO: visibility is bugged... must fix! //const RoadBatch &batch = mBatches[i]; //const bool isVisible = frustum.intersects( batch.bounds ); if ( true /*isVisible*/ ) { // If this is the start of a set of batches. if ( startBatchIdx == -1 ) endBatchIdx = startBatchIdx = i; // Else we're extending the end batch index. else ++endBatchIdx; // If this isn't the last batch then continue. if ( i < mBatches.size()-1 ) continue; } // We we still don't have a start batch, so skip. if ( startBatchIdx == -1 ) continue; // Render this set of batches. const RoadBatch &startBatch = mBatches[startBatchIdx]; // mBatches[0]; const RoadBatch &endBatch = mBatches[endBatchIdx]; // mBatches.last(); U32 startVert = startBatch.startVert; U32 startIdx = startBatch.startIndex; U32 vertCount = endBatch.endVert - startVert; U32 idxCount = ( endBatch.endIndex - startIdx ) + 1; U32 triangleCount = idxCount / 3; AssertFatal( startVert + vertCount <= mVertCount, "DecalRoad, bad draw call!" ); AssertFatal( startIdx + triangleCount < mTriangleCount * 3, "DecalRoad, bad draw call!" ); MeshRenderInst *ri = renderPass->allocInst<MeshRenderInst>(); *ri = coreRI; ri->prim = renderPass->allocPrim(); ri->prim->type = GFXTriangleList; ri->prim->minIndex = 0; ri->prim->startIndex = startIdx; ri->prim->numPrimitives = triangleCount; ri->prim->startVertex = startVert; ri->prim->numVertices = vertCount; // For sorting we first sort by render priority // and then by objectId. // // Since a road can submit more than one render instance, we want all // draw calls for a single road to occur consecutively, since they // could use the same vertex buffer. ri->defaultKey = mRenderPriority << 0 | mId << 16; ri->defaultKey2 = 0; renderPass->addInst( ri ); // Reset the batching. startBatchIdx = -1; } return false; }