void GFXGLCardProfiler::setupCardCapabilities() { GLint maxTexSize; glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTexSize); const char* versionString = reinterpret_cast<const char*>(glGetString(GL_VERSION)); F32 glVersion = dAtof(versionString); // OpenGL doesn't have separate maximum width/height. setCapability("maxTextureWidth", maxTexSize); setCapability("maxTextureHeight", maxTexSize); setCapability("maxTextureSize", maxTexSize); // If extensions haven't been inited, we're in trouble here. bool suppVBO = (gglHasExtension(GL_ARB_vertex_buffer_object) || glVersion >= 1.499f); setCapability("GL::suppVertexBufferObject", suppVBO); // check if render to texture supported is available bool suppRTT = gglHasExtension(GL_EXT_framebuffer_object); setCapability("GL::suppRenderTexture", suppRTT); bool suppBlit = gglHasExtension(GL_EXT_framebuffer_blit); setCapability("GL::suppRTBlit", suppBlit); bool suppFloatTex = gglHasExtension(GL_ATI_texture_float); setCapability("GL::suppFloatTexture", suppFloatTex); // Check for anisotropic filtering support. bool suppAnisotropic = gglHasExtension( GL_EXT_texture_filter_anisotropic ); setCapability( "GL::suppAnisotropic", suppAnisotropic ); // Check to see if mipmap lod bias is supported bool suppMipLodBias = gglHasExtension(GL_EXT_texture_lod_bias); setCapability("GL::suppMipLodBias", suppMipLodBias); // check to see if we have the fragment shader extension or the gl version is high enough for glsl to be core // also check to see if the language version is high enough F32 glslVersion = dAtof(reinterpret_cast<const char*>(glGetString( GL_SHADING_LANGUAGE_VERSION))); bool suppSPU = (gglHasExtension(GL_ARB_fragment_shader) || glVersion >= 1.999f) && glslVersion >= 1.0999; setCapability("GL::suppFragmentShader", suppSPU); bool suppAppleFence = gglHasExtension(GL_APPLE_fence); setCapability("GL::APPLE::suppFence", suppAppleFence); // When enabled, call glGenerateMipmapEXT() to generate mipmaps instead of relying on GL_GENERATE_MIPMAP setCapability("GL::Workaround::needsExplicitGenerateMipmap", false); // When enabled, binds and unbinds a texture target before doing the depth buffer copy. Failure to do // so will cause a hard freeze on Mac OS 10.4 with a Radeon X1600 setCapability("GL::Workaround::X1600DepthBufferCopy", false); // When enabled, does not copy the last column and row of the depth buffer in a depth buffer copy. Failure // to do so will cause a kernel panic on Mac OS 10.5(.1) with a Radeon HD 2600 (fixed in 10.5.2) setCapability("GL::Workaround::HD2600DepthBufferCopy", false); // Certain Intel drivers have a divide by 0 crash if mipmaps are specified with // glTexSubImage2D. setCapability("GL::Workaround::noManualMips", false); }
S32 QSORT_CALLBACK ArrayObject::_valueNumCompare( const void* a, const void* b ) { ArrayObject::Element *ea = (ArrayObject::Element *) (a); ArrayObject::Element *eb = (ArrayObject::Element *) (b); F32 aCol = dAtof(ea->value); F32 bCol = dAtof(eb->value); F32 result = aCol - bCol; S32 res = result < 0 ? -1 : (result > 0 ? 1 : 0); return ( smDecreasing ? -res : res ); }
S32 QSORT_CALLBACK ArrayObject::_keyNumCompare( const void* a, const void* b ) { ArrayObject::Element *ea = (ArrayObject::Element *) (a); ArrayObject::Element *eb = (ArrayObject::Element *) (b); const char* aCol = ea->key; const char* bCol = eb->key; F32 result = dAtof(aCol) - dAtof(bCol); S32 res = result < 0 ? -1 : (result > 0 ? 1 : 0); return ( smDecreasing ? -res : res ); }
static S32 QSORT_CALLBACK numCompare(const void *a,const void *b) { GuiTextListCtrl::Entry *ea = (GuiTextListCtrl::Entry *) (a); GuiTextListCtrl::Entry *eb = (GuiTextListCtrl::Entry *) (b); const char* aCol = getColumn( ea->text ); const char* bCol = getColumn( eb->text ); F32 result = dAtof(aCol) - dAtof(bCol); S32 res = result < 0 ? -1 : (result > 0 ? 1 : 0); return ( sIncreasing ? res : -res ); }
bool TimeOfDay::setTimeOfDay( void *obj, const char *data ) { TimeOfDay *tod = static_cast<TimeOfDay*>(obj); tod->setTimeOfDay( dAtof( data ) ); return false; }
bool WaterObject::_checkDensity( void *object, const char *index, const char *data ) { //Water densities above 1000 shoot the player high and fast into the air. //value clamped to prevent errors. WaterObject *water = static_cast<WaterObject*>( object ); water->mDensity = mClampF(dAtof( data ), 0.0f, 1000.0f); return false; }
bool NavMesh::setProtectedDetailSampleDist(void *obj, const char *index, const char *data) { F32 dist = dAtof(data); if(dist == 0.0f || dist >= 0.9f) { Con::errorf("NavMesh::detailSampleDist must be 0 or greater than 0.9!"); return true; } return false; }
bool DecalRoad::ptSetBreakAngle( void *obj, const char *data ) { DecalRoad *road = static_cast<DecalRoad*>( obj ); F32 val = dAtof( data ); road->setBreakAngle( val ); // we already set the field return false; }
bool DecalRoad::ptSetTextureLength( void *object, const char *index, const char *data ) { DecalRoad *road = static_cast<DecalRoad*>( object ); F32 val = dAtof( data ); road->setTextureLength( val ); // we already set the field return false; }
bool TimeOfDay::setDayLength( void *obj, const char *data ) { TimeOfDay *tod = static_cast<TimeOfDay*>(obj); F32 length = dAtof( data ); if( length != 0 ) tod->setDayLength( length ); return false; }
bool ScatterSky::ptSetAzimuth( void *object, const char *index, const char *data ) { ScatterSky *sky = static_cast<ScatterSky*>( object ); F32 val = dAtof( data ); sky->setAzimuth( val ); // we already set the field return false; }
bool WaterPlane::protectedSetGridElementSize( void *obj, const char *index, const char *data ) { WaterPlane *object = static_cast<WaterPlane*>(obj); F32 size = dAtof( data ); object->setGridElementSize( size ); // We already set the field. return false; }
void GuiProgressBitmapCtrl::setScriptValue(const char *value) { //set the value if (! value) mProgress = 0.0f; else mProgress = dAtof(value); //validate the value mProgress = mClampF(mProgress, 0.f, 1.f); setUpdate(); }
F32 script_simobject_getfield_float(U32 objectId, const char* fieldName) { SimObject *object = Sim::findObject( objectId ); if( object ) { const char *v = object->getDataField(fieldName, ""); return dAtof(v); } return false; }
void GuiProgressBitmapCtrl::onPreRender() { const char * var = getVariable(); if(var) { F32 value = mClampF(dAtof(var), 0.f, 1.f); if(value != mProgress) { mProgress = value; setUpdate(); } } }
void GuiTextEditSliderCtrl::onMouseDown(const GuiEvent &event) { // If we're not active then skip out. if ( !mActive || !mAwake || !mVisible ) { Parent::onMouseDown(event); return; } char txt[20]; Parent::getText(txt); mValue = dAtof(txt); mMouseDownTime = Sim::getCurrentTime(); GuiControl *parent = getParent(); if(!parent) return; Point2I camPos = event.mousePoint; Point2I point = parent->localToGlobalCoord(getPosition()); if(camPos.x > point.x + getExtent().x - 14) { if(camPos.y > point.y + (getExtent().y/2)) { mValue -=mIncAmount; mTextAreaHit = ArrowDown; mMulInc = -0.15f; } else { mValue +=mIncAmount; mTextAreaHit = ArrowUp; mMulInc = 0.15f; } checkRange(); setValue(); mouseLock(); // We should get the focus and set the // cursor to the start of the text to // mimic the standard Windows behavior. setFirstResponder(); mCursorPos = mBlockStart = mBlockEnd = 0; setUpdate(); return; } Parent::onMouseDown(event); }
bool ParticleData::protectedSetTimes( void *object, const char *index, const char *data) { ParticleData *pData = static_cast<ParticleData*>( object ); F32 val = dAtof(data); U32 i; if (!index) i = 0; else i = dAtoui(index); pData->times[i] = mClampF( val, 0.f, 1.f ); return false; }
ColladaAppNode::ColladaAppNode(const domNode* node, ColladaAppNode* parent) : p_domNode(node), appParent(parent), nodeExt(new ColladaExtension_node(node)), lastTransformTime(TSShapeLoader::DefaultTime-1), defaultTransformValid(false), invertMeshes(false) { mName = dStrdup(_GetNameOrId(node)); mParentName = dStrdup(parent ? parent->getName() : "ROOT"); // Extract user properties from the <node> extension as whitespace separated // "name=value" pairs char* properties = dStrdup(nodeExt->user_properties); char* pos = properties; char* end = properties + dStrlen( properties ); while ( pos < end ) { // Find the '=' character to separate the name and value pair char* split = dStrchr( pos, '=' ); if ( !split ) break; // Get the name (whitespace trimmed string up to the '=') // and value (whitespace trimmed string after the '=') *split = '\0'; char* name = TrimFirstWord( pos ); char* value = TrimFirstWord( split + 1 ); mProps.insert(StringTable->insert(name), dAtof(value)); pos = value + dStrlen( value ) + 1; } dFree( properties ); // Create vector of transform elements for (S32 iChild = 0; iChild < node->getContents().getCount(); iChild++) { switch (node->getContents()[iChild]->getElementType()) { case COLLADA_TYPE::TRANSLATE: case COLLADA_TYPE::ROTATE: case COLLADA_TYPE::SCALE: case COLLADA_TYPE::SKEW: case COLLADA_TYPE::MATRIX: case COLLADA_TYPE::LOOKAT: nodeTransforms.increment(); nodeTransforms.last().element = node->getContents()[iChild]; break; } } }
F64 consoleStringToNumber(const char *str, StringTableEntry file, U32 line) { F64 val = dAtof(str); if(val != 0) return val; else if(!dStricmp(str, "true")) return 1; else if(!dStricmp(str, "false")) return 0; else if(file) { Con::warnf(ConsoleLogEntry::General, "%s (%d): string always evaluates to 0.", file, line); return 0; } return 0; }
void SFXSource::addMarker( const String& name, U32 pos ) { mEffects.pushBack( new SFXMarkerEffect( this, name, pos ) ); } SFXProfile* SFXSource::getProfile() const { return mProfile; } //----------------------------------------------------------------------------- ConsoleMethod( SFXSource, addMarker, void, 4, 4, "( string name, float pos ) - Add a notification marker called 'name' at 'pos' seconds of playback." ) { String name = argv[ 2 ]; U32 pos = U32( dAtof( argv[ 3 ] ) * 1000.f ); object->addMarker( name, pos ); } ConsoleMethod( SFXSource, play, void, 2, 3, "( [float fadeIn] ) - Starts playback of the source." ) { F32 fadeInTime = -1.0f; if( argc > 2 ) fadeInTime = dAtof( argv[ 2 ] ); object->play( fadeInTime ); } ConsoleMethod( SFXSource, stop, void, 2, 3, "( [float fadeOut] ) - Ends playback of the source." ) { F32 fadeOutTime = -1.0f;
inline void default_vector_scan(const String &data, Vector<T> & result) { result.clear(); for(S32 i = 0; i < StringUnit::getUnitCount(data, " \t\n"); i++) result.push_back(dAtof(StringUnit::getUnit(data, i, " \t\n"))); }
//----------------------------------------------------------------------------- // F32/U32/S32 //----------------------------------------------------------------------------- bool default_scan(const String &data, F32 & result) { result = dAtof(data.c_str()); return true; }
"@brief Find objects matching the bitmask type within a box centered at point, with extents x, y, z.\n\n" "@returns The first object found, or an empty string if nothing was found. Thereafter, you can get more " "results using containerFindNext()." "@see containerFindNext\n" "@ingroup Game") { //find out what we're looking for U32 typeMask = U32(dAtoi(argv[1])); //find the center of the container volume Point3F origin(0.0f, 0.0f, 0.0f); dSscanf(argv[2], "%g %g %g", &origin.x, &origin.y, &origin.z); //find the box dimensions Point3F size(0.0f, 0.0f, 0.0f); size.x = mFabs(dAtof(argv[3])); size.y = mFabs(dAtof(argv[4])); size.z = mFabs(dAtof(argv[5])); //build the container volume Box3F queryBox; queryBox.minExtents = origin; queryBox.maxExtents = origin; queryBox.minExtents -= size; queryBox.maxExtents += size; //initialize the list, and do the query sgServerQueryList.mList.clear(); gServerContainer.findObjects(queryBox, typeMask, SimpleQueryList::insertionCallback, &sgServerQueryList); //return the first element
" Or maybe size of RAW is not pow2+1? (ie, 257 instead of 256, 4097 instead of 4096)"); *cur = F32(h) / 16.0; cur++; } return true; } }; ConsoleFunction(atlasGenerateGeometryFromHeightfield, void, 6, 6, "(atlasOutFile, inHeightfield, hfSize, gridSpacing, patchSize) - generate terrain geometry " "to atlasOutFile based on the heightfield.") { const U32 hfSize = dAtoi(argv[3]); const F32 gridSpacing = dAtof(argv[4]); const U32 tileSize = dAtoi(argv[5]); // Caculate treeDepth... const S32 treeDepth = getBinLog2(hfSize/tileSize)+1; Con::errorf("***************************************************************"); Con::errorf(""); Con::errorf("BE AWARE - THIS FUNCTION IS STILL IN DEVELOPMENT AND WILL NOT GIVE USEFUL RESULTS."); Con::errorf("PLEASE USE THE atlasOldGenerateChunkFileFromRaw16 method AND importOldAtlasCHU"); Con::errorf("TO GENERATE GEOMETRY FOR NOW."); Con::errorf(""); Con::errorf("Now generating geometry..."); Con::errorf(""); Con::errorf("***************************************************************");
void GuiTextEditSliderCtrl::setText(const char *txt) { mValue = dAtof(txt); checkRange(); setValue(); }
F32 getFloatVariable(const char *varName, F32 def) { const char *value = getVariable(varName); return *value ? dAtof(value) : def; }