DebrisData::DebrisData(const DebrisData& other, bool temp_clone) : GameBaseData(other, temp_clone) { #ifdef TRACK_DEBRIS_DATA_CLONES debris_data_clones++; if (debris_data_clones == 1) Con::errorf("DebrisData -- Clones are on the loose!"); #endif velocity = other.velocity; velocityVariance = other.velocityVariance; friction = other.friction; elasticity = other.elasticity; lifetime = other.lifetime; lifetimeVariance = other.lifetimeVariance; numBounces = other.numBounces; bounceVariance = other.bounceVariance; minSpinSpeed = other.minSpinSpeed; maxSpinSpeed = other.maxSpinSpeed; explodeOnMaxBounce = other.explodeOnMaxBounce; staticOnMaxBounce = other.staticOnMaxBounce; snapOnMaxBounce = other.snapOnMaxBounce; fade = other.fade; useRadiusMass = other.useRadiusMass; baseRadius = other.baseRadius; gravModifier = other.gravModifier; terminalVelocity = other.terminalVelocity; ignoreWater = other.ignoreWater; shapeName = other.shapeName; shape = other.shape; // -- TSShape loaded using shapeName textureName = other.textureName; explosionId = other.explosionId; // -- for pack/unpack of explosion ptr explosion = other.explosion; dMemcpy( emitterList, other.emitterList, sizeof( emitterList ) ); dMemcpy( emitterIDList, other.emitterIDList, sizeof( emitterIDList ) ); // -- for pack/unpack of emitterList ptrs }
void TheoraTexture::FrameReadItem::execute() { // Read Theora frame data. OggTheoraFrame* frame; if( mFrameStream->getSourceStream()->read( &frame, 1 ) != 1 ) return; // Copy the data into the texture. OggTheoraDecoder* decoder = mAsyncState->getTheora(); const U32 height = decoder->getFrameHeight(); const U32 framePitch = decoder->getFrameWidth() * 4; GFXLockedRect* rect = mFrame->mLockedRect; if( rect ) { const U32 usePitch = getMin(framePitch, mFrame->mTexture->getWidth() * 4); const U32 maxHeight = getMin(height, mFrame->mTexture->getHeight()); if( (framePitch == rect->pitch) && (height == maxHeight) ) dMemcpy( rect->bits, frame->data, rect->pitch * height ); else { // Scanline length does not match. Copy line by line. U8* dst = rect->bits; U8* src = ( U8* ) frame->data; // Center the video if it is too big for the texture mode if ( height > maxHeight ) src += framePitch * ((height - maxHeight) / 2); if ( framePitch > usePitch ) src += (framePitch - usePitch) / 2; for( U32 i = 0; i < maxHeight; ++ i ) { dMemcpy( dst, src, usePitch ); dst += rect->pitch; src += framePitch; } } } #ifdef TORQUE_DEBUG else Platform::outputDebugString( "[TheoraTexture] texture not locked on frame %i", frame->mFrameNumber ); #endif // Copy frame metrics. mFrame->mFrameNumber = frame->mFrameNumber; mFrame->mFrameTime = frame->mFrameTime; mFrame->mFrameDuration = frame->mFrameDuration; // Yield the frame packet back to the Theora decoder. decoder->reusePacket( frame ); // Buffer the frame. mFrameStream->_onArrival( mFrame ); }
/** Set rotation for certain nodes in a function space * * @param fs the function space * @param is index set of nodes to rotate, sequential, with respect blocks of local vector * @param rot Rotation matrices at all nodes in \a is. Should have length \c bs*bs*size(is). * @param ns number of dofs to enforce strongly at each node (every entry must have 0<=ns[i]<=bs) * @param v Vector of values for strongly enforced dofs * * @example Consider 2D flow over a bed with known melt rates. Suppose the local velocity vector is * * [u0x,u0y; u1x,u1y; u2x,u2y; u3x,u3y | u4x,u4y] * * (4 owned blocks, one ghosted block) and nodes 1,4 are on the slip boundary with normal and tangent vectors n1,t1,n4,t4 * and melt rates r1,r4. To enforce the melt rate strongly, use * * \a is = [1,4] * \a rot = [n10,n11,t10,t11, n40,n41,t40,t41] * \a ns = [1,1] * \a v = [r1,r4] * * The rotated vector will become (. = \cdot) * * [u0x,u0y; u1.n1,u1.t1; u2x,u2y; u3x,u3y | u4.n4,u4.t4] * * and strongly enforcing melt rate produces the global vector * * [u0x,u0y; r1,u1.t1; u2x,u2y; u3x,u3y | r4,u4.t4] . * * This is what the solver sees, the Jacobian will always have rows and columns of the identity corresponding to the * strongly enforced components (2,8 of the local vector) and the residual will always be 0 in these components. Hence * the Newton step v will always be of the form * * [v0x,v0y; 0,v1y; v2x,v2y; v3x,v3y | 0,v4y] . **/ dErr dFSRotationCreate(dFS fs,IS is,dReal rmat[],dInt ns[],Vec v,dFSRotation *inrot) { dFSRotation rot; dInt bs,n; dErr err; dFunctionBegin; dValidHeader(fs,DM_CLASSID,1); dValidHeader(is,IS_CLASSID,2); dValidRealPointer(rmat,3); dValidIntPointer(ns,4); dValidHeader(v,VEC_CLASSID,5); dValidPointer(inrot,6); *inrot = 0; err = PetscHeaderCreate(rot,_p_dFSRotation,struct _dFSRotationOps,dFSROT_CLASSID,"dFSRotation","Local function space rotation","FS",PETSC_COMM_SELF,dFSRotationDestroy,dFSRotationView);dCHK(err); err = dFSGetBlockSize(fs,&bs);dCHK(err); rot->bs = bs; err = ISGetSize(is,&n);dCHK(err); rot->n = n; err = PetscObjectReference((PetscObject)is);dCHK(err); rot->is = is; err = PetscObjectReference((PetscObject)v);dCHK(err); rot->strong = v; for (dInt i=0; i<n; i++) { if (ns[i] < 0 || bs < ns[i]) dERROR(PETSC_COMM_SELF,1,"Number of strong dofs must be between 0 and bs=%d (inclusive)",bs); /* \todo Check that every rmat is orthogonal */ } err = dMallocA2(n*bs*bs,&rot->rmat,n,&rot->nstrong);dCHK(err); err = dMemcpy(rot->rmat,rmat,n*bs*bs*sizeof rmat[0]);dCHK(err); err = dMemcpy(rot->nstrong,ns,n*sizeof ns[0]);dCHK(err); *inrot = rot; dFunctionReturn(0); }
//************************************************************************** // General operation //************************************************************************** GenOp::GenOp( const char * statement, ... ) : Parent( NULL, NULL ) { VECTOR_SET_ASSOCIATION( mElemList ); va_list args; va_start(args, statement); char* lastEntry = (char*)statement; while( 1 ) { // search 'statement' for @ symbol char * str = dStrstr( lastEntry, (char *)"@" ); if( !str ) { // not found, handle end of line str = (char*)&statement[ dStrlen( (char*)statement ) ]; U64 diff = str - lastEntry + 1; if( diff == 1 ) break; char * newStr = new char[diff]; dMemcpy( (void*)newStr, lastEntry, diff ); mElemList.push_back( new EchoOp( newStr ) ); break; } // create and store statement fragment U64 diff = str - lastEntry + 1; if( diff == 1 ) { // store langElement LangElement *elem = va_arg(args, LangElement* ); AssertFatal( elem, "NULL arguement." ); mElemList.push_back( elem ); lastEntry++; continue; } char * newStr = new char[diff]; dMemcpy( (void*)newStr, lastEntry, diff ); newStr[diff-1] = '\0'; lastEntry = str + 1; mElemList.push_back( new EchoOp( newStr ) ); // store langElement LangElement *elem = va_arg(args, LangElement* ); AssertFatal( elem, "NULL argument." ); mElemList.push_back( elem ); }
bool GFXD3D9ShaderBufferLayout::setMatrix(const ParamDesc& pd, const GFXShaderConstType constType, const U32 size, const void* data, U8* basePointer) { PROFILE_SCOPE(GFXD3D9ShaderBufferLayout_setMatrix); if (pd.constType == GFXSCT_Float4x4) { // Special case, we can just blast this guy. AssertFatal(pd.size >= size, "Not enough room in the buffer for this data!"); if (dMemcmp(basePointer+pd.offset, data, size) != 0) { dMemcpy(basePointer+pd.offset, data, size); return true; } return false; } else { PROFILE_SCOPE(GFXD3D9ShaderBufferLayout_setMatrix_not4x4); // Figure out how big of a chunk we are copying. We're going to copy 4 columns by N rows of data U32 csize; switch (pd.constType) { case GFXSCT_Float2x2 : csize = 32; break; case GFXSCT_Float3x3 : csize = 48; break; default: AssertFatal(false, "Unhandled case!"); return false; break; } // Loop through and copy bool ret = false; U8* currDestPointer = basePointer+pd.offset; const U8* currSourcePointer = static_cast<const U8*>(data); const U8* endData = currSourcePointer + size; while (currSourcePointer < endData) { if (dMemcmp(currDestPointer, currSourcePointer, csize) != 0) { dMemcpy(currDestPointer, currSourcePointer, csize); ret = true; } currDestPointer += csize; currSourcePointer += sizeof(MatrixF); } return ret; } }
//----------------------------------------------------------------------------- // This function should ONLY be called from GFXDevice::updateStates() !!! //----------------------------------------------------------------------------- void GFXD3D9Device::setLightInternal(U32 lightStage, const GFXLightInfo light, bool lightEnable) { #ifndef TORQUE_OS_XENON if(!lightEnable) { mD3DDevice->LightEnable(lightStage, false); return; } D3DLIGHT9 d3dLight; switch (light.mType) { case GFXLightInfo::Ambient: AssertFatal(false, "Instead of setting an ambient light you should set the global ambient color."); return; case GFXLightInfo::Vector: d3dLight.Type = D3DLIGHT_DIRECTIONAL; break; case GFXLightInfo::Point: d3dLight.Type = D3DLIGHT_POINT; break; case GFXLightInfo::Spot: d3dLight.Type = D3DLIGHT_SPOT; break; default : AssertFatal(false, "Unknown light type!"); }; dMemcpy(&d3dLight.Diffuse, &light.mColor, sizeof(light.mColor)); dMemcpy(&d3dLight.Ambient, &light.mAmbient, sizeof(light.mAmbient)); dMemcpy(&d3dLight.Specular, &light.mColor, sizeof(light.mColor)); dMemcpy(&d3dLight.Position, &light.mPos, sizeof(light.mPos)); dMemcpy(&d3dLight.Direction, &light.mDirection, sizeof(light.mDirection)); d3dLight.Range = light.mRadius; d3dLight.Falloff = 1.0; d3dLight.Attenuation0 = 1.0f; d3dLight.Attenuation1 = 0.1f; d3dLight.Attenuation2 = 0.0f; d3dLight.Theta = light.mInnerConeAngle; d3dLight.Phi = light.mOuterConeAngle; mD3DDevice->SetLight(lightStage, &d3dLight); mD3DDevice->LightEnable(lightStage, true); #endif }
void vertexBufferCopy(vertexType vtype) { PROFILE_SCOPE(Terrain_vbufferCopy); // Do vertexes if (vtype == vertexTypeFullClipMapping) { GVertexBufferHandle<GAtlasVert2> v(GRAPHIC, mCurVertex, GBufferTypeVolatile); PROFILE_START(Terrain_bufferCopy_lockV); v.lock(); PROFILE_END(); dMemcpy(&v[0], &mVertexStore[0], sizeof(GAtlasVert2) * mCurVertex); PROFILE_START(Terrain_bufferCopy_unlockV); v.unlock(); PROFILE_END(); GRAPHIC->setVertexBuffer(v); } else if (vtype == vertexTypeDLight) { GVertexBufferHandle<GVertexPCNTT> vPCNTT(GRAPHIC, mCurVertex, GBufferTypeVolatile); PROFILE_START(Terrain_bufferCopy_lockVPCNTT); vPCNTT.lock(); PROFILE_END(); dMemcpy(&vPCNTT[0], &mVertexStorePCNTT[0], sizeof(GVertexPCNTT) * mCurVertex); PROFILE_START(Terrain_bufferCopy_unlockVPCNTT); vPCNTT.unlock(); PROFILE_END(); GRAPHIC->setVertexBuffer(vPCNTT); } else { GVertexBufferHandle<GVertexPCNT> vPCNT(GRAPHIC, mCurVertex, GBufferTypeVolatile); PROFILE_START(Terrain_bufferCopy_lockVPCNT); vPCNT.lock(); PROFILE_END(); dMemcpy(&vPCNT[0], &mVertexStorePCNT[0], sizeof(GVertexPCNT) * mCurVertex); PROFILE_START(Terrain_bufferCopy_unlockVPCNT); vPCNT.unlock(); PROFILE_END(); GRAPHIC->setVertexBuffer(vPCNT); } }
void LightFlareData::_makePrimBuffer( GFXPrimitiveBufferHandle *pb, U32 count ) { // create index buffer based on that size U32 indexListSize = count * 6; // 6 indices per particle U16 *indices = new U16[ indexListSize ]; for ( U32 i = 0; i < count; i++ ) { // this index ordering should be optimal (hopefully) for the vertex cache U16 *idx = &indices[i*6]; volatile U32 offset = i * 4; // set to volatile to fix VC6 Release mode compiler bug idx[0] = 0 + offset; idx[1] = 1 + offset; idx[2] = 3 + offset; idx[3] = 1 + offset; idx[4] = 3 + offset; idx[5] = 2 + offset; } U16 *ibIndices; GFXBufferType bufferType = GFXBufferTypeStatic; #ifdef TORQUE_OS_XENON // Because of the way the volatile buffers work on Xenon this is the only // way to do this. bufferType = GFXBufferTypeVolatile; #endif pb->set( GFX, indexListSize, 0, bufferType ); pb->lock( &ibIndices ); dMemcpy( ibIndices, indices, indexListSize * sizeof(U16) ); pb->unlock(); delete [] indices; }
U32 MemFile::write(const void* src, U32 size) { if ((mStatus != Open && mStatus != EndOfFile) || !size) return 0; if (mFileData->mFileSize + size > mFileData->mBufferSize) { // Keep doubling our buffer size until we're big enough. while (mFileData->mFileSize + size > mFileData->mBufferSize) mFileData->mBufferSize *= 2; mFileData->mBuffer = dRealloc(mFileData->mBuffer, mFileData->mBufferSize); if (!mFileData->mBuffer) { mStatus = FileSystemFull; return 0; } } dMemcpy((U8*)mFileData->mBuffer + mCurrentPos, src, size); mCurrentPos += size; mFileData->mFileSize = getMax(mFileData->mFileSize, mCurrentPos); mFileData->mLastAccess = Time::getCurrentTime(); mFileData->mModified = mFileData->mLastAccess; return size; }
GBitmap::GBitmap(const GBitmap& rCopy) { mInternalFormat = rCopy.mInternalFormat; mByteSize = rCopy.mByteSize; mBits = new U8[mByteSize]; dMemcpy(mBits, rCopy.mBits, mByteSize); mWidth = rCopy.mWidth; mHeight = rCopy.mHeight; mBytesPerPixel = rCopy.mBytesPerPixel; mNumMipLevels = rCopy.mNumMipLevels; dMemcpy(mMipLevelOffsets, rCopy.mMipLevelOffsets, sizeof(mMipLevelOffsets)); mHasTransparency = rCopy.mHasTransparency; }
bool NetAsync::checkLookup(NetSocket socket, char* out_h_addr, int* out_h_length, int out_h_addr_size) { bool found = false; // search for the socket RequestIterator iter; for (iter = mLookupRequests.begin(); iter != mLookupRequests.end(); ++iter) // if we found it and it is complete... if (socket == iter->sock && iter->complete) { // copy the lookup data to the callers parameters dMemcpy(out_h_addr, iter->out_h_addr, out_h_addr_size); *out_h_length = iter->out_h_length; found = true; break; } // we found the socket, so we are done with it. erase. if (found) mLookupRequests.erase(iter); return found; }
void GFXD3D9ShaderConstBuffer::set(GFXShaderConstHandle* handle, const MatrixF& mat, const GFXShaderConstType matrixType) { AssertFatal(handle, "Handle is NULL!" ); AssertFatal(handle->isValid(), "Handle is not valid!" ); AssertFatal(dynamic_cast<const GFXD3D9ShaderConstHandle*>(handle), "Incorrect const buffer type!"); const GFXD3D9ShaderConstHandle* h = static_cast<const GFXD3D9ShaderConstHandle*>(handle); AssertFatal(!h->isSampler(), "Handle is sampler constant!" ); AssertFatal(h->mShader == mShader, "Mismatched shaders!"); MatrixF transposed; mat.transposeTo(transposed); if (h->mInstancingConstant) { if ( matrixType == GFXSCT_Float4x4 ) dMemcpy( mInstPtr+h->mPixelHandle.offset, mat, sizeof( mat ) ); // TODO: Support 3x3 and 2x2 matricies? return; } if (h->mVertexConstant) mVertexConstBufferF->set(h->mVertexHandle, transposed, matrixType); if (h->mPixelConstant) mPixelConstBufferF->set(h->mPixelHandle, transposed, matrixType); }
void BitVector::_resize( U32 sizeInBits, bool copyBits ) { if ( sizeInBits != 0 ) { U32 newSize = calcByteSize( sizeInBits ); if ( mByteSize < newSize ) { U8 *newBits = new U8[newSize]; if( copyBits ) dMemcpy( newBits, mBits, mByteSize ); delete [] mBits; mBits = newBits; mByteSize = newSize; } } else { delete [] mBits; mBits = NULL; mByteSize = 0; } mSize = sizeInBits; }
//-------------------------------------- bool Platform::createPath(const char *file) { TempAlloc< TCHAR > pathbuf( dStrlen( file ) + 1 ); #ifdef UNICODE TempAlloc< WCHAR > fileBuf( pathbuf.size ); convertUTF8toUTF16( file, fileBuf, fileBuf.size ); const WCHAR* fileName = fileBuf; const WCHAR* dir; #else const char* fileName = file; const char* dir; #endif pathbuf[ 0 ] = 0; U32 pathLen = 0; while((dir = dStrchr(fileName, '/')) != NULL) { TCHAR* pathptr = pathbuf; dMemcpy( pathptr + pathLen, fileName, ( dir - fileName ) * sizeof( TCHAR ) ); pathbuf[pathLen + dir-fileName] = 0; // ignore return value because we are fine with already existing directory CreateDirectory(pathbuf, NULL); pathLen += dir - fileName; pathbuf[pathLen++] = '\\'; fileName = dir + 1; } return true; }
void GFXGLShaderConstBuffer::set(GFXShaderConstHandle* handle, const MatrixF& mat, const GFXShaderConstType matType) { AssertFatal(handle, "GFXGLShaderConstBuffer::set - Handle is NULL!" ); AssertFatal(handle->isValid(), "GFXGLShaderConstBuffer::set - Handle is not valid!" ); AssertFatal(dynamic_cast<GFXGLShaderConstHandle*>(handle), "GFXGLShaderConstBuffer::set - Incorrect const buffer type"); GFXGLShaderConstHandle* _glHandle = static_cast<GFXGLShaderConstHandle*>(handle); AssertFatal(mShader == _glHandle->mShader, "GFXGLShaderConstBuffer::set - Should only set handles which are owned by our shader"); AssertFatal(!_glHandle->mInstancingConstant || matType == GFXSCT_Float4x4, "GFXGLShaderConstBuffer::set - Only support GFXSCT_Float4x4 for instancing"); switch(matType) { case GFXSCT_Float2x2: reinterpret_cast<F32*>(mBuffer + _glHandle->mOffset)[0] = mat[0]; reinterpret_cast<F32*>(mBuffer + _glHandle->mOffset)[1] = mat[1]; reinterpret_cast<F32*>(mBuffer + _glHandle->mOffset)[2] = mat[4]; reinterpret_cast<F32*>(mBuffer + _glHandle->mOffset)[3] = mat[5]; break; case GFXSCT_Float3x3: reinterpret_cast<F32*>(mBuffer + _glHandle->mOffset)[0] = mat[0]; reinterpret_cast<F32*>(mBuffer + _glHandle->mOffset)[1] = mat[1]; reinterpret_cast<F32*>(mBuffer + _glHandle->mOffset)[2] = mat[2]; reinterpret_cast<F32*>(mBuffer + _glHandle->mOffset)[3] = mat[4]; reinterpret_cast<F32*>(mBuffer + _glHandle->mOffset)[4] = mat[5]; reinterpret_cast<F32*>(mBuffer + _glHandle->mOffset)[5] = mat[6]; reinterpret_cast<F32*>(mBuffer + _glHandle->mOffset)[6] = mat[8]; reinterpret_cast<F32*>(mBuffer + _glHandle->mOffset)[7] = mat[9]; reinterpret_cast<F32*>(mBuffer + _glHandle->mOffset)[8] = mat[10]; break; case GFXSCT_Float4x4: { if(_glHandle->mInstancingConstant) { MatrixF transposed; mat.transposeTo(transposed); dMemcpy( mInstPtr + _glHandle->mOffset, (const F32*)transposed, sizeof(MatrixF) ); return; } dMemcpy(mBuffer + _glHandle->mOffset, (const F32*)mat, sizeof(MatrixF)); break; } default: AssertFatal(false, "GFXGLShaderConstBuffer::set - Invalid matrix type"); break; } }
void GFXGLShader::setConstantsFromBuffer(GFXGLShaderConstBuffer* buffer) { for(Vector<GFXGLShaderConstHandle*>::iterator i = mValidHandles.begin(); i != mValidHandles.end(); ++i) { GFXGLShaderConstHandle* handle = *i; AssertFatal(handle, "GFXGLShader::setConstantsFromBuffer - Null handle"); if(handle->mInstancingConstant) continue; // Don't set if the value has not be changed. if(dMemcmp(mConstBuffer + handle->mOffset, buffer->mBuffer + handle->mOffset, handle->getSize()) == 0) continue; // Copy new value into our const buffer and set in GL. dMemcpy(mConstBuffer + handle->mOffset, buffer->mBuffer + handle->mOffset, handle->getSize()); switch(handle->mDesc.constType) { case GFXSCT_Float: glUniform1fv(handle->mLocation, handle->mDesc.arraySize, (GLfloat*)(mConstBuffer + handle->mOffset)); break; case GFXSCT_Float2: glUniform2fv(handle->mLocation, handle->mDesc.arraySize, (GLfloat*)(mConstBuffer + handle->mOffset)); break; case GFXSCT_Float3: glUniform3fv(handle->mLocation, handle->mDesc.arraySize, (GLfloat*)(mConstBuffer + handle->mOffset)); break; case GFXSCT_Float4: glUniform4fv(handle->mLocation, handle->mDesc.arraySize, (GLfloat*)(mConstBuffer + handle->mOffset)); break; case GFXSCT_Int: case GFXSCT_Sampler: case GFXSCT_SamplerCube: glUniform1iv(handle->mLocation, handle->mDesc.arraySize, (GLint*)(mConstBuffer + handle->mOffset)); break; case GFXSCT_Int2: glUniform2iv(handle->mLocation, handle->mDesc.arraySize, (GLint*)(mConstBuffer + handle->mOffset)); break; case GFXSCT_Int3: glUniform3iv(handle->mLocation, handle->mDesc.arraySize, (GLint*)(mConstBuffer + handle->mOffset)); break; case GFXSCT_Int4: glUniform4iv(handle->mLocation, handle->mDesc.arraySize, (GLint*)(mConstBuffer + handle->mOffset)); break; case GFXSCT_Float2x2: glUniformMatrix2fv(handle->mLocation, handle->mDesc.arraySize, true, (GLfloat*)(mConstBuffer + handle->mOffset)); break; case GFXSCT_Float3x3: glUniformMatrix3fv(handle->mLocation, handle->mDesc.arraySize, true, (GLfloat*)(mConstBuffer + handle->mOffset)); break; case GFXSCT_Float4x4: glUniformMatrix4fv(handle->mLocation, handle->mDesc.arraySize, true, (GLfloat*)(mConstBuffer + handle->mOffset)); break; default: AssertFatal(0,""); break; } } }
void TerrainFile::setHeightMap( const Vector<U16> &heightmap, bool updateCollision ) { AssertFatal( mHeightMap.size() == heightmap.size(), "TerrainFile::setHeightMap - Incorrect heightmap size!" ); dMemcpy( mHeightMap.address(), heightmap.address(), mHeightMap.size() ); if ( updateCollision ) _buildGridMap(); }
void operator =(const UTF16Cache &other) { delete [] mString; mLength = other.mLength; mString = new UTF16[mLength]; dMemcpy(mString, other.mString, mLength * sizeof(UTF16)); }
void copyToBuffer(UTF16 *outBuffer, U32 lenToCopy, bool nullTerminate = true) const { U32 copy = getMin(mLength, lenToCopy); if(mString && copy > 0) dMemcpy(outBuffer, mString, copy * sizeof(UTF16)); if(nullTerminate) outBuffer[copy] = 0; }
virtual void execute() { #ifndef TORQUE_OS_XENON // do it struct hostent* hostent = gethostbyname(mRequest.remoteAddr); if (hostent == NULL) { // oh well! leave the lookup data unmodified (h_length) should // still be -1 from initialization mRequest.complete = true; } else { // copy the stuff we need from the hostent dMemset(mRequest.out_h_addr, 0, sizeof(mRequest.out_h_addr)); dMemcpy(mRequest.out_h_addr, hostent->h_addr, hostent->h_length); mRequest.out_h_length = hostent->h_length; mRequest.complete = true; } #else XNDNS *pxndns = NULL; HANDLE hEvent = CreateEvent(NULL, false, false, NULL); XNetDnsLookup(mRequest.remoteAddr, hEvent, &pxndns); while(pxndns->iStatus == WSAEINPROGRESS) WaitForSingleObject(hEvent, INFINITE); if(pxndns->iStatus == 0 && pxndns->cina > 0) { dMemset(mRequest.out_h_addr, 0, sizeof(mRequest.out_h_addr)); // This is a suspect section. I need to revisit. [2/22/2010 Pat] dMemcpy(mRequest.out_h_addr, pxndns->aina, sizeof(IN_ADDR)); mRequest.out_h_length = sizeof(IN_ADDR); } mRequest.complete = true; XNetDnsRelease(pxndns); CloseHandle(hEvent); #endif }
void PxCloth::_updateVBIB() { PROFILE_SCOPE( PxCloth_UpdateVBIB ); mIsVBDirty = false; // Don't set the VB if the vertex count is the same! if ( mVB.isNull() || mVB->mNumVerts < mNumVertices ) mVB.set( GFX, mNumVertices, GFXBufferTypeDynamic ); GFXVertexPNTT *vert = mVertexRenderBuffer; GFXVertexPNTT *secondVert = NULL; for ( U32 i = 0; i < mNumVertices; i++ ) { if ( i % (U32)mPatchSize.x == 0 && i != 0 ) { secondVert = vert; secondVert--; vert->tangent = -(vert->point - secondVert->point); } else { secondVert = vert; secondVert++; vert->tangent = vert->point - secondVert->point; } vert->tangent.normalize(); vert++; } GFXVertexPNTT *vpPtr = mVB.lock(); dMemcpy( vpPtr, mVertexRenderBuffer, sizeof( GFXVertexPNTT ) * mNumVertices ); mVB.unlock(); if ( mPrimBuffer.isNull() || mPrimBuffer->mIndexCount < mNumIndices ) mPrimBuffer.set( GFX, mNumIndices, 0, GFXBufferTypeDynamic ); U16 *pbPtr; mPrimBuffer.lock( &pbPtr ); dMemcpy( pbPtr, mIndexRenderBuffer, sizeof( U16 ) * mNumIndices ); mPrimBuffer.unlock(); }
void SceneCullingState::debugRenderCullingVolumes() const { const ColorI occluderColor( 255, 0, 0, 255 ); const ColorI includerColor( 0, 255, 0, 255 ); const PlaneF& nearPlane = getCullingFrustum().getPlanes()[ Frustum::PlaneNear ]; const PlaneF& farPlane = getCullingFrustum().getPlanes()[ Frustum::PlaneFar ]; DebugDrawer* drawer = DebugDrawer::get(); const SceneZoneSpaceManager* zoneManager = mSceneManager->getZoneManager(); bool haveDebugZone = false; const U32 numZones = mZoneStates.size(); for( S32 zoneId = numZones - 1; zoneId >= 0; -- zoneId ) { if( !zoneManager->isValidZoneId( zoneId ) ) continue; const SceneZoneCullingState& zoneState = mZoneStates[ zoneId ]; if( !zoneManager->getZoneOwner( zoneId )->isSelected() && ( zoneId != SceneZoneSpaceManager::RootZoneId || haveDebugZone ) ) continue; haveDebugZone = true; for( SceneZoneCullingState::CullingVolumeIterator iter( zoneState ); iter.isValid(); ++ iter ) { // Temporarily add near and far plane to culling volume so that // no matter how it is defined, it has a chance of being properly // capped. const U32 numPlanes = iter->getPlanes().getNumPlanes(); const PlaneF* planes = iter->getPlanes().getPlanes(); TempAlloc< PlaneF > tempPlanes( numPlanes + 2 ); tempPlanes[ 0 ] = nearPlane; tempPlanes[ 1 ] = farPlane; dMemcpy( &tempPlanes[ 2 ], planes, numPlanes * sizeof( PlaneF ) ); // Build a polyhedron from the plane set. Polyhedron polyhedron; polyhedron.buildFromPlanes( PlaneSetF( tempPlanes, numPlanes + 2 ) ); // If the polyhedron has any renderable data, // hand it over to the debug drawer. if( polyhedron.getNumEdges() ) drawer->drawPolyhedron( polyhedron, iter->isOccluder() ? occluderColor : includerColor ); } } }
ShadowVolumeBSP::SVPoly * ShadowVolumeBSP::copyPoly(SVPoly * src) { SVPoly * poly = createPoly(); dMemcpy(poly, src, sizeof(SVPoly)); poly->mTarget = 0; poly->mNext = 0; return(poly); }
void GFXGLShaderConstBuffer::internalSet(GFXShaderConstHandle* handle, const ConstType& param) { AssertFatal(handle, "GFXGLShaderConstBuffer::internalSet - Handle is NULL!" ); AssertFatal(handle->isValid(), "GFXGLShaderConstBuffer::internalSet - Handle is not valid!" ); AssertFatal(dynamic_cast<GFXGLShaderConstHandle*>(handle), "GFXGLShaderConstBuffer::set - Incorrect const buffer type"); GFXGLShaderConstHandle* _glHandle = static_cast<GFXGLShaderConstHandle*>(handle); AssertFatal(mShader == _glHandle->mShader, "GFXGLShaderConstBuffer::set - Should only set handles which are owned by our shader"); dMemcpy(mBuffer + _glHandle->mOffset, ¶m, sizeof(ConstType)); }
void GFXCopyPixels( GFXFormat fromFormat, U32 fromWidth, U32 fromHeight, U8* fromData, GFXFormat toFormat, U32 toWidth, U32 toHeight, U8* toData ) { if( fromFormat == toFormat && fromWidth == toWidth && fromHeight == toHeight ) dMemcpy( toData, fromData, fromWidth * fromHeight * GFXFormatInfo( fromFormat ).getBytesPerPixel() ); else { AssertFatal( false, "Not implemented" ); } }
static const char * prependPercent ( const char * name ) { if(name[0] != '%') { S32 len = dStrlen(name); AssertFatal(len < sizeof(scratchBuffer)-2, "CONSOLE: name too long"); scratchBuffer[0] = '%'; dMemcpy(scratchBuffer + 1, name, len + 1); name = scratchBuffer; } return name; }
GFXGLShaderConstBuffer::GFXGLShaderConstBuffer(GFXGLShader* shader, U32 bufSize, U8* existingConstants) { mShader = shader; mBuffer = new U8[bufSize]; mWasLost = true; // Copy the existing constant buffer to preserve sampler numbers /// @warning This preserves a lot more than sampler numbers, obviously. If there /// is any code that assumes a new constant buffer will have everything set to /// 0, it will break. dMemcpy(mBuffer, existingConstants, bufSize); }
const char *ProjectileData::getScaledValue( void *obj, const char *data) { S32 value = dAtoi(data); value = scaleValue(value, false); String stringData = String::ToString(value); char *strBuffer = Con::getReturnBuffer(stringData.size()); dMemcpy( strBuffer, stringData, stringData.size() ); return strBuffer; }
TSMaterialList::TSMaterialList(U32 materialCount, const char **materialNames, const U32 * materialFlags, const U32 * reflectanceMaps, const U32 * bumpMaps, const U32 * detailMaps, const F32 * detailScales, const F32 * reflectionAmounts) : MaterialList(materialCount,materialNames), mNamesTransformed(false) { VECTOR_SET_ASSOCIATION(mFlags); VECTOR_SET_ASSOCIATION(mReflectanceMaps); VECTOR_SET_ASSOCIATION(mBumpMaps); VECTOR_SET_ASSOCIATION(mDetailMaps); VECTOR_SET_ASSOCIATION(mDetailScales); VECTOR_SET_ASSOCIATION(mReflectionAmounts); allocate(materialCount); dMemcpy(mFlags.address(),materialFlags,materialCount*sizeof(U32)); dMemcpy(mReflectanceMaps.address(),reflectanceMaps,materialCount*sizeof(U32)); dMemcpy(mBumpMaps.address(),bumpMaps,materialCount*sizeof(U32)); dMemcpy(mDetailMaps.address(),detailMaps,materialCount*sizeof(U32)); dMemcpy(mDetailScales.address(),detailScales,materialCount*sizeof(F32)); dMemcpy(mReflectionAmounts.address(),reflectionAmounts,materialCount*sizeof(F32)); }
U32 MemFile::read(void* dst, U32 size) { if (mStatus != Open && mStatus != EndOfFile) return 0; U32 copyAmount = getMin(size, mFileData->mFileSize - mCurrentPos); dMemcpy(dst, (U8*) mFileData->mBuffer + mCurrentPos, copyAmount); mCurrentPos += copyAmount; mFileData->mLastAccess = Time::getCurrentTime(); if (mCurrentPos == mFileData->mFileSize) mStatus = EndOfFile; return copyAmount; }