char *AppConfig_GetVersionDate(void) { return TOSTRING(LIB_VERSIONDATE); }
initpyodbc(void) #endif { ErrorInit(); if (PyType_Ready(&ConnectionType) < 0 || PyType_Ready(&CursorType) < 0 || PyType_Ready(&RowType) < 0 || PyType_Ready(&CnxnInfoType) < 0) return MODRETURN(0); Object module; #if PY_MAJOR_VERSION >= 3 module.Attach(PyModule_Create(&moduledef)); #else module.Attach(Py_InitModule4("pyodbc", pyodbc_methods, module_doc, NULL, PYTHON_API_VERSION)); #endif pModule = module.Get(); if (!module || !import_types() || !CreateExceptions()) return MODRETURN(0); init_locale_info(); const char* szVersion = TOSTRING(PYODBC_VERSION); PyModule_AddStringConstant(module, "version", (char*)szVersion); PyModule_AddIntConstant(module, "threadsafety", 1); PyModule_AddStringConstant(module, "apilevel", "2.0"); PyModule_AddStringConstant(module, "paramstyle", "qmark"); PyModule_AddObject(module, "pooling", Py_True); Py_INCREF(Py_True); PyModule_AddObject(module, "lowercase", Py_False); Py_INCREF(Py_False); PyModule_AddObject(module, "Connection", (PyObject*)&ConnectionType); Py_INCREF((PyObject*)&ConnectionType); PyModule_AddObject(module, "Cursor", (PyObject*)&CursorType); Py_INCREF((PyObject*)&CursorType); PyModule_AddObject(module, "Row", (PyObject*)&RowType); Py_INCREF((PyObject*)&RowType); // Add the SQL_XXX defines from ODBC. for (unsigned int i = 0; i < _countof(aConstants); i++) PyModule_AddIntConstant(module, (char*)aConstants[i].szName, aConstants[i].value); PyModule_AddObject(module, "Date", (PyObject*)PyDateTimeAPI->DateType); Py_INCREF((PyObject*)PyDateTimeAPI->DateType); PyModule_AddObject(module, "Time", (PyObject*)PyDateTimeAPI->TimeType); Py_INCREF((PyObject*)PyDateTimeAPI->TimeType); PyModule_AddObject(module, "Timestamp", (PyObject*)PyDateTimeAPI->DateTimeType); Py_INCREF((PyObject*)PyDateTimeAPI->DateTimeType); PyModule_AddObject(module, "DATETIME", (PyObject*)PyDateTimeAPI->DateTimeType); Py_INCREF((PyObject*)PyDateTimeAPI->DateTimeType); PyModule_AddObject(module, "STRING", (PyObject*)&PyString_Type); Py_INCREF((PyObject*)&PyString_Type); PyModule_AddObject(module, "NUMBER", (PyObject*)&PyFloat_Type); Py_INCREF((PyObject*)&PyFloat_Type); PyModule_AddObject(module, "ROWID", (PyObject*)&PyInt_Type); Py_INCREF((PyObject*)&PyInt_Type); PyObject* binary_type; #if PY_VERSION_HEX >= 0x02060000 binary_type = (PyObject*)&PyByteArray_Type; #else binary_type = (PyObject*)&PyBuffer_Type; #endif PyModule_AddObject(module, "BINARY", binary_type); Py_INCREF(binary_type); PyModule_AddObject(module, "Binary", binary_type); Py_INCREF(binary_type); I(null_binary != 0); // must be initialized first PyModule_AddObject(module, "BinaryNull", null_binary); PyModule_AddIntConstant(module, "UNICODE_SIZE", sizeof(Py_UNICODE)); PyModule_AddIntConstant(module, "SQLWCHAR_SIZE", sizeof(SQLWCHAR)); if (!PyErr_Occurred()) { module.Detach(); } else { ErrorCleanup(); } return MODRETURN(pModule); }
FlexBody::FlexBody(SceneManager *manager, node_t *nds, int numnds, char* meshname, char* uname, int ref, int nx, int ny, Vector3 offset, Quaternion rot, char* setdef, MaterialFunctionMapper *mfm, Skin *usedSkin, bool enableShadows, MaterialReplacer *mr) : snode(0), faulty(false), mr(mr) { nodes=nds; numnodes=numnds; cref=ref; nodes[cref].iIsSkin=true; cx=nx; nodes[cx].iIsSkin=true; cy=ny; nodes[cy].iIsSkin=true; coffset=offset; cameramode=-2; // all cameras enabled=true; haveshadows=(manager->getShadowTechnique()==SHADOWTYPE_STENCIL_MODULATIVE || manager->getShadowTechnique()==SHADOWTYPE_STENCIL_ADDITIVE); havetangents=false; haveblend=true; freenodeset=0; //parsing set definition char* pos=setdef; char* end=pos; char endwas='G'; while (endwas!=0) { unsigned int val1, val2; end=pos; while (*end!='-' && *end!=',' && *end!=0) end++; endwas=*end; *end=0; val1=strtoul(pos, 0, 10); if (endwas=='-') { pos=end+1; end=pos; while (*end!=',' && *end!=0) end++; endwas=*end; *end=0; val2=strtoul(pos, 0, 10); addinterval(val1, val2); } else addinterval(val1, val1); pos=end+1; } /* // too verbose, removed for (int i=0; i<freenodeset; i++) LOG("FLEXBODY node interval "+TOSTRING(i)+": "+TOSTRING(nodeset[i].from)+"-"+TOSTRING(nodeset[i].to)); */ Vector3 normal = Vector3::UNIT_Y; Vector3 position = Vector3::ZERO; Quaternion orientation = Quaternion::ZERO; if(ref >= 0) { normal=(nodes[ny].smoothpos-nodes[ref].smoothpos).crossProduct(nodes[nx].smoothpos-nodes[ref].smoothpos); normal.normalise(); //position position=nodes[ref].smoothpos+offset.x*(nodes[nx].smoothpos-nodes[ref].smoothpos)+offset.y*(nodes[ny].smoothpos-nodes[ref].smoothpos); position=(position+normal*offset.z); //orientation Vector3 refx=nodes[nx].smoothpos-nodes[ref].smoothpos; refx.normalise(); Vector3 refy=refx.crossProduct(normal); orientation=Quaternion(refx, normal, refy)*rot; } else { // special case! normal = Vector3::UNIT_Y; position=nodes[0].smoothpos+offset; orientation = rot; } // load unique mesh (load original mesh and clone it with unique name) // find group that contains the mesh String groupname=""; try { groupname = ResourceGroupManager::getSingleton().findGroupContainingResource(meshname); }catch(...) { } if(groupname == "") { LOG("FLEXBODY mesh not found: "+String(meshname)); faulty=true; return; } // build new unique mesh name char uname_mesh[256]; memset(uname_mesh, 0, 254); strcpy(uname_mesh, uname); strcat(uname_mesh, "_mesh"); MeshPtr mesh = Ogre::MeshManager::getSingleton().load(meshname, groupname); MeshPtr newmesh = mesh->clone(uname_mesh); // now find possible LODs String basename, ext; StringUtil::splitBaseFilename(String(meshname), basename, ext); for(int i=0; i<4;i++) { String fn = basename + "_" + TOSTRING(i) + ".mesh"; bool exists = ResourceGroupManager::getSingleton().resourceExistsInAnyGroup(fn); if(!exists) continue; float distance = 3; if(i == 1) distance = 20; if(i == 2) distance = 50; if(i == 3) distance = 200; newmesh->createManualLodLevel(distance, fn); } Entity *ent = manager->createEntity(uname, uname_mesh); MaterialFunctionMapper::replaceSimpleMeshMaterials(ent, ColourValue(0.5, 0.5, 1)); if(mfm) mfm->replaceMeshMaterials(ent); if(mr) mr->replaceMeshMaterials(ent); if(usedSkin) usedSkin->replaceMeshMaterials(ent); //LOG("FLEXBODY unique mesh created: "+String(meshname)+" -> "+String(uname_mesh)); msh=ent->getMesh(); //determine if we have texture coordinates everywhere havetexture=true; if (msh->sharedVertexData && msh->sharedVertexData->vertexDeclaration->findElementBySemantic(VES_TEXTURE_COORDINATES)==0) havetexture=false; for (int i=0; i<msh->getNumSubMeshes(); i++) if (!msh->getSubMesh(i)->useSharedVertices && msh->getSubMesh(i)->vertexData->vertexDeclaration->findElementBySemantic(VES_TEXTURE_COORDINATES)==0) havetexture=false; if (!havetexture) LOG("FLEXBODY Warning: at least one part of this mesh does not have texture coordinates, switching off texturing!"); if (!havetexture) {havetangents=false;haveblend=false;}; //we can't do this //detect the anomalous case where a mesh is exported without normal vectors bool havenormal=true; if (msh->sharedVertexData && msh->sharedVertexData->vertexDeclaration->findElementBySemantic(VES_NORMAL)==0) havenormal=false; for (int i=0; i<msh->getNumSubMeshes(); i++) if (!msh->getSubMesh(i)->useSharedVertices && msh->getSubMesh(i)->vertexData->vertexDeclaration->findElementBySemantic(VES_NORMAL)==0) havenormal=false; if (!havenormal) LOG("FLEXBODY Error: at least one part of this mesh does not have normal vectors, export your mesh with normal vectors! THIS WILL CRASH IN 3.2.1..."); //create optimal VertexDeclaration VertexDeclaration* optimalVD=HardwareBufferManager::getSingleton().createVertexDeclaration(); optimalVD->addElement(0, 0, VET_FLOAT3, VES_POSITION); optimalVD->addElement(1, 0, VET_FLOAT3, VES_NORMAL); if (haveblend) optimalVD->addElement(2, 0, VET_COLOUR_ARGB, VES_DIFFUSE); if (havetexture) optimalVD->addElement(3, 0, VET_FLOAT2, VES_TEXTURE_COORDINATES); if (havetangents) optimalVD->addElement(4, 0, VET_FLOAT3, VES_TANGENT); optimalVD->sort(); optimalVD->closeGapsInSource(); BufferUsageList optimalBufferUsages; for (size_t u = 0; u <= optimalVD->getMaxSource(); ++u) optimalBufferUsages.push_back(HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE); //print mesh information //LOG("FLEXBODY Printing input mesh informations:"); //printMeshInfo(ent->getMesh().getPointer()); //adding color buffers, well get the reference later if (haveblend) { if (msh->sharedVertexData) { if (msh->sharedVertexData->vertexDeclaration->findElementBySemantic(VES_DIFFUSE)==0) { //add buffer int index=msh->sharedVertexData->vertexDeclaration->getMaxSource()+1; msh->sharedVertexData->vertexDeclaration->addElement(index, 0, VET_COLOUR_ARGB, VES_DIFFUSE); msh->sharedVertexData->vertexDeclaration->sort(); index=msh->sharedVertexData->vertexDeclaration->findElementBySemantic(VES_DIFFUSE)->getSource(); HardwareVertexBufferSharedPtr vbuf=HardwareBufferManager::getSingleton().createVertexBuffer(VertexElement::getTypeSize(VET_COLOUR_ARGB), msh->sharedVertexData->vertexCount, HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE); msh->sharedVertexData->vertexBufferBinding->setBinding(index, vbuf); } } for (int i=0; i<msh->getNumSubMeshes(); i++) if (!msh->getSubMesh(i)->useSharedVertices) { if (msh->getSubMesh(i)->vertexData->vertexDeclaration->findElementBySemantic(VES_DIFFUSE)==0) { //add buffer int index=msh->getSubMesh(i)->vertexData->vertexDeclaration->getMaxSource()+1; msh->getSubMesh(i)->vertexData->vertexDeclaration->addElement(index, 0, VET_COLOUR_ARGB, VES_DIFFUSE); msh->getSubMesh(i)->vertexData->vertexDeclaration->sort(); index=msh->getSubMesh(i)->vertexData->vertexDeclaration->findElementBySemantic(VES_DIFFUSE)->getSource(); HardwareVertexBufferSharedPtr vbuf=HardwareBufferManager::getSingleton().createVertexBuffer(VertexElement::getTypeSize(VET_COLOUR_ARGB), msh->getSubMesh(i)->vertexData->vertexCount, HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE); msh->getSubMesh(i)->vertexData->vertexBufferBinding->setBinding(index, vbuf); } } } //tangents for envmapping if (havetangents) { LOG("FLEXBODY preparing for tangents"); unsigned short srcTex, destTex; bool existing = msh->suggestTangentVectorBuildParams(VES_TANGENT, srcTex, destTex); if (!existing) msh->buildTangentVectors(VES_TANGENT, srcTex, destTex); } //reorg //LOG("FLEXBODY reorganizing buffers"); if (msh->sharedVertexData) { msh->sharedVertexData->reorganiseBuffers(optimalVD, optimalBufferUsages); msh->sharedVertexData->removeUnusedBuffers(); msh->sharedVertexData->closeGapsInBindings(); } Mesh::SubMeshIterator smIt = msh->getSubMeshIterator(); unsigned short idx = 0; while (smIt.hasMoreElements()) { SubMesh* sm = smIt.getNext(); if (!sm->useSharedVertices) { sm->vertexData->reorganiseBuffers(optimalVD, optimalBufferUsages); sm->vertexData->removeUnusedBuffers(); sm->vertexData->closeGapsInBindings(); } } //print mesh information //LOG("FLEXBODY Printing modififed mesh informations:"); //printMeshInfo(ent->getMesh().getPointer()); //get the buffers //getMeshInformation(ent->getMesh().getPointer(),vertex_count,vertices,index_count,indices, position, orientation, Vector3(1,1,1)); //getting vertex counts vertex_count=0; hasshared=false; numsubmeshbuf=0; if (msh->sharedVertexData) { vertex_count+=msh->sharedVertexData->vertexCount; hasshared=true; } for (int i=0; i<msh->getNumSubMeshes(); i++) if (!msh->getSubMesh(i)->useSharedVertices) { vertex_count+=msh->getSubMesh(i)->vertexData->vertexCount; numsubmeshbuf++; } LOG("FLEXBODY Vertices in mesh "+String(meshname)+": "+ TOSTRING(vertex_count)); //LOG("Triangles in mesh: %u",index_count / 3); //getting buffers bindings and data if (numsubmeshbuf>0) { submeshnums=(int*)malloc(sizeof(int)*numsubmeshbuf); subnodecounts=(int*)malloc(sizeof(int)*numsubmeshbuf); //C++ is just dumb! //How can they manage to break such a fundamental programming mechanisms? //They invented the un-initializable and un-attribuable objects you can't allocate dynamically! //I'm sure they have a fancy way to do that but they won't pry my precious malloc() from my cold, dead hands! goddamit! //subpbufs=(HardwareVertexBufferSharedPtr*)malloc(sizeof(HardwareVertexBufferSharedPtr)*numsubmeshbuf); //subpbufs[0]=HardwareVertexBufferSharedPtr(); //crash! //subnbufs=(HardwareVertexBufferSharedPtr*)malloc(sizeof(HardwareVertexBufferSharedPtr)*numsubmeshbuf); //subnbufs[0]=HardwareVertexBufferSharedPtr(); //crash! if (numsubmeshbuf>=16) LOG("FLEXBODY You have more than 16 submeshes! Blame Bjarne for this crash."); } vertices=(Vector3*)malloc(sizeof(Vector3)*vertex_count); dstpos=(Vector3*)malloc(sizeof(Vector3)*vertex_count); srcnormals=(Vector3*)malloc(sizeof(Vector3)*vertex_count); dstnormals=(Vector3*)malloc(sizeof(Vector3)*vertex_count); if (haveblend) { srccolors=(ARGB*)malloc(sizeof(ARGB)*vertex_count); for (int i=0; i<(int)vertex_count; i++) srccolors[i]=0x00000000; } Vector3* vpt=vertices; Vector3* npt=srcnormals; int cursubmesh=0; if (msh->sharedVertexData) { sharedcount=(int)msh->sharedVertexData->vertexCount; //vertices int source=msh->sharedVertexData->vertexDeclaration->findElementBySemantic(VES_POSITION)->getSource(); sharedpbuf=msh->sharedVertexData->vertexBufferBinding->getBuffer(source); sharedpbuf->readData(0, msh->sharedVertexData->vertexCount*sizeof(Vector3), (void*)vpt); vpt+=msh->sharedVertexData->vertexCount; //normals source=msh->sharedVertexData->vertexDeclaration->findElementBySemantic(VES_NORMAL)->getSource(); sharednbuf=msh->sharedVertexData->vertexBufferBinding->getBuffer(source); sharednbuf->readData(0, msh->sharedVertexData->vertexCount*sizeof(Vector3), (void*)npt); npt+=msh->sharedVertexData->vertexCount; //colors if (haveblend) { source=msh->sharedVertexData->vertexDeclaration->findElementBySemantic(VES_DIFFUSE)->getSource(); sharedcbuf=msh->sharedVertexData->vertexBufferBinding->getBuffer(source); sharedcbuf->writeData(0, msh->sharedVertexData->vertexCount*sizeof(ARGB), (void*)srccolors); } } for (int i=0; i<msh->getNumSubMeshes(); i++) if (!msh->getSubMesh(i)->useSharedVertices) { submeshnums[cursubmesh]=i; subnodecounts[cursubmesh]=(int)msh->getSubMesh(i)->vertexData->vertexCount; //vertices int source=msh->getSubMesh(i)->vertexData->vertexDeclaration->findElementBySemantic(VES_POSITION)->getSource(); subpbufs[cursubmesh]=msh->getSubMesh(i)->vertexData->vertexBufferBinding->getBuffer(source); subpbufs[cursubmesh]->readData(0, msh->getSubMesh(i)->vertexData->vertexCount*sizeof(Vector3), (void*)vpt); vpt+=msh->getSubMesh(i)->vertexData->vertexCount; //normals source=msh->getSubMesh(i)->vertexData->vertexDeclaration->findElementBySemantic(VES_NORMAL)->getSource(); subnbufs[cursubmesh]=msh->getSubMesh(i)->vertexData->vertexBufferBinding->getBuffer(source); subnbufs[cursubmesh]->readData(0, msh->getSubMesh(i)->vertexData->vertexCount*sizeof(Vector3), (void*)npt); npt+=msh->getSubMesh(i)->vertexData->vertexCount; //colors if (haveblend) { source=msh->getSubMesh(i)->vertexData->vertexDeclaration->findElementBySemantic(VES_DIFFUSE)->getSource(); subcbufs[cursubmesh]=msh->getSubMesh(i)->vertexData->vertexBufferBinding->getBuffer(source); subcbufs[cursubmesh]->writeData(0, msh->getSubMesh(i)->vertexData->vertexCount*sizeof(ARGB), (void*)srccolors); } cursubmesh++; } //transform for (int i=0; i<(int)vertex_count; i++) { vertices[i]=(orientation*vertices[i])+position; } locs=(Locator_t*)malloc(sizeof(Locator_t)*vertex_count); for (int i=0; i<(int)vertex_count; i++) { //search nearest node as the local origin float mindist=100000.0; int minnode=-1; for (int k=0; k<numnodes; k++) { if (!isinset(k)) continue; //if (nodes[k].iswheel) continue; float dist=(vertices[i]-nodes[k].smoothpos).length(); if (dist<mindist) {mindist=dist;minnode=k;}; } if (minnode==-1) LOG("FLEXBODY ERROR on mesh "+String(meshname)+": REF node not found"); locs[i].ref=minnode; nodes[minnode].iIsSkin=true; // LOG("FLEXBODY distance to "+TOSTRING(minnode)+" "+TOSTRING(mindist)); //search the second nearest node as the X vector mindist=100000.0; minnode=-1; for (int k=0; k<numnodes; k++) { if (!isinset(k)) continue; //if (nodes[k].iswheel) continue; if (k==locs[i].ref) continue; float dist=(vertices[i]-nodes[k].smoothpos).length(); if (dist<mindist) {mindist=dist;minnode=k;}; } if (minnode==-1) LOG("FLEXBODY ERROR on mesh "+String(meshname)+": VX node not found"); locs[i].nx=minnode; nodes[minnode].iIsSkin=true; //search another close, orthogonal node as the Y vector mindist=100000.0; minnode=-1; Vector3 vx=nodes[locs[i].nx].smoothpos-nodes[locs[i].ref].smoothpos; vx.normalise(); for (int k=0; k<numnodes; k++) { if (!isinset(k)) continue; //if (nodes[k].iswheel) continue; if (k==locs[i].ref) continue; if (k==locs[i].nx) continue; Vector3 vt=nodes[k].smoothpos-nodes[locs[i].ref].smoothpos; vt.normalise(); float cost=vx.dotProduct(vt); if (cost>0.707 || cost<-0.707) continue; //rejection, fails the orthogonality criterion (+-45 degree) float dist=(vertices[i]-nodes[k].smoothpos).length(); if (dist<mindist) {mindist=dist;minnode=k;}; } if (minnode==-1) LOG("FLEXBODY ERROR on mesh "+String(meshname)+": VY node not found"); locs[i].ny=minnode; nodes[minnode].iIsSkin=true; /* //search the final close, orthogonal node as the Z vector mindist=100000.0; minnode=-1; Vector3 vy=nodes[locs[i].ny].smoothpos-nodes[locs[i].ref].smoothpos; vy.normalise(); for (int k=0; k<numnodes; k++) { if (nodes[k].iswheel) continue; if (k==locs[i].ref) continue; if (k==locs[i].nx) continue; if (k==locs[i].ny) continue; Vector3 vt=nodes[k].smoothpos-nodes[locs[i].ref].smoothpos; vt.normalise(); float cost=vx.dotProduct(vt); if (cost>0.707 || cost<-0.707) continue; //rejection, fails the orthogonality criterion (+-45 degree) cost=vy.dotProduct(vt); if (cost>0.707 || cost<-0.707) continue; //rejection, fails the orthogonality criterion (+-45 degree) float dist=(vertices[i]-nodes[k].smoothpos).length(); if (dist<mindist) {mindist=dist;minnode=k;}; } if (minnode==-1) LOG("FLEXBODY ERROR on mesh "+String(meshname)+": VZ node not found"); locs[i].nz=minnode; //rright, check orientation Vector3 xyn=vx.crossProduct(vy); if (xyn.dotProduct(nodes[locs[i].nz].smoothpos-nodes[locs[i].ref].smoothpos)<0) { //the base is messed up int t=locs[i].nz; locs[i].nz=locs[i].ny; locs[i].ny=t; } */ Vector3 vz=(nodes[locs[i].nx].smoothpos-nodes[locs[i].ref].smoothpos).crossProduct(nodes[locs[i].ny].smoothpos-nodes[locs[i].ref].smoothpos); vz.normalise(); Matrix3 mat; mat.SetColumn(0, nodes[locs[i].nx].smoothpos-nodes[locs[i].ref].smoothpos); mat.SetColumn(1, nodes[locs[i].ny].smoothpos-nodes[locs[i].ref].smoothpos); // mat.SetColumn(2, nodes[locs[i].nz].smoothpos-nodes[locs[i].ref].smoothpos); mat.SetColumn(2, vz); mat=mat.Inverse(); //compute coordinates in the newly formed euclidian basis locs[i].coords=mat*(vertices[i]-nodes[locs[i].ref].smoothpos); //thats it! } //shadow if (haveshadows) { LOG("FLEXBODY preparing for shadow volume"); msh->prepareForShadowVolume(); //we do this always so we have only one datastructure format to manage msh->buildEdgeList(); } //adjusting bounds AxisAlignedBox aab=msh->getBounds(); Vector3 v=aab.getMinimum(); float mi=v.x; if (v.y<mi) mi=v.y; if (v.z<mi) mi=v.z; mi=fabs(mi); v=aab.getMaximum(); float ma=v.x; if (ma<v.y) ma=v.y; if (ma<v.z) ma=v.z; ma=fabs(ma); if (mi>ma) ma=mi; aab.setMinimum(Vector3(-ma,-ma,-ma)); aab.setMaximum(Vector3(ma,ma,ma)); msh->_setBounds(aab, true); LOG("FLEXBODY show mesh"); //okay, show the mesh now snode=manager->getRootSceneNode()->createChildSceneNode(); snode->attachObject(ent); snode->setPosition(position); //ent->setCastShadows(enableShadows); #if 0 // XXX TODO: fix 1.7 LODs if(enable_truck_lod) { String lodstr = "FLEXBODY LODs: "; for(int i=0;i<msh->getNumLodLevels();i++) { if(i) lodstr += ", "; lodstr += TOSTRING(Real(sqrt(msh->getLodLevel(i).fromDepthSquared))) + "m"; if(msh->getLodLevel(i).edgeData) { lodstr += "(" + TOSTRING(msh->getLodLevel(i).edgeData->triangles.size()) + " triangles)"; } else { if(msh->getEdgeList(i)) lodstr += "(" + TOSTRING(msh->getEdgeList(i)->triangles.size()) +" triangles)"; } } LOG(lodstr); } #endif //0 for (int i=0; i<(int)vertex_count; i++) { Vector3 vz=(nodes[locs[i].nx].smoothpos-nodes[locs[i].ref].smoothpos).crossProduct(nodes[locs[i].ny].smoothpos-nodes[locs[i].ref].smoothpos); vz.normalise(); Matrix3 mat; mat.SetColumn(0, nodes[locs[i].nx].smoothpos-nodes[locs[i].ref].smoothpos); mat.SetColumn(1, nodes[locs[i].ny].smoothpos-nodes[locs[i].ref].smoothpos); // mat.SetColumn(2, nodes[locs[i].nz].smoothpos-nodes[locs[i].ref].smoothpos); mat.SetColumn(2, vz); mat=mat.Inverse(); //compute coordinates in the euclidian basis srcnormals[i]=mat*(orientation*srcnormals[i]); } LOG("FLEXBODY ready"); }
int main() { std::cout.setf(std::ios::left); compare(EXPR1, TOSTRING(EXPR1)); compare(EXPR2, TOSTRING(EXPR2)); compare(EXPR3, TOSTRING(EXPR3)); compare(EXPR4, TOSTRING(EXPR4)); compare(EXPR5, TOSTRING(EXPR5)); compare(EXPR6, TOSTRING(EXPR6)); compare(EXPR7, TOSTRING(EXPR7)); compare(EXPR8, TOSTRING(EXPR8)); compare(EXPR9, TOSTRING(EXPR9)); compare(EXPRa, TOSTRING(EXPRa)); compare(EXPRb, TOSTRING(EXPRb)); if (failed != 0) { std::cerr << failed << " test(s) failed!" << std::endl; return 1; } std::cout << "All tests passed successfully!" << std::endl; return 0; }
void ModulePromGroup::on_translate(double x, double y) { set_property("posx", TOSTRING((int)(x))); set_property("posy", TOSTRING((int)(y))); fire_change_event(); }
//------------------------------------------------------------------------------ // Name: read_settings // Desc: read in the options from the file //------------------------------------------------------------------------------ void Configuration::read_settings() { #ifdef Q_OS_WIN32 const QString default_font = QFont("Courier New", 8).toString(); #elif defined(Q_OS_MACX) const QString default_font = QFont("Courier New", 10).toString(); #else const QString default_font = QFont("Monospace", 8).toString(); #endif #ifdef DEFAULT_PLUGIN_PATH const QString default_plugin_path = TOSTRING(DEFAULT_PLUGIN_PATH); #else const QString edb_lib_dir=QCoreApplication::applicationDirPath()+(EDB_IS_64_BIT ? "/../lib64/edb" : "/../lib/edb"); const QString edb_binary_dir=QCoreApplication::applicationDirPath(); // If the binary is in its installation directory, then look for plugins in their installation directory // Otherwise assume that we are in build directory, so the plugins are in the same directory as the binary const QString default_plugin_path = QRegExp(".*/bin/?$").exactMatch(edb_binary_dir) ? edb_lib_dir : edb_binary_dir; #endif QSettings settings; settings.beginGroup("General"); close_behavior = static_cast<CloseBehavior>(settings.value("close_behavior").value<uint>()); settings.endGroup(); settings.beginGroup("Appearance"); stack_font = settings.value("appearance.stack.font", default_font).value<QString>(); data_font = settings.value("appearance.data.font", default_font).value<QString>(); registers_font = settings.value("appearance.registers.font", default_font).value<QString>(); disassembly_font = settings.value("appearance.disassembly.font", default_font).value<QString>(); data_show_address = settings.value("appearance.data.show_address.enabled", true).value<bool>(); data_show_hex = settings.value("appearance.data.show_hex.enabled", true).value<bool>(); data_show_ascii = settings.value("appearance.data.show_ascii.enabled", true).value<bool>(); data_show_comments = settings.value("appearance.data.show_comments.enabled", true).value<bool>(); data_word_width = settings.value("appearance.data.word_width", 1).value<int>(); data_row_width = settings.value("appearance.data.row_width", 16).value<int>(); show_address_separator = settings.value("appearance.address_colon.enabled", true).value<bool>(); settings.endGroup(); settings.beginGroup("Debugging"); initial_breakpoint = static_cast<InitialBreakpoint>(settings.value("debugger.initial_breakpoint", MainSymbol).value<uint>()); warn_on_no_exec_bp = settings.value("debugger.BP_NX_warn.enabled", true).value<bool>(); find_main = settings.value("debugger.find_main.enabled", true).value<bool>(); min_string_length = settings.value("debugger.string_min", 4).value<uint>(); tty_enabled = settings.value("debugger.terminal.enabled", true).value<bool>(); tty_command = settings.value("debugger.terminal.command", "/usr/bin/xterm").value<QString>(); remove_stale_symbols = settings.value("debugger.remove_stale_symbols.enabled", true).value<bool>(); disableASLR = settings.value("debugger.disableASLR.enabled", false).value<bool>(); disableLazyBinding = settings.value("debugger.disableLazyBinding.enabled", false).value<bool>(); settings.endGroup(); settings.beginGroup("Disassembly"); syntax = static_cast<Syntax>(settings.value("disassembly.syntax", Intel).value<uint>()); syntax_highlighting_enabled = settings.value("disassembly.syntax_highlighting_enabled", true).value<bool>(); zeros_are_filling = settings.value("disassembly.zeros_are_filling.enabled", true).value<bool>(); uppercase_disassembly = settings.value("disassembly.uppercase.enabled", false).value<bool>(); small_int_as_decimal = settings.value("disassembly.small_int_as_decimal.enabled", false).value<bool>(); tab_between_mnemonic_and_operands=settings.value("disassembly.tab_between_mnemonic_and_operands.enabled", false).value<bool>(); show_local_module_name_in_jump_targets = settings.value("disassembly.show_local_module_name_in_jump_targets.enabled", true).value<bool>(); show_symbolic_addresses = settings.value("disassembly.show_symbolic_addresses.enabled", true).value<bool>(); simplify_rip_relative_targets = settings.value("disassembly.simplify_rip_relative_targets.enabled", true).value<bool>(); settings.endGroup(); settings.beginGroup("Directories"); #if QT_VERSION >= 0x050000 QStringList cacheDirectories = QStandardPaths::standardLocations(QStandardPaths::CacheLocation); QString cacheDirectory = !cacheDirectories.isEmpty() ? cacheDirectories[0] : QString(); #else QString cacheDirectory = QDesktopServices::storageLocation(QDesktopServices::CacheLocation); #endif QString defaultSymbolPath = QString("%1/%2").arg(cacheDirectory, "symbols"); QString defaultSessionPath = QString("%1/%2").arg(cacheDirectory, "sessions"); symbol_path = settings.value("directory.symbol.path", defaultSymbolPath).value<QString>(); plugin_path = settings.value("directory.plugin.path", default_plugin_path).value<QString>(); session_path = settings.value("directory.session.path", defaultSessionPath).value<QString>(); settings.endGroup(); settings.beginGroup("Exceptions"); enable_signals_message_box=settings.value("signals.show_message_box.enabled", true).value<bool>(); settings.endGroup(); // normalize values if(data_word_width != 1 && data_word_width != 2 && data_word_width != 4 && data_word_width != 8) { data_word_width = 1; } if(data_row_width != 1 && data_row_width != 2 && data_row_width != 4 && data_row_width != 8 && data_row_width != 16) { data_row_width = 16; } // Init capstone to some default settings CapstoneEDB::init(EDB_IS_64_BIT); CapstoneEDB::Formatter::FormatOptions options = edb::v1::formatter().options(); options.capitalization = uppercase_disassembly ? CapstoneEDB::Formatter::UpperCase : CapstoneEDB::Formatter::LowerCase; options.smallNumFormat = small_int_as_decimal ? CapstoneEDB::Formatter::SmallNumAsDec : CapstoneEDB::Formatter::SmallNumAsHex; options.syntax=static_cast<CapstoneEDB::Formatter::Syntax>(syntax); options.tabBetweenMnemonicAndOperands=tab_between_mnemonic_and_operands; options.simplifyRIPRelativeTargets=simplify_rip_relative_targets; edb::v1::formatter().setOptions(options); }
void LinkPromLink::on_change() { link->annotations.set("bezier_x2", TOSTRING(component->b->x2)); link->annotations.set("bezier_y2", TOSTRING(component->b->y2)); link->annotations.set("bezier_x3", TOSTRING(component->b->x3)); link->annotations.set("bezier_y3", TOSTRING(component->b->y3)); }
#define TOSTRING(x) STRINGIFY(x) #define DEFAULT_DEMUX_DEV "/dev/dvb/adapter0/demux0" #define DEFAULT_TIMEOUT 10 struct epgdump_s glob; const char *argp_program_version = PACKAGE_STRING; const char *argp_program_bug_address = "<" PACKAGE_BUGREPORT ">"; static char args_doc[] = "[-a NUM | -d DEV] [-t NUM]"; static char doc[] = "Tool to dump EGP data fom MPEG-TS stream."; static struct argp_option options[] = { {"adapter", 'a', "NUM", 0, "Use /dev/dvb/adapterNUM/demux0 DVB adapter (-a and -d are mutually exclusive)." }, {"device", 'd', "DEV", 0, "Use DEV as DVB demux device (default: " DEFAULT_DEMUX_DEV ")." }, {"timeout", 't', "INT", 0, "Timeout after INT seconds if no EPG data availabale (default: " TOSTRING(DEFAULT_TIMEOUT) ")." }, {"current-only", 'c', 0, 0, "Print only current (actual) TS EPG data (-o and -c are mutually exclusive)." }, {"other-only", 'o', 0, 0, "Print only other TS EPG data (-o and -c are mutually exclusive)." }, { 0 } }; static error_t parse_opt (int key, char *arg, struct argp_state *state); static struct argp argp = { options, parse_opt, args_doc, doc }; void critical_error(const char *format, ...) { va_list pvar; va_start(pvar, format); vfprintf(stderr, format, pvar); va_end(pvar);
int main(int argc, char *argv[]) { char opt; static struct option long_options[] = { {"item", 0, 0, 'i'}, {"monster", 0, 0, 'm'}, {"spell", 0, 0, 's'}, {"map", 1, 0, 'p'}, {"editmap", 1, 0, 'e'}, {"ascii", 0, 0, 'a'}, {"xml", 1, 0, 'x'}, {"multiplier", 1, 0, 'u'}, {0, 0, 0, 0} }; bool utf8 = true; int mode = MODE_STANDARD; char *mapFile = NULL; char *xmlFile = NULL; int multiplier = 0; std::string libDir(TOSTRING(BTBUILDERDIR)); while ((opt = getopt_long(argc,argv,"imsap:x:e:l:u:", long_options, NULL)) != EOF) { switch (opt) { case 'i': mode = MODE_ITEM; break; case 'm': mode = MODE_MONSTER; break; case 's': mode = MODE_SPELL; break; case 'p': mode = MODE_MAP; if (optarg) { mapFile = strdup(optarg); } break; case 'e': mode = MODE_EDITMAP; if (optarg) { mapFile = strdup(optarg); } break; case 'l': if (optarg) { libDir = optarg; } break; case 'a': utf8 = false; break; case 'x': if (optarg) { xmlFile = strdup(optarg); } break; case 'u': if (optarg) { multiplier = atol(optarg); } break; default: break; } } BTMainScreen mainScreen(argv[0], libDir, multiplier); if (optind >= argc) { if (mode != MODE_STANDARD) return 0; mainScreen.run(); return 0; } else if (mode == MODE_STANDARD) { std::string moduleFile("module/"); moduleFile += argv[optind]; moduleFile += ".xml"; mainScreen.runModule(moduleFile); return 0; } else if (mode == MODE_EDITMAP) { std::string moduleFile("module/"); moduleFile += argv[optind]; moduleFile += ".xml"; mainScreen.editModule(moduleFile, mapFile); return 0; } std::string moduleFile("module/"); moduleFile += argv[optind]; moduleFile += ".xml"; BTModule module; mainScreen.loadModule(moduleFile, module); BTGame game(&module); BTFactory<BTMonster> &monList(game.getMonsterList()); BTFactory<BTItem> &itmList(game.getItemList()); BTFactory<BTSpell, BTSpell1> &splList(game.getSpellList()); int i; if (mode == MODE_MONSTER) { if (xmlFile) { monList.save(xmlFile); } else { for (i = 0; i < monList.size(); i++) { BTMonster &mon(monList[i]); printf("Name: %s\n", mon.getName().c_str()); printf("Illusion: %s Base armor class: %d\n", (mon.isIllusion() ? "Yes" : "No"), (mon.getAc() - 10) * -1); printf("Level: %d Thaumaturgical resistance: %d\n", mon.getLevel(), mon.getMagicResistance()); printf("Starting distance (*10'): %d Moves per round: %d\n", mon.getStartDistance(), mon.getMove()); printf("Hit points: %dd%d Combat options: ", mon.getHp().getNumber(), mon.getHp().getType()); IShort combatAction = mon.getCombatAction(0); for (int a = 1; a < 4; ++a) if (combatAction != mon.getCombatAction(a)) combatAction = -1; if (-1 == combatAction) printf("Multiple\n"); else printf("%s\n", combatActions[combatAction]); printf("Rate of attacks: %d Damage dice: %dd%d\n", mon.getRateAttacks(), mon.getMeleeDamage().getNumber(), mon.getMeleeDamage().getType()); printf("Extra damage: %s\n", extraDamage[mon.getMeleeExtra()]); printf("Attack message: <monster> %s <opponent>\n", mon.getMeleeMessage()); printf("Extra ranged attack information -\n"); printf(" Type: %s", rangedTypes[mon.getRangedType()]); switch (mon.getRangedType()) { case BTRANGEDTYPE_MAGIC: printf(": %s", splList[mon.getRangedSpell()].getCode()); case BTRANGEDTYPE_FOE: case BTRANGEDTYPE_GROUP: printf(" Message: <monster> %s <opponent>\n", mon.getRangedMessage()); printf(" Damage: %dd%d Extra damage: %s Range: %d", mon.getRangedDamage().getNumber(), mon.getRangedDamage().getType(), extraDamage[mon.getRangedExtra()], mon.getRange()); break; default: break; } printf("\n"); printf("Upper limit appearing: %d Gold: %dd%d Picture number: %d\n", mon.getMaxAppearing(), mon.getGold().getNumber(), mon.getGold().getType(), mon.getPicture()); printf("\n"); } } } else if (mode == MODE_SPELL) { if (xmlFile) { splList.save(xmlFile); } else { BTSpellListCompare compare; BTSortedFactory<BTSpell, BTSpell1> sortedSplList(&splList, &compare); IShort caster = -1; IShort level = -1; for (i = 0; i < sortedSplList.size(); i++) { BTSpell &mon(sortedSplList[i]); if ((caster != mon.getCaster()) || (level != mon.getLevel())) { if (caster != mon.getCaster()) { caster = mon.getCaster(); BTJobList& jobList = BTGame::getGame()->getJobList(); int j; for (j = 0; j < jobList.size(); ++j) { if (jobList[j]->getSkill(caster) != NULL) break; } printf("Class: %s\n", ((j < jobList.size()) ? BTGame::getGame()->getJobList()[j]->name : "Unknown")); } level = mon.getLevel(); printf("Level: %d\n\n", level); } printf("Name: %s\n", mon.getName().c_str()); printf("Code: %s\n", mon.getCode()); printf("Points: %d Range: %d Extra range: %s\n", mon.getSp(), mon.getRange() * 10, effectiveRanges[mon.getEffectiveRange()]); printf("Target: %s\n", areaEffect[mon.getArea()]); printf("Effect: %s <target>\n", mon.getEffect()); printf("Duration: %s\n", durations[mon.getDuration()]); printf("%s", mon.describeManifest().data()); /* printf("Type: %s", spellTypes[mon.getType()]); switch (mon.getType()) { case BTSPELLTYPE_SUMMONILLUSION: case BTSPELLTYPE_SUMMONMONSTER: printf(" Name: %s", monList[mon.getExtra()].getName().c_str()); break; case BTSPELLTYPE_ARMORBONUS: case BTSPELLTYPE_HITBONUS: printf(" Bonus: %d", mon.getExtra()); break; case BTSPELLTYPE_PUSH: printf(" Distance: %d", mon.getExtra()); break; case BTSPELLTYPE_REGENBARD: printf(" Amount: %d", mon.getExtra()); break; default: break; } printf("\nDice: %dd%d Duration: %s\n", mon.getDice().getNumber(), mon.getDice().getType(), durations[mon.getDuration()]); */ printf("\n"); } } } else if (mode == MODE_ITEM) { if (xmlFile) { itmList.save(xmlFile); } else { for (i = 0; i < itmList.size(); i++) { BTItem &mon(itmList[i]); printf("Name: %s\n", mon.getName().c_str()); printf("Type: %s\n", itemTypes[mon.getType()]); printf("Price: %d User class: Multiple\n", mon.getPrice()); printf("Armor bonus: %d Hit bonus: %d\n", mon.getArmorPlus(), mon.getHitPlus()); printf("Damage dice: %dd%d\n", mon.getDamage().getNumber(), mon.getDamage().getType()); printf("Extra special damage: %s Special damage likelihood: %d%%\n", extraDamage[mon.getXSpecial()], mon.getChanceXSpecial()); if (BTTIMESUSABLE_UNLIMITED == mon.getTimesUsable()) printf("Times useable: (unlimited)"); else printf("Times useable: %d", mon.getTimesUsable()); printf(" Spell cast: %s\n", ((mon.getSpellCast() == BTITEMCAST_NONE) ? "(none)" : splList[mon.getSpellCast()].getName().c_str())); printf("Cause: <member> %s <opponent>\n", mon.getCause()); printf("Effect: %s <damage>\n", mon.getEffect()); printf("\n"); } } } else if (mode == MODE_MAP) { int x, y; IShort index; if (mapFile) game.loadMap(mapFile); BTMap &gameMap = *game.getMap(); if (xmlFile) { XMLSerializer parser; parser.add("map", &gameMap); parser.write(xmlFile, true); } else { printf("Name: %s\n", gameMap.getName()); printf("Type: %s Level: %d\n", game.getPsuedo3DConfigList().getName(gameMap.getType()).c_str(), gameMap.getLevel()); printf("Monster difficulty: %d Chance of encounter: %d%%\n", gameMap.getMonsterLevel(), gameMap.getMonsterChance()); printf("File: %s\n\n", gameMap.getFilename()); for (y = 0; y < gameMap.getYSize(); y++) { printf(" "); for (x = 0; x < gameMap.getXSize(); x++) { index = 0; if ((y > 0) && (gameMap.getSquare(y - 1, x).getWall(BTDIRECTION_WEST) > 0)) { index += 1 << BTDIRECTION_NORTH; } if ((x > 0) && (gameMap.getSquare(y, x - 1).getWall(BTDIRECTION_NORTH) > 0)) { index += 1 << BTDIRECTION_WEST; } if (gameMap.getSquare(y, x).getWall(BTDIRECTION_NORTH) > 0) { index += 1 << BTDIRECTION_EAST; } if (gameMap.getSquare(y, x).getWall(BTDIRECTION_WEST) > 0) { index += 1 << BTDIRECTION_SOUTH; } if (utf8) printf("%s%s", cornerWallsUTF8[index], upperWallsUTF8[gameMap.getSquare(y, x).getWall(BTDIRECTION_NORTH)]); else printf("%c%c", cornerWalls[index], upperWalls[gameMap.getSquare(y, x).getWall(BTDIRECTION_NORTH)]); } index = 0; if ((y > 0) && (gameMap.getSquare(y - 1, gameMap.getXSize() - 1).getWall(BTDIRECTION_EAST) > 0)) { index += 1 << BTDIRECTION_NORTH; } if (gameMap.getSquare(y, gameMap.getXSize() - 1).getWall(BTDIRECTION_NORTH) > 0) { index += 1 << BTDIRECTION_WEST; } if (gameMap.getSquare(y, gameMap.getXSize() - 1).getWall(BTDIRECTION_EAST) > 0) { index += 1 << BTDIRECTION_SOUTH; } if (utf8) printf("%s \n", cornerWallsUTF8[index]); else printf("%c \n", cornerWalls[index]); printf(" "); for (x = 0; x < gameMap.getXSize(); x++) { index = gameMap.getSquare(y, x).getSpecial(); if (utf8) printf("%s%c", sideWallsUTF8[gameMap.getSquare(y, x).getWall(BTDIRECTION_WEST)], (index < 0 ) ? ' ' : ((index < 26) ? 'A' + index : 'a' - 26 + index)); else printf("%c%c", sideWalls[gameMap.getSquare(y, x).getWall(BTDIRECTION_WEST)], (index < 0 ) ? ' ' : ((index < 26) ? 'A' + index : 'a' - 26 + index)); } if (utf8) printf("%s \n", sideWallsUTF8[gameMap.getSquare(y, gameMap.getXSize() - 1).getWall(BTDIRECTION_EAST)]); else printf("%c \n", sideWalls[gameMap.getSquare(y, gameMap.getXSize() - 1).getWall(BTDIRECTION_EAST)]); } printf(" "); for (x = 0; x < gameMap.getXSize(); x++) { index = 0; if (gameMap.getSquare(gameMap.getYSize() - 1, x).getWall(BTDIRECTION_WEST) > 0) { index += 1 << BTDIRECTION_NORTH; } if ((x > 0) && (gameMap.getSquare(gameMap.getYSize() - 1, x - 1).getWall(BTDIRECTION_SOUTH) > 0)) { index += 1 << BTDIRECTION_WEST; } if (gameMap.getSquare(gameMap.getYSize() - 1, x).getWall(BTDIRECTION_SOUTH) > 0) { index += 1 << BTDIRECTION_EAST; } if (utf8) printf("%s%s", cornerWallsUTF8[index], upperWallsUTF8[gameMap.getSquare(gameMap.getYSize() - 1, x).getWall(BTDIRECTION_SOUTH)]); else printf("%c%c", cornerWalls[index], upperWalls[gameMap.getSquare(gameMap.getYSize() - 1, x).getWall(BTDIRECTION_SOUTH)]); } index = 0; if (gameMap.getSquare(gameMap.getYSize() - 1, gameMap.getXSize() - 1).getWall(BTDIRECTION_EAST) > 0) { index += 1 << BTDIRECTION_NORTH; } if (gameMap.getSquare(gameMap.getYSize() - 1, gameMap.getXSize() - 1).getWall(BTDIRECTION_SOUTH) > 0) { index += 1 << BTDIRECTION_WEST; } if (utf8) printf("%s \n", cornerWallsUTF8[index]); else printf("%c \n", cornerWalls[index]); printf("\nDefined special squares:\n\n\n"); for (int i = 0; i < 30; i++) { const BTSpecial *sp = gameMap.getSpecial(i); if (NULL != sp) { printf("%c. ", (i < 26) ? 'A' + i : 'a' - 26 + i); sp->print(stdout); printf("\n"); } } } } PHYSFS_deinit(); return 0; }
#include <unistd.h> #include <string.h> #ifdef COLOR #include <textcolor.h> #endif #define STRINGIFY(x) #x #define TOSTRING(x) STRINGIFY(x) #define LLU_CAST (unsigned long long) extern int pthread_setaffinity_np(pthread_t thread, size_t cpusetsize, const cpu_set_t *cpuset); static char * sosearchpaths[] = { #ifdef LIBPTHREAD TOSTRING(LIBPTHREAD), #endif "/lib64/tls/libpthread.so.0",/* sles9 x86_64 */ "libpthread.so.0", /* Ubuntu */ NULL }; #ifdef COLOR #define color_print(format,...) do { \ color_on(BRIGHT, COLOR); \ printf(format, ##__VA_ARGS__); \ color_reset(); \ } while(0) #else #define color_print(format,...) do { \
int mosquitto_auth_plugin_version(void) { fprintf(stderr, "*** auth-plug: backend=%s\n", TOSTRING(BACKEND)); return MOSQ_AUTH_PLUGIN_VERSION; }
static void mdlStart(SimStruct *S) { SFUNPRINTF("Starting Instance of %s.\n", TOSTRING(S_FUNCTION_NAME)); // init ROS if not yet done. initROS(S); void** vecPWork = ssGetPWork(S); ros::NodeHandle nodeHandle(ros::this_node::getName()); // get base service name strings size_t buflen = mxGetN((ssGetSFcnParam(S, 1)))*sizeof(mxChar)+1; char* base_name = (char*)mxMalloc(buflen); mxGetString((ssGetSFcnParam(S, 1)), base_name, buflen); const std::string start_name = std::string(base_name) + "/simRosStartSimulation"; ros::ServiceClient* start_client = new ros::ServiceClient(nodeHandle.serviceClient<vrep_common::simRosStartSimulation>(start_name)); vecPWork[0] = start_client; if (!start_client->exists()){ ssSetErrorStatus(S,"Start service does not exist!"); } const std::string stop_name = std::string(base_name) + "/simRosStopSimulation"; ros::ServiceClient* stop_client = new ros::ServiceClient(nodeHandle.serviceClient<vrep_common::simRosStopSimulation>(stop_name)); vecPWork[1] = stop_client; if (!stop_client->exists()){ ssSetErrorStatus(S,"Stop service does not exist!"); } const std::string synchronous_name = std::string(base_name) + "/simRosSynchronous"; ros::ServiceClient* synchronous_client = new ros::ServiceClient(nodeHandle.serviceClient<vrep_common::simRosSynchronous>(synchronous_name)); vecPWork[2] = synchronous_client; if (!synchronous_client->exists()){ ssSetErrorStatus(S,"Synchronous service does not exist!"); } const std::string trigger_name = std::string(base_name) + "/simRosSynchronousTrigger"; ros::ServiceClient* trigger_client = new ros::ServiceClient(nodeHandle.serviceClient<vrep_common::simRosSynchronousTrigger>(trigger_name)); vecPWork[3] = trigger_client; if (!trigger_client->exists()){ ssSetErrorStatus(S,"Trigger service does not exist!"); } const std::string info_name = std::string(base_name) + "/simRosGetInfo"; ros::ServiceClient* info_client = new ros::ServiceClient(nodeHandle.serviceClient<vrep_common::simRosGetInfo>(info_name)); if (!info_client->exists()){ ssSetErrorStatus(S,"Info service does not exist!"); } const std::string parameter_name = std::string(base_name) + "/simRosSetFloatingParameter"; ros::ServiceClient* parameter_client = new ros::ServiceClient(nodeHandle.serviceClient<vrep_common::simRosSetFloatingParameter>(parameter_name)); if (!parameter_client->exists()){ ssSetErrorStatus(S,"Set parameter service does not exist!"); } mxFree(base_name); // Set V-Rep time step to this block time step const real_T tSim = mxGetScalar(ssGetSFcnParam(S, 0)); vrep_common::simRosSetFloatingParameter paramSrv; paramSrv.request.parameter = sim_floatparam_simulation_time_step; paramSrv.request.parameterValue = tSim; parameter_client->call(paramSrv); if (paramSrv.response.result == -1){ ssSetErrorStatus(S,"Error setting V-REP simulation time step."); } vrep_common::simRosGetInfo infoSrv; info_client->call(infoSrv); const real_T vrepTimeStep = ROUND(infoSrv.response.timeStep*1e6)*1e-6; if (fabs(vrepTimeStep-tSim) > 1e-5){ char str[100]; sprintf(str, "V-REP time step (%e) is different from block time step (%e).", vrepTimeStep, tSim); ssSetErrorStatus(S,str); } // Set synchronous mode vrep_common::simRosSynchronous syncSrv; syncSrv.request.enable = true; synchronous_client->call(syncSrv); if (syncSrv.response.result == -1){ ssSetErrorStatus(S,"Error setting V-REP synchronous simulation mode."); } // Start V-Rep simulation vrep_common::simRosStartSimulation startSrv; start_client->call(startSrv); if (startSrv.response.result == -1){ ssSetErrorStatus(S,"Error starting V-REP simulation."); } // Subscribe to all the topics to wait size_t wait_buflen = mxGetN((ssGetSFcnParam(S, 2)))*sizeof(mxChar)+1; char* wait_name = (char*)mxMalloc(wait_buflen); mxGetString((ssGetSFcnParam(S, 2)), wait_name, wait_buflen); int_T nWaitTopic = 0; char* topic = strtok(wait_name, TOPIC_SEPARATORS); while(topic != NULL){ GenericSubscriber<topic_tools::ShapeShifter>* sub = new GenericSubscriber<topic_tools::ShapeShifter>(nodeHandle, topic, 1); vecPWork[4+nWaitTopic] = sub; nWaitTopic++; topic = strtok (NULL, TOPIC_SEPARATORS); } if (nWaitTopic>0){ ros::AsyncSpinner* spinner = new ros::AsyncSpinner(nWaitTopic); spinner->start(); vecPWork[4+nWaitTopic] = spinner; ssGetIWork(S)[0] = nWaitTopic; } mxFree(wait_name); }
//------------------------------------------------------------------------------ // Name: read_settings // Desc: read in the options from the file //------------------------------------------------------------------------------ void Configuration::read_settings() { #ifdef Q_OS_WIN32 const QString default_font = QFont("Courier New", 8).toString(); #elif defined(Q_OS_MACX) const QString default_font = QFont("Courier New", 10).toString(); #else const QString default_font = QFont("Monospace", 8).toString(); #endif #ifdef DEFAULT_PLUGIN_PATH const QString default_plugin_path = TOSTRING(DEFAULT_PLUGIN_PATH); #else const QString edb_lib_dir=QCoreApplication::applicationDirPath()+(EDB_IS_64_BIT ? "/../lib64/edb" : "/../lib/edb"); const QString edb_binary_dir=QCoreApplication::applicationDirPath(); // If the binary is in its installation directory, then look for plugins in their installation directory // Otherwise assume that we are in build directory, so the plugins are in the same directory as the binary const QString default_plugin_path = QRegExp(".*/bin/?$").exactMatch(edb_binary_dir) ? edb_lib_dir : edb_binary_dir; #endif QSettings settings; settings.beginGroup("General"); close_behavior = static_cast<CloseBehavior>(settings.value("close_behavior").value<uint>()); settings.endGroup(); settings.beginGroup("Appearance"); stack_font = settings.value("appearance.stack.font", default_font).value<QString>(); data_font = settings.value("appearance.data.font", default_font).value<QString>(); registers_font = settings.value("appearance.registers.font", default_font).value<QString>(); disassembly_font = settings.value("appearance.disassembly.font", default_font).value<QString>(); data_show_address = settings.value("appearance.data.show_address.enabled", true).value<bool>(); data_show_hex = settings.value("appearance.data.show_hex.enabled", true).value<bool>(); data_show_ascii = settings.value("appearance.data.show_ascii.enabled", true).value<bool>(); data_show_comments = settings.value("appearance.data.show_comments.enabled", true).value<bool>(); data_word_width = settings.value("appearance.data.word_width", 1).value<int>(); data_row_width = settings.value("appearance.data.row_width", 16).value<int>(); show_address_separator = settings.value("appearance.address_colon.enabled", true).value<bool>(); settings.endGroup(); settings.beginGroup("Debugging"); initial_breakpoint = static_cast<InitialBreakpoint>(settings.value("debugger.initial_breakpoint", MainSymbol).value<uint>()); warn_on_no_exec_bp = settings.value("debugger.BP_NX_warn.enabled", true).value<bool>(); find_main = settings.value("debugger.find_main.enabled", true).value<bool>(); min_string_length = settings.value("debugger.string_min", 4).value<uint>(); tty_enabled = settings.value("debugger.terminal.enabled", true).value<bool>(); tty_command = settings.value("debugger.terminal.command", "/usr/bin/xterm").value<QString>(); remove_stale_symbols = settings.value("debugger.remove_stale_symbols.enabled", true).value<bool>(); settings.endGroup(); settings.beginGroup("Disassembly"); syntax = static_cast<Syntax>(settings.value("disassembly.syntax", Intel).value<uint>()); zeros_are_filling = settings.value("disassembly.zeros_are_filling.enabled", true).value<bool>(); uppercase_disassembly = settings.value("disassembly.uppercase.enabled", false).value<bool>(); small_int_as_decimal = settings.value("disassembly.small_int_as_decimal.enabled", false).value<bool>(); settings.endGroup(); settings.beginGroup("Directories"); symbol_path = settings.value("directory.symbol.path", QString()).value<QString>(); plugin_path = settings.value("directory.plugin.path", default_plugin_path).value<QString>(); session_path = settings.value("directory.session.path", QString()).value<QString>(); settings.endGroup(); // normalize values if(data_word_width != 1 && data_word_width != 2 && data_word_width != 4 && data_word_width != 8) { data_word_width = 1; } if(data_row_width != 1 && data_row_width != 2 && data_row_width != 4 && data_row_width != 8 && data_row_width != 16) { data_row_width = 16; } // Init capstone to some default settings CapstoneEDB::init(EDB_IS_64_BIT); CapstoneEDB::Formatter::FormatOptions options = edb::v1::formatter().options(); options.capitalization = uppercase_disassembly ? CapstoneEDB::Formatter::UpperCase : CapstoneEDB::Formatter::LowerCase; options.smallNumFormat = small_int_as_decimal ? CapstoneEDB::Formatter::SmallNumAsDec : CapstoneEDB::Formatter::SmallNumAsHex; options.syntax=static_cast<CapstoneEDB::Formatter::Syntax>(syntax); edb::v1::formatter().setOptions(options); }
//ERRNO_PRINT; ERROR_PRINT(Failed to execute the daemon '%s'\n, exeprog); exit(EXIT_FAILURE); } } else if (pid < 0) { ERROR_PRINT(Failed to fork access daemon for CPU %d, cpu_id); return pid; } EXIT_IF_ERROR(socket_fd = socket(AF_LOCAL, SOCK_STREAM, 0), socket() failed); address.sun_family = AF_LOCAL; address_length = sizeof(address); snprintf(address.sun_path, sizeof(address.sun_path), TOSTRING(LIKWIDSOCKETBASE) "-%d", pid); filepath = strdup(address.sun_path); res = connect(socket_fd, (struct sockaddr *) &address, address_length); while (res && timeout > 0) { usleep(2500); res = connect(socket_fd, (struct sockaddr *) &address, address_length); if (res == 0) { break; } timeout--; DEBUG_PRINT(DEBUGLEV_INFO, Still waiting for socket %s for CPU %d..., filepath, cpu_id);
/* * Find unchanged files from a specified time from the DB * Input: * query_callback : query callback fuction to handle * result records from the query * for_time : Time from where the file/s are not changed * */ int gf_sqlite3_find_unchanged_for_time (void *db_conn, gf_query_callback_t query_callback, void *query_cbk_args, gfdb_time_t *for_time) { int ret = -1; char *query_str = NULL; gf_sql_connection_t *sql_conn = db_conn; sqlite3_stmt *prep_stmt = NULL; uint64_t for_time_usec = 0; char *base_query_str = NULL; CHECK_SQL_CONN (sql_conn, out); GF_VALIDATE_OR_GOTO(GFDB_STR_SQLITE3, query_callback, out); ret = gf_get_basic_query_stmt (&base_query_str); if (ret <= 0) { goto out; } ret = gf_asprintf (&query_str, "%s AND " /*First condition: For writes*/ "( ((" GF_COL_TB_WSEC " * " TOSTRING(GFDB_MICROSEC) " + " GF_COL_TB_WMSEC ") <= ? )" " AND " /*Second condition: For reads*/ "((" GF_COL_TB_RWSEC " * " TOSTRING(GFDB_MICROSEC) " + " GF_COL_TB_RWMSEC ") <= ?) )", base_query_str); if (ret < 0) { gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_QUERY_FAILED, "Failed to create query statement"); query_str = NULL; goto out; } for_time_usec = gfdb_time_2_usec (for_time); ret = sqlite3_prepare (sql_conn->sqlite3_db_conn, query_str, -1, &prep_stmt, 0); if (ret != SQLITE_OK) { gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_PREPARE_FAILED, "Failed to prepare statment %s :" " %s", query_str, sqlite3_errmsg (sql_conn->sqlite3_db_conn)); ret = -1; goto out; } /*Bind write wind time*/ ret = sqlite3_bind_int64 (prep_stmt, 1, for_time_usec); if (ret != SQLITE_OK) { gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_BINDING_FAILED, "Failed to bind for_time_usec " "%"PRIu64" : %s", for_time_usec, sqlite3_errmsg (sql_conn->sqlite3_db_conn)); ret = -1; goto out; } /*Bind read wind time*/ ret = sqlite3_bind_int64 (prep_stmt, 2, for_time_usec); if (ret != SQLITE_OK) { gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_BINDING_FAILED, "Failed to bind for_time_usec " "%"PRIu64" : %s", for_time_usec, sqlite3_errmsg (sql_conn->sqlite3_db_conn)); ret = -1; goto out; } /*Execute the query*/ ret = gf_sql_query_function (prep_stmt, query_callback, query_cbk_args); if (ret) { gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_QUERY_FAILED, "Failed Query %s", query_str); goto out; } ret = 0; out: sqlite3_finalize (prep_stmt); GF_FREE (base_query_str); GF_FREE (query_str); return ret; }
#define OBJECT_BINDING 0 #define MATRIX_BINDING 1 #define VISIBILITY_BINDING 2 //#define NO_GLSL_BARRIER static const char* shader = "#version 430\n" "struct Object {\n" " uint matrix;\n" " vec4 lowerLeft;\n" " vec4 extent;\n" "};\n" "\n" "shared uint sharedVisible[" TOSTRING(WORKGROUP_SIZE) "];\n" "\n" "layout( std430, binding = " TOSTRING(OBJECT_BINDING) ") buffer Objects {\n" " Object objects[];\n" "};\n" "layout( std430, binding = " TOSTRING(MATRIX_BINDING) " ) buffer Matrices {\n" " mat4 matrices[];\n" "};\n" "layout( std430, binding = " TOSTRING(VISIBILITY_BINDING) " ) buffer BufferVisible {\n" " uint visible[];\n" "};\n" #if defined(NO_GLSL_BARRIER) "layout( local_size_x = 32, local_size_y = 1, local_size_z = 1) in;\n" #else "layout( local_size_x = " TOSTRING(WORKGROUP_SIZE) ", local_size_y = 1, local_size_z = 1) in;\n" #endif
/* * Find recently changed files with a specific frequency from the DB * Input: * db_conn : db connection object * query_callback : query callback fuction to handle * result records from the query * from_time : Time to define what is recent * freq_write_cnt : Frequency thresold for write * freq_read_cnt : Frequency thresold for read * clear_counters : Clear counters (r/w) for all inodes in DB * */ int gf_sqlite3_find_recently_changed_files_freq (void *db_conn, gf_query_callback_t query_callback, void *query_cbk_args, gfdb_time_t *from_time, int freq_write_cnt, int freq_read_cnt, gf_boolean_t clear_counters) { int ret = -1; char *query_str = NULL; gf_sql_connection_t *sql_conn = db_conn; sqlite3_stmt *prep_stmt = NULL; uint64_t from_time_usec = 0; char *base_query_str = NULL; CHECK_SQL_CONN (sql_conn, out); GF_VALIDATE_OR_GOTO(GFDB_STR_SQLITE3, query_callback, out); ret = gf_get_basic_query_stmt (&base_query_str); if (ret <= 0) { goto out; } ret = gf_asprintf (&query_str, "%s AND " /*First condition: For Writes*/ "( ( ((" GF_COL_TB_WSEC " * " TOSTRING(GFDB_MICROSEC) " + " GF_COL_TB_WMSEC ") >= ? )" " AND "" (" GF_COL_TB_WFC " >= ? ) )" " OR " /*Second condition: For Reads */ "( ((" GF_COL_TB_RWSEC " * " TOSTRING(GFDB_MICROSEC) " + " GF_COL_TB_RWMSEC ") >= ?)" " AND "" (" GF_COL_TB_RFC " >= ? ) ) )", base_query_str); if (ret < 0) { gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_QUERY_FAILED, "Failed to create query statement"); query_str = NULL; goto out; } from_time_usec = gfdb_time_2_usec (from_time); ret = sqlite3_prepare (sql_conn->sqlite3_db_conn, query_str, -1, &prep_stmt, 0); if (ret != SQLITE_OK) { gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_PREPARE_FAILED, "Failed to prepare statment %s :" " %s", query_str, sqlite3_errmsg (sql_conn->sqlite3_db_conn)); ret = -1; goto out; } /*Bind write wind time*/ ret = sqlite3_bind_int64 (prep_stmt, 1, from_time_usec); if (ret != SQLITE_OK) { gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_BINDING_FAILED, "Failed to bind from_time_usec " "%"PRIu64" : %s", from_time_usec, sqlite3_errmsg (sql_conn->sqlite3_db_conn)); ret = -1; goto out; } /*Bind write frequency thresold*/ ret = sqlite3_bind_int (prep_stmt, 2, freq_write_cnt); if (ret != SQLITE_OK) { gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_BINDING_FAILED, "Failed to bind freq_write_cnt " "%d : %s", freq_write_cnt, sqlite3_errmsg (sql_conn->sqlite3_db_conn)); ret = -1; goto out; } /*Bind read wind time*/ ret = sqlite3_bind_int64 (prep_stmt, 3, from_time_usec); if (ret != SQLITE_OK) { gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_BINDING_FAILED, "Failed to bind from_time_usec " "%"PRIu64" : %s", from_time_usec, sqlite3_errmsg (sql_conn->sqlite3_db_conn)); ret = -1; goto out; } /*Bind read frequency thresold*/ ret = sqlite3_bind_int (prep_stmt, 4, freq_read_cnt); if (ret != SQLITE_OK) { gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_BINDING_FAILED, "Failed to bind freq_read_cnt " "%d : %s", freq_read_cnt, sqlite3_errmsg (sql_conn->sqlite3_db_conn)); ret = -1; goto out; } /*Execute the query*/ ret = gf_sql_query_function (prep_stmt, query_callback, query_cbk_args); if (ret) { gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_QUERY_FAILED, "Failed Query %s", query_str); goto out; } /*Clear counters*/ if (clear_counters) { ret = gf_sql_clear_counters (sql_conn); if (ret) { gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_CLEAR_COUNTER_FAILED, "Failed to clear" " counters!"); goto out; } } ret = 0; out: sqlite3_finalize (prep_stmt); GF_FREE (base_query_str); GF_FREE (query_str); return ret; }
Device::Device (const char* cfg, bool singledevice) : State(singledevice) { /* check CPU */ if (!hasISA(ISA)) throw_RTCError(RTC_UNSUPPORTED_CPU,"CPU does not support " ISA_STR); /* initialize global state */ State::parseString(cfg); if (!ignore_config_files && FileName::executableFolder() != FileName("")) State::parseFile(FileName::executableFolder()+FileName(".embree" TOSTRING(RTCORE_VERSION_MAJOR))); if (!ignore_config_files && FileName::homeFolder() != FileName("")) State::parseFile(FileName::homeFolder()+FileName(".embree" TOSTRING(RTCORE_VERSION_MAJOR))); State::verify(); /*! do some internal tests */ assert(isa::Cylinder::verify()); /*! enable huge page support if desired */ #if defined(__WIN32__) if (State::enable_selockmemoryprivilege) State::hugepages_success &= win_enable_selockmemoryprivilege(State::verbosity(3)); #endif State::hugepages_success &= os_init(State::hugepages,State::verbosity(3)); /*! set tessellation cache size */ setCacheSize( State::tessellation_cache_size ); /*! enable some floating point exceptions to catch bugs */ if (State::float_exceptions) { int exceptions = _MM_MASK_MASK; //exceptions &= ~_MM_MASK_INVALID; exceptions &= ~_MM_MASK_DENORM; exceptions &= ~_MM_MASK_DIV_ZERO; //exceptions &= ~_MM_MASK_OVERFLOW; //exceptions &= ~_MM_MASK_UNDERFLOW; //exceptions &= ~_MM_MASK_INEXACT; _MM_SET_EXCEPTION_MASK(exceptions); } /* print info header */ if (State::verbosity(1)) print(); if (State::verbosity(2)) State::print(); /* register all algorithms */ instance_factory = make_unique(new InstanceFactory(enabled_cpu_features)); bvh4_factory = make_unique(new BVH4Factory(enabled_builder_cpu_features, enabled_cpu_features)); #if defined(EMBREE_TARGET_SIMD8) bvh8_factory = make_unique(new BVH8Factory(enabled_builder_cpu_features, enabled_cpu_features)); #endif /* setup tasking system */ initTaskingSystem(numThreads); /* ray stream SOA to AOS conversion */ #if defined(EMBREE_RAY_PACKETS) RayStreamFilterFuncsType rayStreamFilterFuncs; SELECT_SYMBOL_DEFAULT_SSE42_AVX_AVX2_AVX512KNL_AVX512SKX(enabled_cpu_features,rayStreamFilterFuncs); rayStreamFilters = rayStreamFilterFuncs(); #endif }
int main() { int ret, status; unsigned nocTx; mppa_dnoc_header_t header = { 0 }; mppa_dnoc_channel_config_t config = { 0 }; mppa_ethernet_header_t eth_header; memset(ð_header, 0, sizeof(eth_header)); ret = odp_rpc_server_start(); if (ret) { fprintf(stderr, "[RPC] Error: Failed to start server\n"); exit(EXIT_FAILURE); } printf("CNOC setup\n"); if (cluster_init_cnoc_rx() < 0){ fprintf(stderr, "Failed to setup CNoC\n"); exit(EXIT_FAILURE); } printf("CNOC setup done\n"); printf("Spawning clusters\n"); { static char const * _argv[] = { "pktio-ddr", "-i", "ioddr0:min_rx=" TOSTRING(MIN_TAG) ":max_rx=" TOSTRING(MAX_TAG) ":tags=" TOSTRING(N_RX) ":log2fragments=" TOSTRING(_ODP_LOG2MAX_FRAGS) ":cnoc=2:rrpolicy=20:rroffset=20:fc=1,drop", "-m", "0", "-s", "0", "-t", "15", "-c", "2", NULL }; boot_cluster(0, _argv[0], _argv); } printf("Cluster booted\n"); for (int i = 0; i < DATA_SIZE; ++i) data[i] = i; ret = mppa_routing_get_dnoc_unicast_route(128, 0, &config, &header); if (ret != MPPA_ROUTING_RET_SUCCESS) { fprintf(stderr, "Failed to route to cluster 0\n"); return -1; } config._.loopback_multicast = 0; config._.cfg_pe_en = 1; config._.cfg_user_en = 1; config._.write_pe_en = 1; config._.write_user_en = 1; config._.decounter_id = 0; config._.decounted = 0; config._.payload_min = 0; config._.payload_max = 32; config._.bw_current_credit = 0xff; config._.bw_max_credit = 0xff; config._.bw_fast_delay = 0x00; config._.bw_slow_delay = 0x00; header._.multicast = 0; header._.valid = 1; ret = mppa_noc_dnoc_tx_alloc_auto(0, &nocTx, MPPA_NOC_BLOCKING); if (ret != MPPA_NOC_RET_SUCCESS) { fprintf(stderr, "Failed to find an available Tx on DMA 0\n"); return -1; } sleep(10); header._.tag = MIN_TAG; eth_header.timestamp = 0; eth_header.info._.pkt_id = 0; eth_header.info._.pkt_size = PKTIO_MTU + sizeof(eth_header); uint64_t pkt_count = 0; printf("Start sending\n"); while(pkt_count < 1200000) { for( int i = 0; i < DATA_SIZE / PKTIO_MTU; i ++) { uint64_t remote_pkt_count; ret = mppa_noc_dnoc_tx_configure(0, nocTx, header, config); if (ret != MPPA_NOC_RET_SUCCESS) { fprintf(stderr, "Failed to configure Tx\n"); return -1; } eth_header.timestamp++; eth_header.info._.pkt_id++; do { remote_pkt_count = mppa_noc_cnoc_rx_get_value(0, CNOC_RX); } while(pkt_count > remote_pkt_count + (MAX_TAG - MIN_TAG + 1)); mppa_noc_dnoc_tx_send_data(0, nocTx, sizeof(eth_header), ð_header); mppa_noc_dnoc_tx_send_data_eot(0, nocTx, PKTIO_MTU, &data[i * PKTIO_MTU]); header._.tag++; if (header._.tag > MAX_TAG) header._.tag = MIN_TAG; pkt_count++; } } if ((ret = join_clusters(&status)) != 0) { fprintf(stderr, "Failed to joined clusters\n"); return ret; } if (status){ fprintf(stderr, "Clusters returned with errors: %d\n", status); fflush(stderr); return status; } return 0; }
int init_configuration(void) { int i; FILE* fp; char line[512]; char name[128]; char value[256]; char filename[1024]; filename[0] = '\0'; char preconfigured[1024]; preconfigured[0] = '\0'; if (init_config == 1) { return 0; } sprintf(preconfigured, "%s%s",TOSTRING(INSTALL_PREFIX),"/etc/likwid.cfg"); if (access(preconfigured, R_OK) != 0) { if (access(TOSTRING(CFGFILE), R_OK) != 0) { if (!access("/etc/likwid.cfg",R_OK)) { sprintf(filename,"%s", "/etc/likwid.cfg"); } } else { sprintf(filename,"%s",TOSTRING(CFGFILE)); } } else { sprintf(filename, "%s",preconfigured); } if ((config.topologyCfgFileName == NULL) && (strlen(filename) == 0)) { if (!access("/etc/likwid_topo.cfg", R_OK)) { preconfigured[0] = '\0'; sprintf(preconfigured,"%s", "/etc/likwid_topo.cfg"); } else { sprintf(preconfigured, "%s%s",TOSTRING(INSTALL_PREFIX),"/etc/likwid_topo.cfg"); if (access(preconfigured, R_OK)) { preconfigured[0] = '\0'; } } if (preconfigured[0] != '\0') { config.topologyCfgFileName = (char*)malloc((strlen(preconfigured)+1) * sizeof(char)); strcpy(config.topologyCfgFileName, preconfigured); config.topologyCfgFileName[strlen(preconfigured)] = '\0'; } } if ((strlen(filename) == 0) || (!access(filename, R_OK))) { return -EFAULT; } DEBUG_PRINT(DEBUGLEV_INFO, Reading configuration from %s, filename); // Copy determined config filename to struct config.configFileName = malloc((strlen(filename)+1)*sizeof(char)); strcpy(config.configFileName, filename); config.configFileName[strlen(filename)] = '\0'; fp = fopen(config.configFileName, "r"); if (fp == NULL) { return -EFAULT; } while (fgets(line, 512, fp) != NULL) { if (sscanf(line,"%s = %s", name, value) != 2) { continue; } if (strcmp(name, "topology_file") == 0) { config.topologyCfgFileName = (char*)malloc((strlen(value)+1) * sizeof(char)); strcpy(config.topologyCfgFileName, value); config.topologyCfgFileName[strlen(value)] = '\0'; } else if (strcmp(name, "daemon_path") == 0) { config.daemonPath = (char*)malloc((strlen(value)+1) * sizeof(char)); strcpy(config.daemonPath, value); config.daemonPath[strlen(value)] = '\0'; } else if (strcmp(name, "daemon_mode") == 0) { if (strcmp(value, "daemon") == 0) { config.daemonMode = ACCESSMODE_DAEMON; } else if (strcmp(value, "direct") == 0) { config.daemonMode = ACCESSMODE_DIRECT; } } else if (strcmp(name, "max_threads") == 0) { config.maxNumThreads = atoi(value); } else if (strcmp(name, "max_nodes") == 0) { config.maxNumNodes = atoi(value); } } init_config = 1; fclose(fp); return 0; }
/* * Find unchanged files from a specified time from the DB * Input: * query_callback : query callback fuction to handle * result records from the query * for_time : Time from where the file/s are not changed * */ int gf_sqlite3_find_unchanged_for_time (void *db_conn, gf_query_callback_t query_callback, void *query_cbk_args, gfdb_time_t *for_time) { int ret = -1; char *query_str = NULL; gf_sql_connection_t *sql_conn = db_conn; sqlite3_stmt *prep_stmt = NULL; uint64_t for_time_usec = 0; CHECK_SQL_CONN (sql_conn, out); GF_VALIDATE_OR_GOTO(GFDB_STR_SQLITE3, query_callback, out); query_str = "select GF_FILE_TB.GF_ID," " (select group_concat( GF_PID || ',' || FNAME || ','" " || FPATH || ',' || W_DEL_FLAG ||',' || LINK_UPDATE , '::')" " from GF_FLINK_TB where GF_FILE_TB.GF_ID = GF_FLINK_TB.GF_ID)" " from GF_FILE_TB where " /*First condition: For writes*/ "((" GF_COL_TB_WSEC " * " TOSTRING(GFDB_MICROSEC) " + " GF_COL_TB_WMSEC ") <= ? )" " AND " /*Second condition: For reads*/ "((" GF_COL_TB_RWSEC " * " TOSTRING(GFDB_MICROSEC) " + " GF_COL_TB_RWMSEC ") <= ?)"; for_time_usec = gfdb_time_2_usec(for_time); ret = sqlite3_prepare(sql_conn->sqlite3_db_conn, query_str, -1, &prep_stmt, 0); if (ret != SQLITE_OK) { gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_PREPARE_FAILED, "Failed preparing statment %s :" " %s", query_str, sqlite3_errmsg(sql_conn->sqlite3_db_conn)); ret = -1; goto out; } /*Bind write wind time*/ ret = sqlite3_bind_int64(prep_stmt, 1, for_time_usec); if (ret != SQLITE_OK) { gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_BINDING_FAILED, "Failed binding for_time_usec " "%"PRIu64" : %s", for_time_usec, sqlite3_errmsg(sql_conn->sqlite3_db_conn)); ret = -1; goto out; } /*Bind read wind time*/ ret = sqlite3_bind_int64(prep_stmt, 2, for_time_usec); if (ret != SQLITE_OK) { gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_BINDING_FAILED, "Failed binding for_time_usec " "%"PRIu64" : %s", for_time_usec, sqlite3_errmsg(sql_conn->sqlite3_db_conn)); ret = -1; goto out; } /*Execute the query*/ ret = gf_sql_query_function(prep_stmt, query_callback, query_cbk_args); if (ret) { gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_QUERY_FAILED, "Failed Query %s", query_str); goto out; } ret = 0; out: sqlite3_finalize(prep_stmt); return ret; }
const char* nvtokenCommandToString(GLenum type){ switch (type){ TOSTRING(GL_NOP_COMMAND_NV ); TOSTRING(GL_DRAW_ELEMENTS_INSTANCED_COMMAND_NV); TOSTRING(GL_DRAW_ARRAYS_INSTANCED_COMMAND_NV ); TOSTRING(GL_ELEMENT_ADDRESS_COMMAND_NV ); TOSTRING(GL_ATTRIBUTE_ADDRESS_COMMAND_NV ); TOSTRING(GL_UNIFORM_ADDRESS_COMMAND_NV ); TOSTRING(GL_BLEND_COLOR_COMMAND_NV ); TOSTRING(GL_STENCIL_REF_COMMAND_NV ); TOSTRING(GL_TERMINATE_SEQUENCE_COMMAND_NV ); TOSTRING(GL_LINE_WIDTH_COMMAND_NV ); TOSTRING(GL_POLYGON_OFFSET_COMMAND_NV ); TOSTRING(GL_ALPHA_REF_COMMAND_NV ); TOSTRING(GL_VIEWPORT_COMMAND_NV ); TOSTRING(GL_SCISSOR_COMMAND_NV ); TOSTRING(GL_DRAW_ELEMENTS_COMMAND_NV ); TOSTRING(GL_DRAW_ARRAYS_COMMAND_NV ); TOSTRING(GL_DRAW_ELEMENTS_STRIP_COMMAND_NV ); TOSTRING(GL_DRAW_ARRAYS_STRIP_COMMAND_NV ); } return NULL; }
/* * Find unchanged files from a specified time, w.r.t to frequency, from the DB * Input: * query_callback : query callback fuction to handle * result records from the query * for_time : Time from where the file/s are not changed * freq_write_cnt : Frequency thresold for write * freq_read_cnt : Frequency thresold for read * clear_counters : Clear counters (r/w) for all inodes in DB * */ int gf_sqlite3_find_unchanged_for_time_freq (void *db_conn, gf_query_callback_t query_callback, void *query_cbk_args, gfdb_time_t *for_time, int freq_write_cnt, int freq_read_cnt, gf_boolean_t clear_counters) { int ret = -1; char *query_str = NULL; gf_sql_connection_t *sql_conn = db_conn; sqlite3_stmt *prep_stmt = NULL; uint64_t for_time_usec = 0; CHECK_SQL_CONN (sql_conn, out); GF_VALIDATE_OR_GOTO (GFDB_STR_SQLITE3, query_callback, out); query_str = "select GF_FILE_TB.GF_ID," " (select group_concat( GF_PID || ',' || FNAME || ','" " || FPATH || ',' || W_DEL_FLAG ||',' || LINK_UPDATE , '::')" " from GF_FLINK_TB where GF_FILE_TB.GF_ID = GF_FLINK_TB.GF_ID)" " from GF_FILE_TB where " /*First condition: For Writes * Files that have write wind time smaller than for_time * OR * File that have write wind time greater than for_time, * but write_frequency less than freq_write_cnt*/ "( ((" GF_COL_TB_WSEC " * " TOSTRING(GFDB_MICROSEC) " + " GF_COL_TB_WMSEC ") < ? )" " OR " "( (" GF_COL_TB_WFC " < ? ) AND" "((" GF_COL_TB_WSEC " * " TOSTRING(GFDB_MICROSEC) " + " GF_COL_TB_WMSEC ") >= ? ) ) )" " AND " /*Second condition: For Reads * Files that have read wind time smaller than for_time * OR * File that have read wind time greater than for_time, * but write_frequency less than freq_write_cnt*/ "( ((" GF_COL_TB_RWSEC " * " TOSTRING(GFDB_MICROSEC) " + " GF_COL_TB_RWMSEC ") < ? )" " OR " "( (" GF_COL_TB_RFC " < ? ) AND" "((" GF_COL_TB_RWSEC " * " TOSTRING(GFDB_MICROSEC) " + " GF_COL_TB_RWMSEC ") >= ? ) ) )"; for_time_usec = gfdb_time_2_usec(for_time); ret = sqlite3_prepare (sql_conn->sqlite3_db_conn, query_str, -1, &prep_stmt, 0); if (ret != SQLITE_OK) { gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_PREPARE_FAILED, "Failed preparing delete " "statment %s : %s", query_str, sqlite3_errmsg(sql_conn->sqlite3_db_conn)); ret = -1; goto out; } /*Bind write wind time*/ ret = sqlite3_bind_int64 (prep_stmt, 1, for_time_usec); if (ret != SQLITE_OK) { gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_BINDING_FAILED, "Failed binding for_time_usec " "%"PRIu64" : %s", for_time_usec, sqlite3_errmsg(sql_conn->sqlite3_db_conn)); ret = -1; goto out; } /*Bind write frequency thresold*/ ret = sqlite3_bind_int (prep_stmt, 2, freq_write_cnt); if (ret != SQLITE_OK) { gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_BINDING_FAILED, "Failed binding freq_write_cnt" " %d : %s", freq_write_cnt, sqlite3_errmsg(sql_conn->sqlite3_db_conn)); ret = -1; goto out; } /*Bind write wind time*/ ret = sqlite3_bind_int64 (prep_stmt, 3, for_time_usec); if (ret != SQLITE_OK) { gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_BINDING_FAILED, "Failed binding for_time_usec " "%"PRIu64" : %s", for_time_usec, sqlite3_errmsg(sql_conn->sqlite3_db_conn)); ret = -1; goto out; } /*Bind read wind time*/ ret = sqlite3_bind_int64 (prep_stmt, 4, for_time_usec); if (ret != SQLITE_OK) { gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_BINDING_FAILED, "Failed binding for_time_usec " "%"PRIu64" : %s", for_time_usec, sqlite3_errmsg(sql_conn->sqlite3_db_conn)); ret = -1; goto out; } /*Bind read frequency thresold*/ ret = sqlite3_bind_int (prep_stmt, 5, freq_read_cnt); if (ret != SQLITE_OK) { gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_BINDING_FAILED, "Failed binding freq_read_cnt " "%d : %s", freq_read_cnt, sqlite3_errmsg(sql_conn->sqlite3_db_conn)); ret = -1; goto out; } /*Bind read wind time*/ ret = sqlite3_bind_int64 (prep_stmt, 6, for_time_usec); if (ret != SQLITE_OK) { gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_BINDING_FAILED, "Failed binding for_time_usec " "%"PRIu64" : %s", for_time_usec, sqlite3_errmsg(sql_conn->sqlite3_db_conn)); ret = -1; goto out; } /*Execute the query*/ ret = gf_sql_query_function (prep_stmt, query_callback, query_cbk_args); if (ret) { gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_QUERY_FAILED, "Failed Query %s", query_str); goto out; } /*Clear counters*/ if (clear_counters) { ret = gf_sql_clear_counters (sql_conn); if (ret) { gf_msg (GFDB_STR_SQLITE3, GF_LOG_ERROR, 0, LG_MSG_CLEAR_COUNTER_FAILED, "Failed clearing " "counters!"); goto out; } } ret = 0; out: sqlite3_finalize(prep_stmt); return ret; }
void FlexBody::printMeshInfo(Mesh* mesh) { if(faulty) return; if (mesh->sharedVertexData) { LOG("FLEXBODY Mesh has Shared Vertices:"); VertexData* vt=mesh->sharedVertexData; LOG("FLEXBODY element count:"+TOSTRING(vt->vertexDeclaration->getElementCount())); for (int j=0; j<(int)vt->vertexDeclaration->getElementCount(); j++) { const VertexElement* ve=vt->vertexDeclaration->getElement(j); LOG("FLEXBODY element "+TOSTRING(j)+" source "+TOSTRING(ve->getSource())); LOG("FLEXBODY element "+TOSTRING(j)+" offset "+TOSTRING(ve->getOffset())); LOG("FLEXBODY element "+TOSTRING(j)+" type "+TOSTRING(ve->getType())); LOG("FLEXBODY element "+TOSTRING(j)+" semantic "+TOSTRING(ve->getSemantic())); LOG("FLEXBODY element "+TOSTRING(j)+" size "+TOSTRING(ve->getSize())); } } LOG("FLEXBODY Mesh has "+TOSTRING(mesh->getNumSubMeshes())+" submesh(es)"); for (int i=0; i<mesh->getNumSubMeshes(); i++) { SubMesh* submesh = mesh->getSubMesh(i); LOG("FLEXBODY SubMesh "+TOSTRING(i)+": uses shared?:"+TOSTRING(submesh->useSharedVertices)); if (!submesh->useSharedVertices) { VertexData* vt=submesh->vertexData; LOG("FLEXBODY element count:"+TOSTRING(vt->vertexDeclaration->getElementCount())); for (int j=0; j<(int)vt->vertexDeclaration->getElementCount(); j++) { const VertexElement* ve=vt->vertexDeclaration->getElement(j); LOG("FLEXBODY element "+TOSTRING(j)+" source "+TOSTRING(ve->getSource())); LOG("FLEXBODY element "+TOSTRING(j)+" offset "+TOSTRING(ve->getOffset())); LOG("FLEXBODY element "+TOSTRING(j)+" type "+TOSTRING(ve->getType())); LOG("FLEXBODY element "+TOSTRING(j)+" semantic "+TOSTRING(ve->getSemantic())); LOG("FLEXBODY element "+TOSTRING(j)+" size "+TOSTRING(ve->getSize())); } } } }
inline void MapDatabaseSQLite3::bindPos(sqlite3_stmt *stmt, const v3s16 &pos, int index) { SQLOK(sqlite3_bind_int64(stmt, index, getBlockAsInteger(pos)), "Internal error: failed to bind query at " __FILE__ ":" TOSTRING(__LINE__)); }
char *AppConfig_GetVersion(void) { return TOSTRING(LIB_VERSION); }
You should have received a copy of the GNU General Public License along with Foobar. If not, see <http://www.gnu.org/licenses/>. */ #include "stark.h" #ifdef UBIGRAPHAPI_H #define UBISTRING ":UBI" #else #define UBISTRING #endif const char starkinit[] = "STARK:O" TOSTRING(OFFSET_L) ":HARD_MAXDEPTH:" TOSTRING(HARD_MAXDEPTH) UBISTRING ":MD5:" TOSTRING(STARK_MD5) "\n"; const char foursymbol_index[] = {['A'] = 0, ['C'] = 1, ['G'] = 2, ['T'] = 3, ['U'] = 3}; //char foursymbol_index[2]['U'+1] = {{['A'] = 0, ['C'] = 1, ['G'] = 2, ['T'] = 3, ['U'] = 3},{['A'] = 3, ['C'] = 2, ['G'] = 1, ['T'] = 0, ['U'] = 0}}; const char parent_Link_index[] = {['A'] = STARK_PARENT2_LINK_A, ['C'] = STARK_PARENT2_LINK_C, ['G'] = STARK_PARENT2_LINK_G, ['T'] = STARK_PARENT2_LINK_T, ['U'] = STARK_PARENT2_LINK_T}; const char parent_Link_to_char[] = { [STARK_PARENT1_LINK_A] = 'A', [STARK_PARENT1_LINK_C] = 'C', [STARK_PARENT1_LINK_G] = 'G', [STARK_PARENT1_LINK_T] = 'T', [STARK_PARENT2_LINK_A] = 'A', [STARK_PARENT2_LINK_C] = 'C', [STARK_PARENT2_LINK_G] = 'G', [STARK_PARENT2_LINK_T] = 'T'};
void RoR::GfxEnvmap::SetupEnvMap() { m_rtt_texture = Ogre::TextureManager::getSingleton().getByName("EnvironmentTexture"); for (int face = 0; face < NUM_FACES; face++) { m_render_targets[face] = m_rtt_texture->getBuffer(face)->getRenderTarget(); m_cameras[face] = gEnv->sceneManager->createCamera("EnvironmentCamera-" + TOSTRING(face)); m_cameras[face]->setAspectRatio(1.0); m_cameras[face]->setProjectionType(Ogre::PT_PERSPECTIVE); m_cameras[face]->setFixedYawAxis(false); m_cameras[face]->setFOVy(Ogre::Degree(90)); m_cameras[face]->setNearClipDistance(0.1f); m_cameras[face]->setFarClipDistance(gEnv->mainCamera->getFarClipDistance()); Ogre::Viewport* v = m_render_targets[face]->addViewport(m_cameras[face]); v->setOverlaysEnabled(false); v->setClearEveryFrame(true); v->setBackgroundColour(gEnv->mainCamera->getViewport()->getBackgroundColour()); m_render_targets[face]->setAutoUpdated(false); } m_cameras[0]->setDirection(+Ogre::Vector3::UNIT_X); m_cameras[1]->setDirection(-Ogre::Vector3::UNIT_X); m_cameras[2]->setDirection(+Ogre::Vector3::UNIT_Y); m_cameras[3]->setDirection(-Ogre::Vector3::UNIT_Y); m_cameras[4]->setDirection(-Ogre::Vector3::UNIT_Z); m_cameras[5]->setDirection(+Ogre::Vector3::UNIT_Z); if (App::diag_envmap.GetActive()) { // create fancy mesh for debugging the envmap Ogre::Overlay* overlay = Ogre::OverlayManager::getSingleton().create("EnvMapDebugOverlay"); if (overlay) { Ogre::Vector3 position = Ogre::Vector3::ZERO; float scale = 1.0f; Ogre::MeshPtr mesh = Ogre::MeshManager::getSingletonPtr()->createManual("cubeMapDebug", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); // create sub mesh Ogre::SubMesh* sub = mesh->createSubMesh(); // Initialize render operation sub->operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST; // sub->useSharedVertices = true; mesh->sharedVertexData = new Ogre::VertexData; sub->indexData = new Ogre::IndexData; // Create vertex declaration size_t offset = 0; mesh->sharedVertexData->vertexDeclaration->addElement(0, offset, Ogre::VET_FLOAT3, Ogre::VES_POSITION); offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3); mesh->sharedVertexData->vertexDeclaration->addElement(0, offset, Ogre::VET_FLOAT3, Ogre::VES_TEXTURE_COORDINATES); // Create and bind vertex buffer mesh->sharedVertexData->vertexCount = 14; Ogre::HardwareVertexBufferSharedPtr vertexBuffer = Ogre::HardwareBufferManager::getSingleton().createVertexBuffer( mesh->sharedVertexData->vertexDeclaration->getVertexSize(0), mesh->sharedVertexData->vertexCount, Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY); mesh->sharedVertexData->vertexBufferBinding->setBinding(0, vertexBuffer); // Vertex data static const float vertexData[] = { // Position Texture coordinates // Index 0.0, 2.0, -1.0, 1.0, 1.0, // 0 0.0, 1.0, -1.0, -1.0, 1.0, // 1 1.0, 2.0, -1.0, 1.0, -1.0, // 2 1.0, 1.0, -1.0, -1.0, -1.0, // 3 2.0, 2.0, 1.0, 1.0, -1.0, // 4 2.0, 1.0, 1.0, -1.0, -1.0, // 5 3.0, 2.0, 1.0, 1.0, 1.0, // 6 3.0, 1.0, 1.0, -1.0, 1.0, // 7 4.0, 2.0, -1.0, 1.0, 1.0, // 8 4.0, 1.0, -1.0, -1.0, 1.0, // 9 1.0, 3.0, -1.0, 1.0, 1.0, // 10 2.0, 3.0, 1.0, 1.0, 1.0, // 11 1.0, 0.0, -1.0, -1.0, 1.0, // 12 2.0, 0.0, 1.0, -1.0, 1.0, // 13 }; // Fill vertex buffer float* pData = static_cast<float*>(vertexBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD)); for (size_t vertex = 0, i = 0; vertex < mesh->sharedVertexData->vertexCount; vertex++) { // Position *pData++ = position.x + scale * vertexData[i++]; *pData++ = position.y + scale * vertexData[i++]; *pData++ = 0.0; // Texture coordinates *pData++ = vertexData[i++]; *pData++ = vertexData[i++]; *pData++ = vertexData[i++]; } vertexBuffer->unlock(); // Create index buffer sub->indexData->indexCount = 36; Ogre::HardwareIndexBufferSharedPtr indexBuffer = Ogre::HardwareBufferManager::getSingleton().createIndexBuffer( Ogre::HardwareIndexBuffer::IT_16BIT, sub->indexData->indexCount, Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY); sub->indexData->indexBuffer = indexBuffer; // Index data static const Ogre::uint16 indexData[] = { // Indices // Face 0, 1, 2, // 0 2, 1, 3, // 1 2, 3, 4, // 2 4, 3, 5, // 3 4, 5, 6, // 4 6, 5, 7, // 5 6, 7, 8, // 6 8, 7, 9, // 7 10, 2, 11, // 8 11, 2, 4, // 9 3, 12, 5, // 10 5, 12, 13, // 11 }; // Fill index buffer indexBuffer->writeData(0, indexBuffer->getSizeInBytes(), indexData, true); mesh->_setBounds(Ogre::AxisAlignedBox::BOX_INFINITE); mesh->_setBoundingSphereRadius(10); mesh->load(); Ogre::Entity* e = gEnv->sceneManager->createEntity(mesh->getName()); e->setCastShadows(false); e->setRenderQueueGroup(Ogre::RENDER_QUEUE_OVERLAY - 1); e->setVisible(true); e->setMaterialName("tracks/EnvMapDebug"); Ogre::SceneNode* mDebugSceneNode = new Ogre::SceneNode(gEnv->sceneManager); mDebugSceneNode->attachObject(e); mDebugSceneNode->setPosition(Ogre::Vector3(0, 0, -5)); mDebugSceneNode->setFixedYawAxis(true, Ogre::Vector3::UNIT_Y); mDebugSceneNode->setVisible(true); mDebugSceneNode->_update(true, true); mDebugSceneNode->_updateBounds(); overlay->add3D(mDebugSceneNode); overlay->show(); } } }
int main(int argc, char *argv[]) { char *host = NULL; char *renderer = NULL; int width = 800; int height = 600; int fullscreen = 0; #ifdef EVENT_HOST host = EVENT_HOST; #endif #ifdef DEFAULT_RENDERER renderer = TOSTRING(DEFAULT_RENDERER); #endif // GUI Environment setzt default Renderer um. if (getenv("GUI")) renderer = getenv("GUI"); #ifdef WIN32 char *sep = strrchr(argv[0], '\\'); if (sep) { *sep = '\0'; chdir(argv[0]); } // Spezialfaelle fuer Windows Screensaver Aufrufe if (argc == 2 && stricmp(argv[1], "/s") == 0) { host = "infon.dividuum.de"; width = 1024, height = 768, fullscreen = 1; goto screen_saver_start; } else if (argc == 3 && stricmp(argv[1], "/p") == 0) { exit(EXIT_SUCCESS); } else if (argc == 2 && strstr(argv[1], "/c:") == argv[1]) { die("There are no settings"); } #endif // Keine Fehler auf stderr opterr = 0; int opt; while ((opt = getopt(argc, argv, ":fvx:y:r:h")) != -1) { switch (opt) { case '?': die("you specified an unknown option -%c.", optopt); case ':': die("missing argument to option -%c.", optopt); case 'r': renderer = optarg; break; case 'f': fullscreen = 1; break; case 'x': width = atoi(optarg); break; case 'y': height = atoi(optarg); break; case 'h': die("usage: %s [-r <renderer>] [-f] [-x <width>] [-y <height>] [-v] [-h] <server[:port]>\n" "\n" " -r <renderer> - renderer to use (sdl_gui, gl_gui, ...)\n" " -x <width> - initial screen width.\n" " -y <height> - initial screen height.\n" " -f - start in fullscreen mode.\n" " -v - display version information.\n" " -h - this help.\n" "\n" "<server[:port]> - ip/hostname of an infon game server.\n" " if no port is given, 1234 is used.\n", argv[0]); case 'v': info(); exit(EXIT_SUCCESS); } } switch (argc - optind) { case 0: break; case 1: host = argv[optind]; break; default: die("you specified more than one game server hostname"); } if (!renderer) die("no renderer specified. use the '-r <renderer>' option"); #ifdef WIN32 if (!host) { if (yesno("You did not specify a game server.\nConnect to 'infon.dividuum.de:1234'?")) host = "infon.dividuum.de"; else die("You must supply the game servers hostname\n" "as a command line parameter.\n\n" "Example: 'infon.exe infon.dividuum.de'\n\n" "Visit http://infon.dividuum.de/ for help."); } #else if (!host) die("usage: %s [options] <server[:port]>\n" "see %s -h for a full list of options", argv[0], argv[0]); #endif #ifndef WIN32 signal(SIGTERM, sighandler); signal(SIGINT, sighandler); signal(SIGPIPE, SIG_IGN); #else screen_saver_start: #endif srand(time(NULL)); gettimeofday(&start, NULL); if (!renderer_init(renderer)) die("cannot initialize the renderer '%s'", renderer); if (!renderer_open(width, height, fullscreen)) die("cannot start the renderer '%s'. sorry", renderer); client_init(host); client_game_init(); int lastticks = get_tick(); while (!signal_received && !renderer_wants_shutdown() && client_is_connected()) { int nowticks = get_tick(); int delta = nowticks - lastticks; if (nowticks < lastticks || nowticks > lastticks + 1000) { // Timewarp? lastticks = nowticks; continue; } lastticks = nowticks; // IO Lesen/Schreiben client_tick(delta); client_creature_move(delta); renderer_tick(game_time, delta); game_time += delta; } client_game_shutdown(); client_shutdown(); renderer_close(); renderer_shutdown(); return EXIT_SUCCESS; }