ReductionType map_reduce_vertices(GraphType& g, MapFunctionType mapfunction, const vertex_set& vset = GraphType::complete_set()) { BOOST_CONCEPT_ASSERT((graphlab::Serializable<ReductionType>)); BOOST_CONCEPT_ASSERT((graphlab::OpPlusEq<ReductionType>)); typedef typename GraphType::vertex_type vertex_type; if(!g.is_finalized()) { logstream(LOG_FATAL) << "\n\tAttempting to run graph.map_reduce_vertices(...) " << "\n\tbefore calling graph.finalize()." << std::endl; } g.dc().barrier(); bool global_result_set = false; ReductionType global_result = ReductionType(); #ifdef _OPENMP #pragma omp parallel #endif { bool result_set = false; ReductionType result = ReductionType(); #ifdef _OPENMP #pragma omp for #endif for (int i = 0; i < (int)g.num_local_vertices(); ++i) { auto lvertex = g.l_vertex(i); if (lvertex.owned() && vset.l_contains(lvid_type(i))) { if (!result_set) { vertex_type vtx(lvertex); result = mapfunction(vtx); result_set = true; } else if (result_set){ const vertex_type vtx(lvertex); const ReductionType tmp = mapfunction(vtx); result += tmp; } } } #ifdef _OPENMP #pragma omp critical #endif { if (result_set) { if (!global_result_set) { global_result = result; global_result_set = true; } else { global_result += result; } } } } conditional_addition_wrapper<ReductionType> wrapper(global_result, global_result_set); g.dc().all_reduce(wrapper); return wrapper.value; } // end of map_reduce_vertices
void FsGuiCommonDrawing::DrawGradationPolygon(int n,const double plg[],const YsColor c[]) { #ifdef YSOGLERRORCHECK FsOpenGlShowError("%s In",__FUNCTION__); #endif YsArray <float,32> vtx(n*2,NULL); YsArray <float,64> col(n*4,NULL); for(int i=0; i<n; ++i) { vtx[i*2 ]=(float)plg[i*2]; vtx[i*2+1]=(float)plg[i*2+1]; col[i*4 ]=c[i].Rf(); col[i*4+1]=c[i].Gf(); col[i*4+2]=c[i].Bf(); col[i*4+3]=c[i].Af(); } YsGLSLUsePlain2DRenderer(YsGLSLSharedPlain2DRenderer()); YsGLSLDrawPlain2DPrimitivefv(YsGLSLSharedPlain2DRenderer(), GL_TRIANGLE_FAN, n,vtx,col); YsGLSLEndUsePlain2DRenderer(YsGLSLSharedPlain2DRenderer()); #ifdef YSOGLERRORCHECK FsOpenGlShowError("%s Out",__FUNCTION__); #endif }
void setup_a(const Oracle *oracl) { vertex vtx(oracl->new_algo(this)); vtx.ascend(); a_ = oracl->get_by(vtx)->a_ | (word_t(1) << get_i()->height()); }
static void initSphere() { int ibLen, vbLen; getSphereVbIbLen(20, 10, vbLen, ibLen); // Temporary storage for sphere Geometry vector<VertexPNTBX> vtx(vbLen); vector<unsigned short> idx(ibLen); makeSphere(1, 20, 10, vtx.begin(), idx.begin()); g_sphere.reset(new SimpleIndexedGeometryPNTBX(&vtx[0], &idx[0], vtx.size(), idx.size())); }
static void initCubes() { int ibLen, vbLen; getCubeVbIbLen(vbLen, ibLen); // Temporary storage for cube Geometry vector<VertexPNTBX> vtx(vbLen); vector<unsigned short> idx(ibLen); makeCube(1, vtx.begin(), idx.begin()); g_cube.reset(new SimpleIndexedGeometryPNTBX(&vtx[0], &idx[0], vbLen, ibLen)); }
//====================================================================== // STEP 3: Replace initGround(), initCube(), and initSphere() functions // with the following defintion. This ensures VertexPNTBX and // SimpleIndexedGeometryPNTBX are used, which provides extra // vertex attributes used for Bump Mapping later //======================================================================= static void initGround() { int ibLen, vbLen; getPlaneVbIbLen(vbLen, ibLen); // Temporary storage for cube Geometry vector<VertexPNTBX> vtx(vbLen); vector<unsigned short> idx(ibLen); makePlane(g_groundSize*2, vtx.begin(), idx.begin()); g_ground.reset(new SimpleIndexedGeometryPNTBX(&vtx[0], &idx[0], vbLen, ibLen)); }
void BenchmarkDemo::createTest6() { setCameraDistance(btScalar(250.)); btVector3 boxSize(1.5f,1.5f,1.5f); btConvexHullShape* convexHullShape = new btConvexHullShape(); for (int i=0;i<TaruVtxCount;i++) { btVector3 vtx(TaruVtx[i*3],TaruVtx[i*3+1],TaruVtx[i*3+2]); convexHullShape->addPoint(vtx); } btTransform trans; trans.setIdentity(); float mass = 1.f; btVector3 localInertia(0,0,0); convexHullShape->calculateLocalInertia(mass,localInertia); { int size = 10; int height = 10; const float cubeSize = boxSize[0]; float spacing = 2.0f; btVector3 pos(0.0f, 20.0f, 0.0f); float offset = -size * (cubeSize * 2.0f + spacing) * 0.5f; for(int k=0;k<height;k++) { for(int j=0;j<size;j++) { pos[2] = offset + (float)j * (cubeSize * 2.0f + spacing); for(int i=0;i<size;i++) { pos[0] = offset + (float)i * (cubeSize * 2.0f + spacing); btVector3 bpos = btVector3(0,25,0) + btVector3(5.0f,1.0f,5.0f)*pos; trans.setOrigin(bpos); localCreateRigidBody(mass,trans,convexHullShape); } } offset -= 0.05f * spacing * (size-1); spacing *= 1.1f; pos[1] += (cubeSize * 2.0f + spacing); } } createLargeMeshBody(); }
main() { page pg; FeynDiagram fd(pg); vertex_dot vtx(fd,0,0); line_spring gluon(fd,xy(-5,0),vtx); gluon.arrowon.settrue(); line_plain ghost(fd,vtx,vtx); ghost.arcthru(3,0,1); ghost.dashon.settrue(); ghost.dsratio.set(0); ghost.thickness.scale(1.8); pg.output(); return 0; }
void BenchmarkDemo::createTest4() { setCameraDistance(btScalar(50.)); int size = 8; const float cubeSize = 1.5f; float spacing = cubeSize; btVector3 pos(0.0f, cubeSize * 2, 0.0f); float offset = -size * (cubeSize * 2.0f + spacing) * 0.5f; btConvexHullShape* convexHullShape = new btConvexHullShape(); btScalar scaling(1); convexHullShape->setLocalScaling(btVector3(scaling,scaling,scaling)); for (int i=0;i<TaruVtxCount;i++) { btVector3 vtx(TaruVtx[i*3],TaruVtx[i*3+1],TaruVtx[i*3+2]); convexHullShape->addPoint(vtx*btScalar(1./scaling)); } //this will enable polyhedral contact clipping, better quality, slightly slower //convexHullShape->initializePolyhedralFeatures(); btTransform trans; trans.setIdentity(); float mass = 1.f; btVector3 localInertia(0,0,0); convexHullShape->calculateLocalInertia(mass,localInertia); for(int k=0;k<15;k++) { for(int j=0;j<size;j++) { pos[2] = offset + (float)j * (cubeSize * 2.0f + spacing); for(int i=0;i<size;i++) { pos[0] = offset + (float)i * (cubeSize * 2.0f + spacing); trans.setOrigin(pos); localCreateRigidBody(mass,trans,convexHullShape); } } offset -= 0.05f * spacing * (size-1); spacing *= 1.01f; pos[1] += (cubeSize * 2.0f + spacing); } }
int btTriangleMesh::findOrAddVertex(const btVector3& vertex, bool removeDuplicateVertices) { //return index of new/existing vertex ///@todo: could use acceleration structure for this if (m_use4componentVertices) { if (removeDuplicateVertices) { for (int i=0;i< m_4componentVertices.size();i++) { if ((m_4componentVertices[i]-vertex).length2() <= m_weldingThreshold) { return i; } } } m_indexedMeshes[0].m_numVertices++; m_4componentVertices.push_back(vertex); m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_4componentVertices[0]; return m_4componentVertices.size()-1; } else { if (removeDuplicateVertices) { for (int i=0;i< m_3componentVertices.size();i+=3) { btVector3 vtx(m_3componentVertices[i],m_3componentVertices[i+1],m_3componentVertices[i+2]); if ((vtx-vertex).length2() <= m_weldingThreshold) { return i/3; } } } m_3componentVertices.push_back((float)vertex.getX()); m_3componentVertices.push_back((float)vertex.getY()); m_3componentVertices.push_back((float)vertex.getZ()); m_indexedMeshes[0].m_numVertices++; m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_3componentVertices[0]; return (m_3componentVertices.size()/3)-1; } }
int CLPhysicsDemo::registerConcaveMesh(btAlignedObjectArray<btVector3>* vertices, btAlignedObjectArray<int>* indices,const float* scaling1) { btVector3 scaling(scaling1[0],scaling1[1],scaling1[2]); int collidableIndex = m_narrowphaseAndSolver->allocateCollidable(); btCollidable& col = m_narrowphaseAndSolver->getCollidableCpu(collidableIndex); col.m_shapeType = CollisionShape::SHAPE_CONCAVE_TRIMESH; col.m_shapeIndex = m_narrowphaseAndSolver->registerConcaveMeshShape(vertices,indices,col,scaling); btAABBHost aabbMin, aabbMax; btVector3 myAabbMin(1e30f,1e30f,1e30f); btVector3 myAabbMax(-1e30f,-1e30f,-1e30f); for (int i=0;i<vertices->size();i++) { btVector3 vtx(vertices->at(i)*scaling); myAabbMin.setMin(vtx); myAabbMax.setMax(vtx); } aabbMin.fx = myAabbMin[0];//s_convexHeightField->m_aabb.m_min.x; aabbMin.fy = myAabbMin[1];//s_convexHeightField->m_aabb.m_min.y; aabbMin.fz= myAabbMin[2];//s_convexHeightField->m_aabb.m_min.z; aabbMin.uw = 0; aabbMax.fx = myAabbMax[0];//s_convexHeightField->m_aabb.m_max.x; aabbMax.fy = myAabbMax[1];//s_convexHeightField->m_aabb.m_max.y; aabbMax.fz= myAabbMax[2];//s_convexHeightField->m_aabb.m_max.z; aabbMax.uw = 0; m_data->m_localShapeAABBCPU->push_back(aabbMin); m_data->m_localShapeAABBGPU->push_back(aabbMin); m_data->m_localShapeAABBCPU->push_back(aabbMax); m_data->m_localShapeAABBGPU->push_back(aabbMax); clFinish(g_cqCommandQue); return collidableIndex; }
/*---------------------------------------------------------------------*//** フォーカス配列からフォーカスカーソルの描画 **//*---------------------------------------------------------------------*/ void FocusCursor::drawFocusCursor(Renderer* rdr, const FocusArray* fa, f32 scale, f32 rate2dr) { if(!fa->isCalculateScreenPos()) { return; } RectF32 vtx(- W_FOCUS_CIRC / 2, - H_FOCUS_CIRC / 2, W_FOCUS_CIRC, H_FOCUS_CIRC); RectF32 uv; if(scale != 1.0f) { vtx *= scale; } // フォーカスカーソル表示 for(s32 i = 0; i < fa->getCount(); i++) { const Unit* unitFocused = fa->getUnit(i); if(unitFocused == 0L) { continue; } // フォーカスがある場合のみ以下を処理する const Vector2F* posScr = fa->getScreenPos(i); // 画面外チェック if( ((posScr->x() + W_FOCUS_CIRC) < 0) || ((posScr->x() - W_FOCUS_CIRC) >= Game::getGame()->getLogicalWidth()) || ((posScr->y() + H_FOCUS_CIRC) < 0) || ((posScr->y() - H_FOCUS_CIRC) >= Game::getGame()->getLogicalHeight()) ) { continue; } // 描画 ::glPushMatrix(); // 行列を保存 ::glTranslatef((f32)posScr->x(), (f32)posScr->y(), 0.0f); drawQuestIcon(rdr, unitFocused, rate2dr); // クエストアイコン表示 ::glRotatef(_dangFocus, 0.0f, 0.0f, 1.0f); // フォーカスカーソル表示 RendererUtils::draw2dTextureRect( rdr, &vtx, Gcalc::calcTexUv(&uv, UV_FOCUS, W_TEX, H_TEX, rate2dr) ); ::glPopMatrix(); // 行列を戻す } }
static bool ON_Brep_GetTightBoundingBox_Helper( const ON_Brep& brep, ON_BoundingBox& bbox, ON_Xform* xform ) { ON_Xform xform_inverse; ON_Xform* inverse = NULL; if( xform ) { xform_inverse = xform->Inverse(); inverse = &xform_inverse; } // make sure we have an empty/invalid bbox bbox.Destroy(); // Compute Vertex bounding box. int vertex_count = brep.m_V.Count(); if( xform ) { ON_3dPointArray vtx(vertex_count); for( int i=0; i<vertex_count; i++ ) vtx.Append(brep.m_V[i].point); vtx.GetTightBoundingBox(bbox, false, xform); } else { for( int i=0; i<vertex_count; i++ ) bbox.Set(brep.m_V[i].point,true); } // Grow partial result with Edge bounding boxes. int edge_count = brep.m_E.Count(); for( int i=0; i<edge_count; i++) ON_Brep_GetTightCurveBoundingBox_Helper(brep.m_E[i], bbox, xform, inverse); // Grow partial result with Face bounding boxes. int face_count = brep.m_F.Count(); for( int i=0; i<face_count; i++) ON_Brep_GetTightFaceBoundingBox_Helper(brep.m_F[i], bbox, xform, inverse); return bbox.IsValid(); }
int CLPhysicsDemo::registerConcaveMesh(objLoader* obj,const float* scaling) { int collidableIndex = narrowphaseAndSolver->allocateCollidable(); btCollidable& col = narrowphaseAndSolver->getCollidableCpu(collidableIndex); col.m_shapeType = CollisionShape::SHAPE_CONCAVE_TRIMESH; col.m_shapeIndex = narrowphaseAndSolver->registerConcaveMeshShape(obj,col,scaling); btAABBHost aabbMin, aabbMax; btVector3 myAabbMin(1e30f,1e30f,1e30f); btVector3 myAabbMax(-1e30f,-1e30f,-1e30f); for (int i=0;i<obj->vertexCount;i++) { btVector3 vtx(obj->vertexList[i]->e[0]*scaling[0],obj->vertexList[i]->e[1]*scaling[1],obj->vertexList[i]->e[2]*scaling[2]); myAabbMin.setMin(vtx); myAabbMax.setMax(vtx); } aabbMin.fx = myAabbMin[0];//s_convexHeightField->m_aabb.m_min.x; aabbMin.fy = myAabbMin[1];//s_convexHeightField->m_aabb.m_min.y; aabbMin.fz= myAabbMin[2];//s_convexHeightField->m_aabb.m_min.z; aabbMin.uw = 0; aabbMax.fx = myAabbMax[0];//s_convexHeightField->m_aabb.m_max.x; aabbMax.fy = myAabbMax[1];//s_convexHeightField->m_aabb.m_max.y; aabbMax.fz= myAabbMax[2];//s_convexHeightField->m_aabb.m_max.z; aabbMax.uw = 0; m_data->m_localShapeAABBCPU->push_back(aabbMin); m_data->m_localShapeAABBGPU->push_back(aabbMin); m_data->m_localShapeAABBCPU->push_back(aabbMax); m_data->m_localShapeAABBGPU->push_back(aabbMax); clFinish(g_cqCommandQue); return collidableIndex; }
void FsGuiCommonDrawing::DrawLineStrip(int n,const double plg[],const YsColor &c) { YsArray <float,32> vtx(n*2,NULL); YsArray <float,64> col(n*4,NULL); for(int i=0; i<n; ++i) { vtx[i*2 ]=(float)plg[i*2]; vtx[i*2+1]=(float)plg[i*2+1]; col[i*4 ]=c.Rf(); col[i*4+1]=c.Gf(); col[i*4+2]=c.Bf(); col[i*4+3]=c.Af(); } YsGLSLUsePlain2DRenderer(YsGLSLSharedPlain2DRenderer()); YsGLSLDrawPlain2DPrimitivefv(YsGLSLSharedPlain2DRenderer(), GL_LINE_STRIP, n,vtx,col); YsGLSLEndUsePlain2DRenderer(YsGLSLSharedPlain2DRenderer()); }
void transform_vertices(GraphType& g, TransformType transform_functor, const vertex_set vset = GraphType::complete_set()) { typedef typename GraphType::vertex_type vertex_type; if(!g.is_finalized()) { logstream(LOG_FATAL) << "\n\tAttempting to call graph.transform_vertices(...)" << "\n\tbefore finalizing the graph." << std::endl; } g.dc().barrier(); size_t ibegin = 0; size_t iend = g.num_local_vertices(); parallel_for (ibegin, iend, [&](size_t i) { auto lvertex = g.l_vertex(i); if (lvertex.owned() && vset.l_contains(lvid_type(i))) { vertex_type vtx(lvertex); transform_functor(vtx); } }); g.dc().barrier(); g.synchronize(); }
void setup_i(Oracle *oracl) { vertex vtx(oracl->new_algo(this)); vtx.iterate(0); this_t *ltI = oracl->get_by(vtx)->get_i(), *rtI = (oracl->get_by(vtx) + 1)->get_i(); const word_t idH = height(), ltH = ltI->height(), rtH = rtI->height(); if (idH > ltH && idH > rtH) set_inode(); else if (ltH < rtH) { set_i(rtI); rtI->set_l(this); } else { set_i(ltI); ltI->set_l(this); } }
int b3GpuNarrowPhase::registerConcaveMesh(b3AlignedObjectArray<b3Vector3>* vertices, b3AlignedObjectArray<int>* indices,const float* scaling1) { b3Vector3 scaling(scaling1[0],scaling1[1],scaling1[2]); int collidableIndex = allocateCollidable(); if (collidableIndex<0) return collidableIndex; b3Collidable& col = getCollidableCpu(collidableIndex); col.m_shapeType = SHAPE_CONCAVE_TRIMESH; col.m_shapeIndex = registerConcaveMeshShape(vertices,indices,col,scaling); col.m_bvhIndex = m_data->m_bvhInfoCPU.size(); b3SapAabb aabb; b3Vector3 myAabbMin(1e30f,1e30f,1e30f); b3Vector3 myAabbMax(-1e30f,-1e30f,-1e30f); for (int i=0;i<vertices->size();i++) { b3Vector3 vtx(vertices->at(i)*scaling); myAabbMin.setMin(vtx); myAabbMax.setMax(vtx); } aabb.m_min[0] = myAabbMin[0]; aabb.m_min[1] = myAabbMin[1]; aabb.m_min[2] = myAabbMin[2]; aabb.m_minIndices[3] = 0; aabb.m_max[0] = myAabbMax[0]; aabb.m_max[1]= myAabbMax[1]; aabb.m_max[2]= myAabbMax[2]; aabb.m_signedMaxIndices[3]= 0; m_data->m_localShapeAABBCPU->push_back(aabb); // m_data->m_localShapeAABBGPU->push_back(aabb); b3OptimizedBvh* bvh = new b3OptimizedBvh(); //void b3OptimizedBvh::build(b3StridingMeshInterface* triangles, bool useQuantizedAabbCompression, const b3Vector3& bvhAabbMin, const b3Vector3& bvhAabbMax) bool useQuantizedAabbCompression = true; b3TriangleIndexVertexArray* meshInterface=new b3TriangleIndexVertexArray(); b3IndexedMesh mesh; mesh.m_numTriangles = indices->size()/3; mesh.m_numVertices = vertices->size(); mesh.m_vertexBase = (const unsigned char *)&vertices->at(0).getX(); mesh.m_vertexStride = sizeof(b3Vector3); mesh.m_triangleIndexStride = 3 * sizeof(int);// or sizeof(int) mesh.m_triangleIndexBase = (const unsigned char *)&indices->at(0); meshInterface->addIndexedMesh(mesh); bvh->build(meshInterface, useQuantizedAabbCompression, (b3Vector3&)aabb.m_min, (b3Vector3&)aabb.m_max); m_data->m_bvhData.push_back(bvh); int numNodes = bvh->getQuantizedNodeArray().size(); //b3OpenCLArray<b3QuantizedBvhNode>* treeNodesGPU = new b3OpenCLArray<b3QuantizedBvhNode>(this->m_context,this->m_queue,numNodes); int numSubTrees = bvh->getSubtreeInfoArray().size(); b3BvhInfo bvhInfo; bvhInfo.m_aabbMin = bvh->m_bvhAabbMin; bvhInfo.m_aabbMax = bvh->m_bvhAabbMax; bvhInfo.m_quantization = bvh->m_bvhQuantization; bvhInfo.m_numNodes = numNodes; bvhInfo.m_numSubTrees = numSubTrees; bvhInfo.m_nodeOffset = m_data->m_treeNodesCPU.size(); bvhInfo.m_subTreeOffset = m_data->m_subTreesCPU.size(); m_data->m_bvhInfoCPU.push_back(bvhInfo); int numNewSubtrees = bvh->getSubtreeInfoArray().size(); m_data->m_subTreesCPU.reserve(m_data->m_subTreesCPU.size()+numNewSubtrees); for (int i=0;i<numNewSubtrees;i++) { m_data->m_subTreesCPU.push_back(bvh->getSubtreeInfoArray()[i]); } int numNewTreeNodes = bvh->getQuantizedNodeArray().size(); for (int i=0;i<numNewTreeNodes;i++) { m_data->m_treeNodesCPU.push_back(bvh->getQuantizedNodeArray()[i]); } return collidableIndex; }
void InternalEdgeDemo::initPhysics() { setTexturing(true); setShadows(false);//true); #define TRISIZE 10.f gContactAddedCallback = CustomMaterialCombinerCallback; #define USE_TRIMESH_SHAPE 1 #ifdef USE_TRIMESH_SHAPE int vertStride = sizeof(btVector3); int indexStride = 3*sizeof(int); const int totalTriangles = 2*(NUM_VERTS_X-1)*(NUM_VERTS_Y-1); gVertices = new btVector3[totalVerts]; gIndices = new int[totalTriangles*3]; int i; setVertexPositions(waveheight,0.f); //gVertices[1].setY(21.1); //gVertices[1].setY(121.1); gVertices[1].setY(.1f); #ifdef ROTATE_GROUND //gVertices[1].setY(-1.1); #else //gVertices[1].setY(0.1); //gVertices[1].setY(-0.1); //gVertices[1].setY(-20.1); //gVertices[1].setY(-20); #endif int index=0; for ( i=0;i<NUM_VERTS_X-1;i++) { for (int j=0;j<NUM_VERTS_Y-1;j++) { #ifdef SWAP_WINDING #ifdef SHIFT_INDICES gIndices[index++] = j*NUM_VERTS_X+i; gIndices[index++] = (j+1)*NUM_VERTS_X+i+1; gIndices[index++] = j*NUM_VERTS_X+i+1; gIndices[index++] = j*NUM_VERTS_X+i; gIndices[index++] = (j+1)*NUM_VERTS_X+i; gIndices[index++] = (j+1)*NUM_VERTS_X+i+1; #else gIndices[index++] = (j+1)*NUM_VERTS_X+i+1; gIndices[index++] = j*NUM_VERTS_X+i+1; gIndices[index++] = j*NUM_VERTS_X+i; gIndices[index++] = (j+1)*NUM_VERTS_X+i; gIndices[index++] = (j+1)*NUM_VERTS_X+i+1; gIndices[index++] = j*NUM_VERTS_X+i; #endif //SHIFT_INDICES #else //SWAP_WINDING #ifdef SHIFT_INDICES gIndices[index++] = (j+1)*NUM_VERTS_X+i+1; gIndices[index++] = j*NUM_VERTS_X+i; gIndices[index++] = j*NUM_VERTS_X+i+1; #ifdef TEST_INCONSISTENT_WINDING gIndices[index++] = j*NUM_VERTS_X+i; gIndices[index++] = (j+1)*NUM_VERTS_X+i; gIndices[index++] = (j+1)*NUM_VERTS_X+i+1; #else //TEST_INCONSISTENT_WINDING gIndices[index++] = (j+1)*NUM_VERTS_X+i; gIndices[index++] = j*NUM_VERTS_X+i; gIndices[index++] = (j+1)*NUM_VERTS_X+i+1; #endif //TEST_INCONSISTENT_WINDING #else //SHIFT_INDICES gIndices[index++] = j*NUM_VERTS_X+i; gIndices[index++] = j*NUM_VERTS_X+i+1; gIndices[index++] = (j+1)*NUM_VERTS_X+i+1; gIndices[index++] = j*NUM_VERTS_X+i; gIndices[index++] = (j+1)*NUM_VERTS_X+i+1; gIndices[index++] = (j+1)*NUM_VERTS_X+i; #endif //SHIFT_INDICES #endif //SWAP_WINDING } } m_indexVertexArrays = new btTriangleIndexVertexArray(totalTriangles, gIndices, indexStride, totalVerts,(btScalar*) &gVertices[0].x(),vertStride); bool useQuantizedAabbCompression = true; //comment out the next line to read the BVH from disk (first run the demo once to create the BVH) #define SERIALIZE_TO_DISK 1 #ifdef SERIALIZE_TO_DISK btVector3 aabbMin(-1000,-1000,-1000),aabbMax(1000,1000,1000); trimeshShape = new btBvhTriangleMeshShape(m_indexVertexArrays,useQuantizedAabbCompression,aabbMin,aabbMax); m_collisionShapes.push_back(trimeshShape); ///we can serialize the BVH data void* buffer = 0; int numBytes = trimeshShape->getOptimizedBvh()->calculateSerializeBufferSize(); buffer = btAlignedAlloc(numBytes,16); bool swapEndian = false; trimeshShape->getOptimizedBvh()->serialize(buffer,numBytes,swapEndian); #ifdef __QNX__ FILE* file = fopen("app/native/bvh.bin","wb"); #else FILE* file = fopen("bvh.bin","wb"); #endif fwrite(buffer,1,numBytes,file); fclose(file); btAlignedFree(buffer); #else trimeshShape = new btBvhTriangleMeshShape(m_indexVertexArrays,useQuantizedAabbCompression,false); char* fileName = "bvh.bin"; #ifdef __QNX__ char* fileName = "app/native/bvh.bin"; #else char* fileName = "bvh.bin"; #endif int size=0; btOptimizedBvh* bvh = 0; if (fseek(file, 0, SEEK_END) || (size = ftell(file)) == EOF || fseek(file, 0, SEEK_SET)) { /* File operations denied? ok, just close and return failure */ printf("Error: cannot get filesize from %s\n", fileName); exit(0); } else { fseek(file, 0, SEEK_SET); int buffersize = size+btOptimizedBvh::getAlignmentSerializationPadding(); void* buffer = btAlignedAlloc(buffersize,16); int read = fread(buffer,1,size,file); fclose(file); bool swapEndian = false; bvh = btOptimizedBvh::deSerializeInPlace(buffer,buffersize,swapEndian); } trimeshShape->setOptimizedBvh(bvh); #endif btCollisionShape* groundShape = trimeshShape; btTriangleInfoMap* triangleInfoMap = new btTriangleInfoMap(); btGenerateInternalEdgeInfo(trimeshShape,triangleInfoMap); #else btCollisionShape* groundShape = new btBoxShape(btVector3(50,3,50)); m_collisionShapes.push_back(groundShape); #endif //USE_TRIMESH_SHAPE m_collisionConfiguration = new btDefaultCollisionConfiguration(); m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); m_broadphase = new btDbvtBroadphase(); m_solver = new btSequentialImpulseConstraintSolver(); m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration); /* m_dynamicsWorld->getSolverInfo().m_splitImpulse = true; m_dynamicsWorld->getSolverInfo().m_splitImpulsePenetrationThreshold = 1e30f; m_dynamicsWorld->getSolverInfo().m_maxErrorReduction = 1e30f; m_dynamicsWorld->getSolverInfo().m_erp =1.f; m_dynamicsWorld->getSolverInfo().m_erp2 = 1.f; */ m_dynamicsWorld->setGravity(btVector3(0,-10,0)); float mass = 0.f; btTransform startTransform; startTransform.setIdentity(); startTransform.setOrigin(btVector3(0,-2,0)); btConvexHullShape* colShape = new btConvexHullShape(); for (int i=0;i<TaruVtxCount;i++) { btVector3 vtx(TaruVtx[i*3],TaruVtx[i*3+1],TaruVtx[i*3+2]); colShape->addPoint(vtx); } //this will enable polyhedral contact clipping, better quality, slightly slower colShape->initializePolyhedralFeatures(); //the polyhedral contact clipping can use either GJK or SAT test to find the separating axis m_dynamicsWorld->getDispatchInfo().m_enableSatConvex=false; m_collisionShapes.push_back(colShape); { for (int i=0;i<1;i++) { startTransform.setOrigin(btVector3(-10.f+i*3.f,2.2f+btScalar(i)*0.1f,-1.3f)); btRigidBody* body = localCreateRigidBody(10, startTransform,colShape); body->setActivationState(DISABLE_DEACTIVATION); body->setLinearVelocity(btVector3(0,0,-1)); //body->setContactProcessingThreshold(0.f); } } { btBoxShape* colShape = new btBoxShape(btVector3(1,1,1)); colShape->initializePolyhedralFeatures(); m_collisionShapes.push_back(colShape); startTransform.setOrigin(btVector3(-16.f+i*3.f,1.f+btScalar(i)*0.1f,-1.3f)); btRigidBody* body = localCreateRigidBody(10, startTransform,colShape); body->setActivationState(DISABLE_DEACTIVATION); body->setLinearVelocity(btVector3(0,0,-1)); } startTransform.setIdentity(); #ifdef ROTATE_GROUND btQuaternion orn(btVector3(0,0,1),SIMD_PI); startTransform.setOrigin(btVector3(-20,0,0)); startTransform.setRotation(orn); #endif //ROTATE_GROUND staticBody = localCreateRigidBody(mass, startTransform,groundShape); //staticBody->setContactProcessingThreshold(-0.031f); staticBody->setCollisionFlags(staticBody->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);//STATIC_OBJECT); //enable custom material callback staticBody->setCollisionFlags(staticBody->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK); getDynamicsWorld()->setDebugDrawer(&gDebugDrawer); setDebugMode(btIDebugDraw::DBG_DrawText|btIDebugDraw::DBG_NoHelpText+btIDebugDraw::DBG_DrawWireframe+btIDebugDraw::DBG_DrawContactPoints); #ifdef BT_INTERNAL_EDGE_DEBUG_DRAW btSetDebugDrawer(&gDebugDrawer); #endif //BT_INTERNAL_EDGE_DEBUG_DRAW }
int main(/*int argc, char *argv[]*/) { typedef patl::trie_set<std::string> StringSet; StringSet test1, test2; //&test2 = test1; // test1.insert("balka"); test1.insert("balet"); test1.insert("bulat"); test1.insert("bulka"); test1.insert("bal"); // test2.insert("balet"); test2.insert("balon"); test2.insert("bal"); test2.insert("baton"); // test1.merge(test2.begin(), test2.end()); test1.change_root(test1.find("balon")); // { typedef StringSet::const_iterator const_iterator; typedef std::pair<const_iterator, const_iterator> pair_cit_cit; pair_cit_cit pcc = test1.equal_range("balda"); const_iterator low_cit = test1.lower_bound("balda"), upp_cit = test1.upper_bound("balda"); printf("equal == <lower, upper>: %s\n", pcc == std::make_pair(low_cit, upp_cit) ? "true" : "false"); printf("range of 'balda' (first: %s, limit: %s):\n", pcc.first != test1.end() ? pcc.first->c_str() : "end", pcc.second != test1.end() ? pcc.second->c_str() : "end"); for (const_iterator cit = pcc.first; cit != pcc.second; ++cit) printf("\t%s\n", cit->c_str()); // printf("\n---\n\n"); // pcc = test1.equal_range("balda", 3 * 8); low_cit = test1.lower_bound("balda", 3 * 8); upp_cit = test1.upper_bound("balda", 3 * 8); printf("equal == <lower, upper>: %s\n", pcc == std::make_pair(low_cit, upp_cit) ? "true" : "false"); printf("range of 'balda' [3] (first: %s, limit: %s):\n", pcc.first != test1.end() ? pcc.first->c_str() : "end", pcc.second != test1.end() ? pcc.second->c_str() : "end"); for (const_iterator cit = pcc.first; cit != pcc.second; ++cit) printf("\t%s\n", cit->c_str()); } // printf("\n--- iterator\n\n"); // { typedef StringSet::const_iterator const_iter; const_iter itBeg = test1.begin(), itEnd = test1.end(), it = itBeg; for (; it != itEnd; ++it) printf("%s\n", it->c_str()); printf("---\n"); while (it != itBeg) { --it; printf("%s\n", it->c_str()); } } // printf("\n--- partial_match\n\n"); // { typedef patl::partial_match<StringSet, false> part_match; part_match pm(test1, "b?l?t"); StringSet::const_partimator<part_match> it = test1.begin(pm), itEnd = test1.end(pm); printf("*** 'b?l?t':\n"); for (; it != itEnd; ++it) printf("%s\n", it->c_str()); printf("---\n"); pm = part_match(test1, "b?l??"); it = test1.begin(pm); itEnd = test1.end(pm); printf("*** 'b?l??\':\n"); for (; it != itEnd; ++it) printf("%s\n", it->c_str()); } // printf("\n--- hamming_distance\n\n"); // { typedef patl::hamming_distance<StringSet, false> hamm_dist; hamm_dist hd(test1, 1, "bulk"); StringSet::const_partimator<hamm_dist> it = test1.begin(hd), itEnd = test1.end(hd); printf("*** 'bulk', dist == 1:\n"); for (; it != itEnd; ++it) printf("%s, dist: %u\n", it->c_str(), it.decis().distance()); } // printf("\n--- levenshtein_distance\n\n"); // { typedef patl::levenshtein_distance<StringSet, false> leven_dist; leven_dist ld(test1, 1, "balt"); StringSet::const_partimator<leven_dist> it = test1.begin(ld), itEnd = test1.end(ld); printf("*** 'balt', dist == 1:\n"); for (; it != itEnd; ++it) printf("%s, dist: %u\n", it->c_str(), it.decis().distance()); } // printf("\n--- postorder_iterator\n\n"); // typedef StringSet::const_vertex const_vertex; const const_vertex vtx_root = test1.root(); { typedef StringSet::const_postorder_iterator const_postorder_iterator; const_postorder_iterator itBeg = vtx_root.postorder_begin(), itEnd = vtx_root.postorder_end(), it = itBeg; for (; it != itEnd; ++it) printf("%d\t%s\n", it->skip(), it->key().c_str()); printf("---\n"); while (it != itBeg) { --it; printf("%d\t%s\n", it->skip(), it->key().c_str()); } } // printf("\n--- preorder_iterator\n\n"); // { typedef StringSet::const_preorder_iterator const_preorder_iterator; const_preorder_iterator itBeg = vtx_root.preorder_begin(), itEnd = vtx_root.preorder_end(), it = itBeg; preorder_iterator_callback<typename StringSet::const_vertex> icb; for (; it != itEnd; /*++it*/it.increment(icb)) printf("%d\t%s\n", it->skip(), it->key().c_str()); printf("---\n"); while (it != itBeg) { //--it; it.decrement(icb); printf("%d\t%s\n", it->skip(), it->key().c_str()); } } // printf("\n--- preorder_iterator with levelorder behavior\n\n"); // { const char *const X[] = { "asm", "auto", "bool", "break", "case", "catch", "char", "class", "const", "const_cast", "continue", "default", "delete", "do", "double", "dynamic_cast", "else", "enum", "explicit", "export", "extern", "false", "float", "for", "friend", "goto", "if", "inline", "int", "long", "mutable", "namespace", "new", "operator", "private", "protected", "public", "register", "reinterpret_cast", "return", "short", "signed", "sizeof", "static", "static_cast", "struct", "switch", "template", "this", "throw", "true", "try", "typedef", "typeid", "typename", "union", "unsigned", "using", "virtual", "void", "volatile", "wchar_t", "while"}; // typedef patl::trie_set<std::string> ReservSet; typedef ReservSet::const_vertex const_vertex; const ReservSet rvset(X, X + sizeof(X) / sizeof(X[0])); // printf("*** Regexp:\n"); const_vertex vtx = rvset.root(); print_regexp(0, vtx.preorder_begin(8), vtx.preorder_end()); printf("\n"); } // printf("\n--- [super_]maxrep_iterator\n\n"); // { typedef patl::suffix_set<char*> SuffixSet; char str[] = //"abrakadabraa"; "xabcyiiizabcqabcyr"; //"cxxaxxaxxb"; //"How many wood would a woodchuck chuck."; //"xgtcacaytgtgacz"; printf("*** string: '%s':\n", str); SuffixSet suffix(str); for (word_t i = 0; i != sizeof(str) - 1; ++i) suffix.push_back(); for (uxn::patl::maxrep_iterator<SuffixSet> mrit(&suffix) ; !mrit->is_root() ; ++mrit) { printf("'%s' x %d:", std::string(mrit->key(), mrit->length()).c_str(), mrit.freq()); const SuffixSet::const_vertex vtx = mrit->get_vertex(); for (SuffixSet::const_iterator it = vtx.begin() ; it != vtx.end() ; ++it) printf(" at %u", suffix.index_of( static_cast<const SuffixSet::const_vertex&>(it))); printf("\n"); } printf("---\n"); for (uxn::patl::super_maxrep_iterator<SuffixSet> mrit(&suffix) ; !mrit->is_root() ; ++mrit) { printf("'%s' x %d:", std::string(mrit->key(), mrit->length()).c_str(), mrit.freq()); const SuffixSet::const_vertex vtx = mrit->get_vertex(); for (SuffixSet::const_iterator it = vtx.begin() ; it != vtx.end() ; ++it) printf(" at %u", suffix.index_of( static_cast<const SuffixSet::const_vertex&>(it))); printf("\n"); } } // printf("\n--- search tandem repeats in O(n)\n\n"); // { //typedef int typ; typedef char typ; typedef patl::suffix_set<const typ*> suffix_t; //typ arr[] = {10, 5, 6, 7, 5, 6, 7, 89, 64}; typ arr[] = "qabrabrabrweabrabraaaad"; //typ arr[] = "qweabrabrrrrd"; printf("*** string: '%s':\n", arr); suffix_t suf(arr, 16 /* maximal length of tandem repeat + 1 */); do { const suffix_t::const_vertex vtx = suf.push_back(), sibl = vtx.sibling(); if (suf.size() > 1) { const int skip = vtx.skip() / 8 / sizeof(typ); const word_t delta = vtx.key() - sibl.key(), count = skip / delta + 1; if (count > 1) { printf("begin: %u, length: %u, count: %u\n", sibl.key() - arr, delta, count); suf.rebind(sibl.key() + delta * count); suf.clear(); } if (!suf.empty() && suf.endpoint()) suf.pop_front(); } } while (suf.keys() + suf.size() != arr + sizeof(arr) / sizeof(arr[0])); } // printf("\n--- generate graphviz dot\n\n"); // patl::patricia_dot_creator<StringSet>().create(vtx_root); #if 0 // pat_.dot & pat_.clust.dot creation { std::ifstream fin(argc > 1 ? argv[1] : "WORD.LST"); if (fin.is_open()) { StringSet dict; std::string str; while (fin >> str) dict.insert(str); const_vertex vtx(dict.root()); // #if 0 vtx.mismatch("patch", 5 * 8); typedef StringSet::const_preorder_iterator const_preorder_iterator; const_preorder_iterator itBeg = vtx.preorder_begin(), itEnd = vtx.preorder_end(), it = itBeg; for (; it != itEnd; it.increment(6 * 8)) { if (it->limited(6 * 8)) printf("* "); printf("%d\t%s\n", it->skip(), it->key().c_str()); } printf("---\n"); while (it != itBeg) { it.decrement(6 * 8); if (it->limited(6 * 8)) printf("* "); printf("%d\t%s\n", it->skip(), it->key().c_str()); } #else vtx.mismatch("patr", 4 * 8); { std::ofstream fout("patr_.dot"); patl::patricia_dot_creator<StringSet, std::ofstream>(fout).create(vtx); } printf("\npatr_.dot created!\n"); { std::ofstream fout("patr_.clust.dot"); patl::patricia_dot_creator<StringSet, std::ofstream>(fout).create(vtx, true); } printf("\npatr_.clust.dot created!\n"); #endif } else
uint16_t i40e_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) { struct i40e_tx_queue *txq = (struct i40e_tx_queue *)tx_queue; volatile struct i40e_tx_desc *txdp; struct i40e_tx_entry *txep; uint16_t n, nb_commit, tx_id; uint64_t flags = I40E_TD_CMD; uint64_t rs = I40E_TX_DESC_CMD_RS | I40E_TD_CMD; int i; /* cross rx_thresh boundary is not allowed */ nb_pkts = RTE_MIN(nb_pkts, txq->tx_rs_thresh); if (txq->nb_tx_free < txq->tx_free_thresh) i40e_tx_free_bufs(txq); nb_commit = nb_pkts = (uint16_t)RTE_MIN(txq->nb_tx_free, nb_pkts); if (unlikely(nb_pkts == 0)) return 0; tx_id = txq->tx_tail; txdp = &txq->tx_ring[tx_id]; txep = &txq->sw_ring[tx_id]; txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_pkts); n = (uint16_t)(txq->nb_tx_desc - tx_id); if (nb_commit >= n) { tx_backlog_entry(txep, tx_pkts, n); for (i = 0; i < n - 1; ++i, ++tx_pkts, ++txdp) vtx1(txdp, *tx_pkts, flags); vtx1(txdp, *tx_pkts++, rs); nb_commit = (uint16_t)(nb_commit - n); tx_id = 0; txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1); /* avoid reach the end of ring */ txdp = &txq->tx_ring[tx_id]; txep = &txq->sw_ring[tx_id]; } tx_backlog_entry(txep, tx_pkts, nb_commit); vtx(txdp, tx_pkts, nb_commit, flags); tx_id = (uint16_t)(tx_id + nb_commit); if (tx_id > txq->tx_next_rs) { txq->tx_ring[txq->tx_next_rs].cmd_type_offset_bsz |= rte_cpu_to_le_64(((uint64_t)I40E_TX_DESC_CMD_RS) << I40E_TXD_QW1_CMD_SHIFT); txq->tx_next_rs = (uint16_t)(txq->tx_next_rs + txq->tx_rs_thresh); } txq->tx_tail = tx_id; I40E_PCI_REG_WRITE(txq->qtx_tail, txq->tx_tail); return nb_pkts; }
MObject blindDataMesh::createMesh(long seed, MObject& outData, MStatus& stat) { MFloatPointArray vertices; MIntArray faceDegrees; MIntArray faceVertices; int i, j; srand(seed); float planeSize = 20.0f; float planeOffset = planeSize / 2.0f; float planeDim = 0.5f; int numDivisions = (int) (planeSize / planeDim); // int numVertices = (numDivisions + 1) * (numDivisions + 1); // int numEdge = (2 * numDivisions) * (numDivisions + 1); int numFaces = numDivisions * numDivisions; // Set up an array containing the vertex positions for the plane. The // vertices are placed equi-distant on the X-Z plane to form a square // grid that has a side length of "planeSize". // // The Y-coordinate of each vertex is the average of the neighbors already // calculated, if there are any, with a small random offset added. Because // of the way the vertices are calculated, the whole plane will look like // it is streaked in a diagonal direction with mountains and depressions. // for (i = 0; i < (numDivisions + 1); ++i) { for (j = 0; j < (numDivisions + 1); ++j) { float height; if (i == 0 && j == 0) { height = ((rand() % 101) / 100.0f - 0.5f); } else if (i == 0) { float previousHeight = vertices[j - 1][1]; height = previousHeight + ((rand() % 101) / 100.0f - 0.5f); } else if (j == 0) { float previousHeight = vertices[(i-1)*(numDivisions + 1)][1]; height = previousHeight + ((rand() % 101) / 100.0f - 0.5f); } else { float previousHeight = vertices[(i-1)*(numDivisions + 1) + j][1]; float previousHeight2 = vertices[i*(numDivisions + 1) + j - 1][1]; height = (previousHeight + previousHeight2) / 2.0f + ((rand() % 101) / 100.0f - 0.5f); } MFloatPoint vtx( i * planeDim - planeOffset, height, j * planeDim - planeOffset ); vertices.append(vtx); } } // Set up an array containing the number of vertices // for each of the plane's faces // for (i = 0; i < numFaces; ++i) { faceDegrees.append(4); } // Set up an array to assign the vertices for each face // for (i = 0; i < numDivisions; ++i) { for (j = 0; j < numDivisions; ++j) { faceVertices.append(i*(numDivisions+1) + j); faceVertices.append(i*(numDivisions+1) + j + 1); faceVertices.append((i+1)*(numDivisions+1) + j + 1); faceVertices.append((i+1)*(numDivisions+1) + j); } } MFnMesh meshFn; MObject newMesh = meshFn.create(vertices.length(), numFaces, vertices, faceDegrees, faceVertices, outData, &stat); return newMesh; }
uint16_t fm10k_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) { struct fm10k_tx_queue *txq = (struct fm10k_tx_queue *)tx_queue; volatile struct fm10k_tx_desc *txdp; struct rte_mbuf **txep; uint16_t n, nb_commit, tx_id; uint64_t flags = FM10K_TXD_FLAG_LAST; uint64_t rs = FM10K_TXD_FLAG_RS | FM10K_TXD_FLAG_LAST; int i; /* cross rx_thresh boundary is not allowed */ nb_pkts = RTE_MIN(nb_pkts, txq->rs_thresh); if (txq->nb_free < txq->free_thresh) fm10k_tx_free_bufs(txq); nb_commit = nb_pkts = (uint16_t)RTE_MIN(txq->nb_free, nb_pkts); if (unlikely(nb_pkts == 0)) return 0; tx_id = txq->next_free; txdp = &txq->hw_ring[tx_id]; txep = &txq->sw_ring[tx_id]; txq->nb_free = (uint16_t)(txq->nb_free - nb_pkts); n = (uint16_t)(txq->nb_desc - tx_id); if (nb_commit >= n) { tx_backlog_entry(txep, tx_pkts, n); for (i = 0; i < n - 1; ++i, ++tx_pkts, ++txdp) vtx1(txdp, *tx_pkts, flags); vtx1(txdp, *tx_pkts++, rs); nb_commit = (uint16_t)(nb_commit - n); tx_id = 0; txq->next_rs = (uint16_t)(txq->rs_thresh - 1); /* avoid reach the end of ring */ txdp = &(txq->hw_ring[tx_id]); txep = &txq->sw_ring[tx_id]; } tx_backlog_entry(txep, tx_pkts, nb_commit); vtx(txdp, tx_pkts, nb_commit, flags); tx_id = (uint16_t)(tx_id + nb_commit); if (tx_id > txq->next_rs) { txq->hw_ring[txq->next_rs].flags |= FM10K_TXD_FLAG_RS; txq->next_rs = (uint16_t)(txq->next_rs + txq->rs_thresh); } txq->next_free = tx_id; FM10K_PCI_REG_WRITE(txq->tail_ptr, txq->next_free); return nb_pkts; }
uint16_t ixgbe_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) { struct ixgbe_tx_queue *txq = (struct ixgbe_tx_queue *)tx_queue; volatile union ixgbe_adv_tx_desc *txdp; struct ixgbe_tx_entry_v *txep; uint16_t n, nb_commit, tx_id; uint64_t flags = DCMD_DTYP_FLAGS; uint64_t rs = IXGBE_ADVTXD_DCMD_RS|DCMD_DTYP_FLAGS; int i; /* cross rx_thresh boundary is not allowed */ nb_pkts = RTE_MIN(nb_pkts, txq->tx_rs_thresh); if (txq->nb_tx_free < txq->tx_free_thresh) ixgbe_tx_free_bufs(txq); nb_commit = nb_pkts = (uint16_t)RTE_MIN(txq->nb_tx_free, nb_pkts); if (unlikely(nb_pkts == 0)) return 0; tx_id = txq->tx_tail; txdp = &txq->tx_ring[tx_id]; txep = &txq->sw_ring_v[tx_id]; txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_pkts); n = (uint16_t)(txq->nb_tx_desc - tx_id); if (nb_commit >= n) { tx_backlog_entry(txep, tx_pkts, n); for (i = 0; i < n - 1; ++i, ++tx_pkts, ++txdp) vtx1(txdp, *tx_pkts, flags); vtx1(txdp, *tx_pkts++, rs); nb_commit = (uint16_t)(nb_commit - n); tx_id = 0; txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1); /* avoid reach the end of ring */ txdp = &(txq->tx_ring[tx_id]); txep = &txq->sw_ring_v[tx_id]; } tx_backlog_entry(txep, tx_pkts, nb_commit); vtx(txdp, tx_pkts, nb_commit, flags); tx_id = (uint16_t)(tx_id + nb_commit); if (tx_id > txq->tx_next_rs) { txq->tx_ring[txq->tx_next_rs].read.cmd_type_len |= rte_cpu_to_le_32(IXGBE_ADVTXD_DCMD_RS); txq->tx_next_rs = (uint16_t)(txq->tx_next_rs + txq->tx_rs_thresh); } txq->tx_tail = tx_id; IXGBE_PCI_REG_WRITE(txq->tdt_reg_addr, txq->tx_tail); return nb_pkts; }
/*---------------------------------------------------------------------*//** 描画 **//*---------------------------------------------------------------------*/ void FocusCursor::draw(const RenderCtx* rc) { if(!_isEnableOut || !_isEnableSelf) { return; } // 無効化中 GameRenderCtx* grc = (GameRenderCtx*)rc; Renderer* rdr = rc->getRenderer(); RectF32 uv; // テクスチャ設定 rdr->bindTexture(_texRef); // 加算アルファ合成 rdr->setAlphaBlendFunc(Renderer::AFUNC_ADD); // 2D 解像描画比 f32 rate2dr = Env_get2drRate(); // 頂点カラーを基本色に rdr->setSolidColor(255, 255, 255, 255); // クリック対象を描画 { Tfw* tfw = Game::getGame()->getTfw(); ASSERT(tfw != 0L); View* view = tfw->getView(); ASSERT(view != 0L); SorSgm* sgm = (SorSgm*)tfw->getSgManager(); ASSERT(sgm != 0L); Camera* cam = sgm->getVisibleCamera(); if(cam != 0L) { UnitManager* unitmng = Game::getGame()->getUnitManager(); ASSERT(unitmng != 0L); for(int i = 0; i < unitmng->getUnitNum(); i++) { const Unit* unit = unitmng->getUnitFromIndex(i); ASSERT(unit != 0L); if(!unit->isEnable()) { continue; } // 無効なユニットは除外 if(!unit->isEnableFocus()) { continue; } // フォーカスされないユニットは除外 if(unit->isHidden()) { continue; } // 隠し属性ユニットは除外 if(unit->isHiddenClick()) { continue; } // クリック選択不可 if(unit->getUnitType() == UNITTYPE_EQUIPMENT_ITEM) { continue; } // 所持品は除外 if(unit->getCenterPos()->z() >= cam->getLoc()->z()) { continue; } // カメラより手前は除外 // 既にフォーカスがあるユニットは不要 bool isHadFocus = false; for(s32 j = 0; j < NUM_FOCUS_MAX; j++) { if(_focusarr->getUnit(j) == unit) { isHadFocus = true; break; } } if(isHadFocus) { continue; } // スクリーン座標に変換 Vector2F vScr; Gcalc::conv3dPosToScreenPos(&vScr, unit->getCenterPos(), cam, view); // 画面外チェック if( ((vScr.x() + W_FOCUS_CIRC) < 0) || ((vScr.x() - W_FOCUS_CIRC) >= Game::getGame()->getLogicalWidth()) || ((vScr.y() + H_FOCUS_CIRC) < 0) || ((vScr.y() - H_FOCUS_CIRC) >= Game::getGame()->getLogicalHeight()) ) { continue; } // 描画 ::glPushMatrix(); // 行列を保存 ::glTranslatef(vScr.x(), vScr.y(), 0.0f); drawQuestIcon(rdr, unit, rate2dr); // クエストアイコン表示 ::glRotatef(_dangFocusable, 0.0f, 0.0f, 1.0f); // フォーカス可能アイコン表示 RectF32 vtx(- W_FOCUS_CIRC / 2, - H_FOCUS_CIRC / 2, W_FOCUS_CIRC, H_FOCUS_CIRC); RendererUtils::draw2dTextureRect(rdr, &vtx, Gcalc::calcTexUv(&uv, UV_FOCUSABLE, W_TEX, H_TEX, rate2dr)); ::glPopMatrix(); // 行列を戻す } } } // フォーカスカーソル表示 drawFocusCursor(rdr, _focusarr, 1.0f, rate2dr); // マジッククラスターのフォーカスを表示 MagicSys* mgsys = Game::getGame()->getMagicSys(); for(int i = 0; i < mgsys->getMaxClusterNum(); i++) { MagicCluster* mc = mgsys->getClusterFromIndex(i); if(mc == 0L) { continue; } if(!mc->isValid()) { continue; } if(!TFW_IS_FLAG(mc->getConfFlags(), MagicCluster::CONFF_SHOW_FC)) { continue; } rdr->setSolidColor(63, 0, 255, 255); drawFocusCursor(rdr, mc->getFocusArray(), 0.5f, rate2dr); } // 通常アルファ合成 rdr->setAlphaBlendFunc(Renderer::AFUNC_NORMAL); // フォーカスゲージ表示 for(s32 i = 0; i < NUM_FOCUS_MAX; i++) { const Unit* unitFocused = _focusarr->getUnit(i); if(unitFocused == 0L) { continue; } // フォーカスがある場合のみ以下を処理する const Vector2F* posScr = _focusarr->getScreenPos(i); f32 x = posScr->x() + W_FOCUS_CIRC * 0.5f; f32 y = posScr->y(); // ゲージ表示 if(unitFocused->isCategory(Unit::UNITCAT_CHAR)) { const CharUnit* cunit = (CharUnit*)unitFocused; const CharStat* cstat = cunit->getCharStat(); if(cstat != 0L) { StatusDrawer::drawCharStat(rc, _texRef, cstat, x, y, StatusDrawer::W_GAUGE_DEFAULT, StatusDrawer::H_GAUGE_DEFAULT, false, false); } } else if(unitFocused->getUnitType() == UNITTYPE_EQUIPMENT_ITEM) { const EquipmentItemUnit* iunit = (EquipmentItemUnit*)unitFocused; const Item* item = iunit->getItem(); if(item != 0L) { // 名前表示 const VcString* name = item->getItemDef()->getName(Env_getLangId()); if(name != 0L) { rdr->setSolidColor(255, 255, 255, 255); Font* fontJp = grc->getFontSet()->getFont(GameFontSet::JP); EasyStringDrawer::draw(fontJp, name, x, y, 8, rc); y += 8.0f; } const EleneStat* eestat = item->getEleneStat(); if(eestat != 0L) { StatusDrawer::drawEleneStat(rc, _texRef, eestat, x, y, 60.0f, StatusDrawer::H_ENEGAUGE_DEFAULT, false); } } } else if(unitFocused->getUnitType() == UNITTYPE_PUT_ITEM) { const PutItemUnit* diunit = (PutItemUnit*)unitFocused; const ItemDef* itmdf = diunit->getItemDef(); if(itmdf != 0L) { // 名前表示 const VcString* name = itmdf->getName(Env_getLangId()); if(name != 0L) { rdr->setSolidColor(255, 255, 255, 255); Font* fontJp = grc->getFontSet()->getFont(GameFontSet::JP); EasyStringDrawer::draw(fontJp, name, x, y, 8, rc); y += 8.0f; } } const EleneStat* eestat = diunit->getEleneStat(); if(eestat != 0L) { StatusDrawer::drawEleneStat(rc, _texRef, eestat, x, y, 60.0f, StatusDrawer::H_ENEGAUGE_DEFAULT, false); } } } }