void SelectionRenderer::update(const SPtr<Camera>& camera) { Vector<ObjectData> objects; const Vector<HSceneObject>& sceneObjects = Selection::instance().getSceneObjects(); const Map<Renderable*, SceneRenderableData>& renderables = SceneManager::instance().getAllRenderables(); for (auto& renderable : renderables) { for (auto& so : sceneObjects) { if (!so->getActive()) continue; if (renderable.second.sceneObject != so) continue; if (renderable.first->getMesh().isLoaded()) { objects.push_back(ObjectData()); ObjectData& newObjData = objects.back(); newObjData.worldTfrm = so->getWorldTfrm(); newObjData.mesh = renderable.first->getMesh()->getCore(); } } } SelectionRendererCore* core = mCore.load(std::memory_order_relaxed); gCoreAccessor().queueCommand(std::bind(&SelectionRendererCore::updateData, core, camera->getCore(), objects)); }
void OHLocationServiceCache::objectAdded( const ObjectReference& uuid, bool agg, const TimedMotionVector3f& loc, uint64 loc_seqno, const TimedMotionQuaternion& orient, uint64 orient_seqno, const BoundingSphere3f& bounds, uint64 bounds_seqno, const Transfer::URI& mesh, uint64 mesh_seqno, const String& physics, uint64 physics_seqno ) { Lock lck(mMutex); ObjectDataMap::iterator it = mObjects.find(uuid); if (it != mObjects.end()) return; it = mObjects.insert( ObjectDataMap::value_type(uuid, ObjectData()) ).first; it->second.props.setLocation(loc, loc_seqno); it->second.props.setOrientation(orient, orient_seqno); it->second.props.setBounds(bounds, bounds_seqno); it->second.props.setMesh(mesh, mesh_seqno); it->second.props.setPhysics(physics, physics_seqno); it->second.aggregate = agg; if (!agg) { it->second.tracking++; mStrand->post( std::tr1::bind( &OHLocationServiceCache::notifyObjectAdded, this, uuid, loc, bounds ), "OHLocationServiceCache::notifyObjectAdded" ); } }
void ObjectDataArrayMemoryManager::destroyNode( ObjectData &inOutData ) { //Zero out important data that would lead to bugs (Remember SIMD SoA means even if //there's one object in scene, 4 objects are still parsed simultaneously) inOutData.mParents[inOutData.mIndex] = mDummyNode; inOutData.mOwner[inOutData.mIndex] = mDummyObject; inOutData.mVisibilityFlags[inOutData.mIndex] = 0; inOutData.mQueryFlags[inOutData.mIndex] = 0; inOutData.mLightMask[inOutData.mIndex] = 0; destroySlot( reinterpret_cast<char*>(inOutData.mParents), inOutData.mIndex ); //Zero out all pointers inOutData = ObjectData(); }
/////////////////////// // IO SERVICE THREAD // void Game::receiveHandlerTCP(const boost::system::error_code& error, std::size_t bytes) { //Handle data sent by the server size_t offset = 0;//Byte offset from buffer begin do { offset += 1; switch (packet::PacketType(receiveBufferTCP[offset - 1])) { default: case packet::invalid: spehs::console::error(__FUNCTION__" invalid packet type!"); break; case packet::enterID: { std::lock_guard<std::recursive_mutex> IDLockGuardMutex(idMutex); memcpy(&ID, &receiveBufferTCP[offset], sizeof(sizeof(ID))); offset += sizeof(CLIENT_ID_TYPE); } break; case packet::createObj: { std::lock_guard<std::recursive_mutex> objectLockGuardMutex(objectMutex); unsigned count; memcpy(&count, &receiveBufferTCP[offset], sizeof(unsigned)); offset += sizeof(unsigned); for (unsigned i = 0; i < count; i++) { newObjects.push_back(ObjectData()); memcpy(&newObjects.back(), &receiveBufferTCP[offset], sizeof(ObjectData)); offset += sizeof(ObjectData); } } break; } } while (offset < bytes); //Start receiving again if (checkBit(state, GAME_EXIT_BIT)) socketTCP.async_receive( boost::asio::buffer(receiveBufferTCP), boost::bind(&Game::receiveHandlerTCP, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)); }
bool ImporterOBJ::ReadInfileAndElementCounts() { std::ifstream fin; int objectCount = 0; bool result; char input1; char input2; int currentPos = 0; int startline = 0; int endline = 0; int i,j,k,objectListSize,lineSize; std::string line; //Open file fin.open(filename,std::ios::in); result = fin.fail(); //Check if we openend file right. if(fin.fail() == true) return false; std::getline(fin,line); fileLines.push_back(line); startline += 1; //see how many objects there are and push the string info fileLines while(!fin.eof()) { if(line[0] == 'o') { objectDataList.push_back(ObjectData()); objectLineStart.push_back(startline); } std::getline(fin,line); fileLines.push_back(line); startline += 1; } fin.close(); objectLineStart.push_back(startline); objectListSize = objectDataList.size(); return true; }
void ReplicatedLocationServiceCache::objectAdded( const ObjectReference& uuid, bool agg, const ObjectReference& parent, const TimedMotionVector3f& loc, uint64 loc_seqno, const TimedMotionQuaternion& orient, uint64 orient_seqno, const AggregateBoundingInfo& bounds, uint64 bounds_seqno, const Transfer::URI& mesh, uint64 mesh_seqno, const String& physics, uint64 physics_seqno ) { Lock lck(mMutex); ObjectDataMap::iterator it = mObjects.find(uuid); assert(it == mObjects.end() || (it->second.exists == false)); if (it == mObjects.end()) it = mObjects.insert( ObjectDataMap::value_type(uuid, ObjectData()) ).first; else it->second.props = SequencedPresenceProperties(); // reset it->second.exists = true; it->second.props.setLocation(loc, loc_seqno); it->second.props.setOrientation(orient, orient_seqno); it->second.props.setBounds(bounds, bounds_seqno); it->second.props.setMesh(mesh, mesh_seqno); it->second.props.setPhysics(physics, physics_seqno); it->second.aggregate = agg; it->second.parent = parent; it->second.tracking++; mStrand->post( std::tr1::bind( &ReplicatedLocationServiceCache::notifyObjectAdded, this, livenessToken(), uuid, parent, agg, loc, bounds ), "ReplicatedLocationServiceCache::notifyObjectAdded" ); }
void GLScene::add(GLDrawable & target) { data.push_back(ObjectData()); objects.push_back(&target); }
bool ParseAnimationFile (std::wifstream& in, ImportedObjectData* d) { std::wstring flag; bool result = true; int vCount = 0; int currFrame = -1; int currObject = -1; int currAnimation = -1; int currMaterial = -1; int totMeshCount = -1; while(!in.eof()) { in >> flag; if(in.eof()) break; if(flag == ObjImpFormat::vertexCount) { if(!ParseInteger(in, vCount)) { DisplayText("File:\n" + in.getloc().name() + "\nDoes not contain any vertex information"); return false; } } else if(flag == ObjImpFormat::animation) { currAnimation++; int frameCount = 0; if(!ParseInteger(in, d->animations[currAnimation].id)) return false; if(!ParseInteger(in, frameCount)) return false; if(!frameCount) return false; d->animations[currAnimation].frames.resize(frameCount); currFrame = -1; } else if(flag == ObjImpFormat::frame) { float frameTime = 0.0f; int frameNum = -1; if(!ParseInteger(in, frameNum)) return false; if(!ParseFloat(in, frameTime)) { char temp1[2]; _itoa_s(frameNum, temp1, 10); DisplayText("File:\n" + in.getloc().name() + "\nFrame: " + temp1 + "\nInvalid frame time"); return false; } if(frameTime < 0.0f) return false; d->objects.push_back(ObjectData()); currObject = (int)d->objects.size()-1; currFrame++; totMeshCount++; d->animations[currAnimation].frames[currFrame].frameNumber = frameNum; d->animations[currAnimation].frames[currFrame].frameTime = frameTime; d->animations[currAnimation].frames[currFrame].objectIndex = currFrame; d->objects[totMeshCount].vertex = new std::vector<VERTEX::VertexPNT>(vCount); d->objects[totMeshCount].material = currMaterial; } else if(flag == ObjImpFormat::material) { currMaterial = ParseMaterial(in); } else if(flag == ObjImpFormat::v) { result = ParseV(in,d->objects[totMeshCount]); } else if(flag == ObjImpFormat::vt) { result = ParseVT(in,d->objects[totMeshCount]); } else if(flag == ObjImpFormat::vn) { result = ParseVN(in,d->objects[totMeshCount]); } else if(flag == ObjImpFormat::comment) { ParseLine(in, true); } if(!result) return result; } return result; }
bool ExternalFileWriter::write(const osg::Object & obj, const Options * options, std::string * out_absolutePath, std::string * out_relativePath) { ObjectsSet::iterator it( _objects.find(&obj) ); if (it != _objects.end()) { // Object has already been passed to this method if (out_absolutePath) *out_absolutePath = it->second.absolutePath; if (out_relativePath) *out_relativePath = it->second.relativePath; return it->second.written; } // Object is a new entry // Get absolute source path WriteType type( getType(obj) ); std::string originalFileName( getFileName(obj, type) ); std::string absoluteSourcePath; if (_keepRelativePaths && !originalFileName.empty()) // if keepRelativePaths is false, absoluteSourcePath is not used, then we can skip this part { if (isAbsolutePath(originalFileName)) absoluteSourcePath = originalFileName; else absoluteSourcePath = concatPaths(_srcDirectory, originalFileName); absoluteSourcePath = getRealPath(convertFileNameToNativeStyle(absoluteSourcePath)); // getRealPath() here is only used to canonize the path, not to add current directory in front of relative paths, hence the "concatPaths(_srcDirectory, ...)" just above } // Compute destination paths from the source path std::string relativeDestinationPath; std::string absoluteDestinationPath; if (absoluteSourcePath.empty()) { // We have no name. Generate one. generateObjectName(relativeDestinationPath, absoluteDestinationPath, type); } else { // We have a name. if (_keepRelativePaths) { // We'll try to keep images relative path. relativeDestinationPath = getPathRelative(_srcDirectory, absoluteSourcePath); unsigned int nbDirsUp = countNbDirsUp(relativeDestinationPath); // TODO if nbDirsUp>nb dirs in _destDirectory, then issue a warning, and use simple file name if (nbDirsUp > _allowUpDirs) relativeDestinationPath = getSimpleFileName(absoluteSourcePath); } else { // We keep only the simple file name. relativeDestinationPath = getSimpleFileName(absoluteSourcePath); } absoluteDestinationPath = getRealPath(convertFileNameToNativeStyle( concatPaths(_destDirectory, relativeDestinationPath) )); // TODO Check for absolute paths collisions between multiple objects } // Write object bool written(false); if (!makeDirectoryForFile(absoluteDestinationPath)) { OSG_NOTICE << "Can't create directory for file '" << absoluteDestinationPath << "'. May fail creating the image file." << std::endl; } if (!doWrite(obj, type, absoluteDestinationPath, options)) { OSG_WARN << "Can't write file '" << absoluteDestinationPath << "'." << std::endl; } else written = true; // Add entry _objects.insert(ObjectsSet::value_type(&obj, ObjectData(absoluteDestinationPath, relativeDestinationPath, written))); _searchMap.insert(SearchMap::value_type(pathHash(absoluteDestinationPath), &obj)); // Fill output strings if (out_absolutePath) *out_absolutePath = absoluteDestinationPath; if (out_relativePath) *out_relativePath = relativeDestinationPath; return written; }