示例#1
0
void Explosion::setObject( Obj& object )
{
    std::vector<glm::vec3> originalVertices;
    std::vector<glm::vec2> originalUVs;
    std::vector<glm::vec3> originalNormals;

    m_zeroPositionVertices.clear();
    m_zeroPositionUVs.clear();
    m_zeroPositionNormals.clear();
    m_triangleRotation.clear();

    object.getInnerData( originalVertices, originalUVs, originalNormals );
    // get mesh data and triangle indices
    std::vector<Mesh*>& meshList = object.getMeshList();
    // Generate a mesh for each triangle
    for( std::vector<Mesh*>::iterator mesh = meshList.begin() ; mesh != meshList.end() ; ++mesh )
    {
        for( int i = 0 ; i < static_cast<int>((*mesh)->m_vertexIndex.size()) ; i=i+3 )
        {
            int a = (*mesh)->m_vertexIndex[i];
            int b = (*mesh)->m_vertexIndex[i+1];
            int c = (*mesh)->m_vertexIndex[i+2];
            // Generate vertex list
            m_zeroPositionVertices.push_back( originalVertices[a] );
            m_zeroPositionVertices.push_back( originalVertices[b] );
            m_zeroPositionVertices.push_back( originalVertices[c] );
            m_zeroPositionUVs.push_back( originalUVs[a] );
            m_zeroPositionUVs.push_back( originalUVs[b] );
            m_zeroPositionUVs.push_back( originalUVs[c] );
            m_zeroPositionNormals.push_back( originalNormals[a] );
            m_zeroPositionNormals.push_back( originalNormals[b] );
            m_zeroPositionNormals.push_back( originalNormals[c] );
            // Generate mesh
            Mesh* m = new Mesh();
            m->m_vertexIndex.push_back(i);
            m->m_vertexIndex.push_back(i+1);
            m->m_vertexIndex.push_back(i+2);
            m_meshList.push_back(m);
            // generate random rotation scheme
            glm::vec3 rot(rand(), rand(), rand());
            m_triangleRotation.push_back(glm::normalize(rot));
        }
    }
    // Store the meshes
    setInnerData( m_zeroPositionVertices, m_zeroPositionUVs, m_zeroPositionNormals );

    m_objectCenterPoint = glm::vec3(0,0,0);
    // find the center point of the object using the middle point of the elements
    for( std::vector<glm::vec3>::iterator it = m_vertices.begin() ; it != m_vertices.end() ; ++it )
    {
        m_objectCenterPoint += (*it);
    }
    int nVertices = static_cast<int>(m_vertices.size());
    m_objectCenterPoint.x /= nVertices;
    m_objectCenterPoint.y /= nVertices;
    m_objectCenterPoint.z /= nVertices;
}
示例#2
0
void HGame::hStep()
{
	for(unsigned int i = 0; i<objectList.size(); i++)
	{
	    Obj* o = objectList.at(i);
		if(didRoomChange){break;}
		o->onStep();
	}
}
示例#3
0
文件: obj.cpp 项目: philippedax/vreng
void Obj::httpReader(void *_obj, Http *http)
{
  Obj *obj = (Obj *) _obj;
  if (! obj) return;

  FILE *f = Cache::openCache(obj->getUrl(), http);
  obj->loadFromFile(f);
  if (! obj->flgpart) obj->displaylist();
  File::closeFile(f);
}
示例#4
0
void IndigoInchi::saveMoleculeIntoInchi (Molecule &mol, Array<char> &inchi)
{
   inchi_Input input;
   QS_DEF(Array<inchi_Atom>, atoms);
   QS_DEF(Array<inchi_Stereo0D>, stereo);

   // Check if structure has aromatic bonds
   bool has_aromatic = false;
   for (int e = mol.edgeBegin(); e != mol.edgeEnd(); e = mol.edgeNext(e))
      if (mol.getBondOrder(e) == BOND_AROMATIC)
      {
         has_aromatic = true;
         break;
      }

   Molecule *target = &mol;
   Obj<Molecule> dearom;
   if (has_aromatic)
   {
      dearom.create();
      dearom->clone(mol, 0, 0);
      try
      {
         dearom->dearomatize();
      }
      catch (DearomatizationsGroups::Error &)
      {
      }
      target = dearom.get();
   }
   generateInchiInput(*target, input, atoms, stereo);

   inchi_Output output;
   
   int ret = GetINCHI(&input, &output);

   if (output.szMessage)
      warning.readString(output.szMessage, true);
   if (output.szLog)
      log.readString(output.szLog, true);
   if (output.szAuxInfo)
      auxInfo.readString(output.szAuxInfo, true);

   if (ret != inchi_Ret_OKAY && ret != inchi_Ret_WARNING)
   {
      // Construct error before dispoing inchi output to preserve error message
      IndigoError error("Indigo-InChI: InChI generation failed: %s. Code: %d.", output.szMessage, ret);
      FreeINCHI(&output);
      throw error;
   }

   inchi.readString(output.szInChI, true);

   FreeINCHI(&output);
}
示例#5
0
PetscErrorCode OutputVTK(const Obj<ALE::Mesh>& mesh, Options *options)
{
    PetscViewer    viewer;
    PetscErrorCode ierr;

    PetscFunctionBegin;
    if (options->outputVTK) {
        ALE::LogStage stage = ALE::LogStageRegister("VTKOutput");
        ALE::LogStagePush(stage);
        ierr = PetscPrintf(mesh->comm(), "Creating VTK mesh files\n");
        CHKERRQ(ierr);
        ierr = PetscViewerCreate(mesh->comm(), &viewer);
        CHKERRQ(ierr);
        ierr = PetscViewerSetType(viewer, PETSC_VIEWER_ASCII);
        CHKERRQ(ierr);
        ierr = PetscViewerSetFormat(viewer, PETSC_VIEWER_ASCII_VTK);
        CHKERRQ(ierr);
        ierr = PetscViewerFileSetName(viewer, "testMesh.vtk");
        CHKERRQ(ierr);
        ierr = VTKViewer::writeHeader(viewer);
        CHKERRQ(ierr);
        ierr = VTKViewer::writeHierarchyVertices(mesh, viewer, options->zScale);
        CHKERRQ(ierr);
        ierr = VTKViewer::writeHierarchyElements(mesh, viewer);
        CHKERRQ(ierr);
        ierr = PetscViewerDestroy(viewer);
        CHKERRQ(ierr);
        const ALE::Mesh::topology_type::sheaf_type& patches = mesh->getTopology()->getPatches();
#if 0
        for(ALE::Mesh::topology_type::sheaf_type::iterator p_iter = patches.begin(); p_iter != patches.end(); ++p_iter) {
            ostringstream filename;

            filename << "coarseMesh." << *p_iter << ".vtk";
            ierr = PetscViewerCreate(mesh->comm(), &viewer);
            CHKERRQ(ierr);
            ierr = PetscViewerSetType(viewer, PETSC_VIEWER_ASCII);
            CHKERRQ(ierr);
            ierr = PetscViewerSetFormat(viewer, PETSC_VIEWER_ASCII_VTK);
            CHKERRQ(ierr);
            ierr = PetscViewerFileSetName(viewer, filename.str().c_str());
            CHKERRQ(ierr);
            ierr = VTKViewer::writeHeader(viewer);
            CHKERRQ(ierr);
            ierr = VTKViewer::writeVertices(mesh, *p_iter, viewer);
            CHKERRQ(ierr);
            ierr = VTKViewer::writeElements(mesh, *p_iter, viewer);
            CHKERRQ(ierr);
            //ierr = FieldView_Sieve(mesh, "spacing", viewer);CHKERRQ(ierr);
            ierr = PetscViewerDestroy(viewer);
            CHKERRQ(ierr);
        }
#endif
    }
    PetscFunctionReturn(0);
}
示例#6
0
VOID AI_Monster::AI_Logic_Approach( UINT uTime )
{
__ENTER_FUNCTION
	/** 先进行Approach类型的判断 */
	GET_MONSTER_SCENE((VOID)0)

	Obj* pObj = pScene->GetObjManager()->GetObj(m_CurEnemyID);
	if (!pObj 
		|| !IsCharacterObj(pObj->GetObjType()) 
		|| !((Obj_Character*)pObj)->IsAlive() 
		|| !((Obj_Character*)pObj)->IsCanViewMe(pMonster) 
		)
	{/** 当前敌人无效后转向下一个敌人,直到全部找完为止 */
		DelEnemy(m_CurEnemyID);
		m_CurEnemyID = GetNextEnemy();
		if (INVALID_ID == m_CurEnemyID) {
			ToGoHome();
		}
		return ;
	}
	Obj_Character* pCurEnemy = (Obj_Character*)pObj;

	
	FLOAT fMTDist,fETDist;
	if (!pCurEnemy)
	{
		Assert(NULL && "AI_Monster::Logic_Approach...pCurEnemy=NULL...");
		ToGoHome();
		return  ;
	}
	FLOAT fDist = MySqrt(pMonster->getWorldPos(), pCurEnemy->getWorldPos());
	if ( IsToGoHome(fMTDist, fETDist) ) 
	{
		return ;
	}

	if (ZERO_VALUE > fMTDist) 
	{/** 如果到达目的地 */
		ToAttack();
	}
	else
	{
		if( fETDist > (FLOAT)AIParam(AIPARAM_RESETTARGET_DIST)/1000.0f)
		{/** 如果目标位置和敌人位置的距离大与一定值则需要重新制定移动目标 */
			ToApproachTar( ) ;
		}
		else if(!GetCharacter()->IsMoving())
		{
			ToApproachTar( );
		}
	}
	ExcuteAIScript(SAPPROACH);

__LEAVE_FUNCTION
}
示例#7
0
		BOOL ImpactCore_T::SendImpactToUnit(Obj_Character& rTar, ID_t nDataIndex, ObjID_t nSender, Time_t nDelayTime, BOOL bCriticalFlag, INT nRefixRate, INT nReserveParam1, INT nReserveParam2) const
		{
			__ENTER_FUNCTION
			OWN_IMPACT impact;
			if(INVALID_ID == nDataIndex)
			{
				return FALSE;
			}
			//根据nDataIndex对应的效果逻辑初始化rImp
			if(TRUE == InitImpactFromData(nDataIndex, impact, rTar, nReserveParam1))
			{
				//获得逻辑对象
				ImpactLogic_T const* pLogic = Impact_GetLogic(impact);
				if(NULL==pLogic)
				{
					Assert(NULL=="[ImpactCore_T::SendImpactToUnit]: Can't find sprcific logic for this impact.");
					return FALSE;
				}
				//设置会心标记
				if(TRUE == bCriticalFlag)
				{
					impact.MarkCriticalFlag();
				}
				if(0!=nRefixRate)
				{
					//向效果逻辑设置修正率
					pLogic->RefixPowerByRate(impact, nRefixRate);
				}
				if(0>nDelayTime)
				{
					nDelayTime = 0;
				}
				Scene* pScene = rTar.getScene();
				Obj_Character* pChar = NULL;
				if(NULL!=pScene)
				{
					Obj* pObj = pScene->GetSpecificObjByID( nSender );
					
					if( IsCharacterObj(pObj->GetObjType()) )
					{
						pChar = static_cast<Obj_Character*>(pObj);
						SkillInfo_T& rSkillInfo = pChar->GetSkillInfo();
						impact.SetSkillID( rSkillInfo.GetSkillID() );
						rSkillInfo.SetSendSkillImpactID(impact.GetDataIndex());
					}
					pScene->GetEventCore().RegisterImpactEvent(rTar.GetID(), nSender, impact, nDelayTime);
					return TRUE;
				}
			}
			// start to fill impact struct
			return TRUE;
			__LEAVE_FUNCTION
			return FALSE;
		}
uint CGLockTargetHandler::Execute( CGLockTarget* pPacket, Player* pPlayer )
{
	__ENTER_FUNCTION

	GamePlayer* pGamePlayer = (GamePlayer*)pPlayer ;
	Assert( pGamePlayer ) ;

	Obj_Human* pHuman = pGamePlayer->GetHuman() ;

	if(NULL==pHuman)
	{
		AssertEx(FALSE,"[CGLockTargetHandler::Execute]: NULL Obj_Human pointer found!!");
		return PACKET_EXE_ERROR ;
	}
	Scene* pScene = pHuman->getScene() ;
	if( pScene==NULL )
	{
		Assert(FALSE) ;
		return PACKET_EXE_ERROR ;
	}

	//检查线程执行资源是否正确
	Assert( MyGetCurrentThreadID()==pScene->m_ThreadID ) ;

	ObjID_t nMeID = pHuman->GetID();
	if( nMeID == INVALID_ID )
	{
		Assert(FALSE) ;
		return PACKET_EXE_ERROR ;
	}
	//update target
	if(NULL==pPacket)
	{
		AssertEx(FALSE,"[CGLockTargetHandler::Execute]: NULL packet pointer found!!");
		return PACKET_EXE_ERROR ;
	}

	pHuman->SetLockedTarget(pPacket->getTargetID());
	// 当锁定的目标是NPC时将会触发NPC的泡泡说话
	Obj* pTarget = pScene->GetObjManager()->GetObj(pPacket->getTargetID());
	if (pTarget->GetObjType() == Obj::OBJ_TYPE_MONSTER)
	{
		((Obj_Monster*)pTarget)->ProcessPaoPao();
	}
	
	g_pLog->FastSaveLog( LOG_FILE_1, "CGLockTargetHandler: ok obj=%d scene=%d", 
		nMeID, pScene->SceneID() ) ;

	return PACKET_EXE_CONTINUE ;

	__LEAVE_FUNCTION

	return PACKET_EXE_ERROR ;
}
示例#9
0
Obj* Obj::create()
{
	Obj*	pObj	= new Obj();

	if (false == pObj->initialize())
	{
		delete	pObj;

		pObj	= NULL;
	}

	return	pObj;
}
int IntQueue::getInt()
{
    // Waiting for resources.
    d_resourceSem.wait();

    // 'd_mutexSem' is used for exclusive access.
    d_mutexSem.wait();
    int ret = d_queue.back();
    d_queue.pop_back();
    d_mutexSem.post();

    return ret;
}
示例#11
0
void ConcurrencyTest::execute()
{
    bslma::Allocator *Z = d_allocator_p;
    Obj *mX = d_description_p; const Obj *MX = mX;

    Format A(Z), B(Z), C(Z), D(Z), E(Z), F(Z);
    const Format *FORMATS[] = { &A, &B, &C, &D, &E, &F };
    const int NUM_FORMATS   = sizeof FORMATS / sizeof *FORMATS;

    Type::Value TYPES[] = { Type::e_TOTAL,
                            Type::e_COUNT,
                            Type::e_MIN,
                            Type::e_MAX,
                            Type::e_AVG,
                            Type::e_RATE,
                            Type::e_UNSPECIFIED
    };
    const int NUM_TYPES = sizeof TYPES / sizeof *TYPES;

    F.setFormatSpec(Type::e_MIN, balm::MetricFormatSpec(2, "%f"));

    ASSERT(!MX->format());

    for (int iteration = 0; iteration < 20; ++iteration) {
        d_barrier.wait();

        for (int j = 0; j < NUM_TYPES; ++j) {
            mX->setPreferredPublicationType(TYPES[j]);
            int x = (int)MX->preferredPublicationType();
            ASSERT(0 <= x && x < Type::k_LENGTH);
        }

        for (int i = 0; i < NUM_FORMATS; ++i) {
            bsl::shared_ptr<const Format> fmt(FORMATS[i],
                                              bslstl::SharedPtrNilDeleter(),
                                              Z);
            mX->setFormat(fmt);
            ASSERT(MX->format());
        }

        d_barrier.wait();

        // Note that '&F' may not equal 'MX->format()'.
        ASSERT(F == *MX->format());

        // Prevent the shared pointers from other threads being destroyed
        // before the preceding comparison.
        d_barrier.wait();
    }

}
示例#12
0
uint CGCharAskBaseAttribHandler::Execute( CGCharAskBaseAttrib* pPacket, Player* pPlayer )
{
__ENTER_FUNCTION

	GamePlayer* pGamePlayer = (GamePlayer*)pPlayer ;
	Assert( pGamePlayer ) ;

	Obj_Human* pHuman = pGamePlayer->GetHuman() ;
	Assert( pHuman ) ;
	
	Scene* pScene = pHuman->getScene() ;
	if( pScene==NULL )
	{
		Assert(FALSE) ;
		return PACKET_EXE_ERROR ;
	}

	//检查线程执行资源是否正确
	Assert( MyGetCurrentThreadID()==pScene->m_ThreadID ) ;

	ObjID_t ObjID = pPacket->getTargetID() ;
	if( ObjID == INVALID_ID )
	{
		return PACKET_EXE_ERROR ;
	}
	
	Obj* pObj = pScene->GetObjManager()->GetObj( ObjID ) ;
	if( pObj==NULL )
	{
		g_pLog->FastSaveLog( LOG_FILE_1, "CGCharAskBaseAttribHandler: not find obj=%d", ObjID ) ;
		return PACKET_EXE_CONTINUE ;
	}

	if( !IsCharacterObj( pObj->GetObjType() ) )
	{
		g_pLog->FastSaveLog( LOG_FILE_1, "CGCharAskBaseAttribHandler: not character obj=%d", ObjID ) ;
		return PACKET_EXE_CONTINUE ;
	}

	Obj_Character* pCharacter = (Obj_Character*)pObj ;
	pCharacter->AskMsg_BaseAttrib( pHuman );

	//影响效率关掉Log
	//g_pLog->FastSaveLog( LOG_FILE_1, "CGCharAskBaseAttribHandler: obj=%d", ObjID ) ;

	return PACKET_EXE_CONTINUE ;

__LEAVE_FUNCTION

	return PACKET_EXE_ERROR ;
}
示例#13
0
void ut_obj(){
  Obj obj;
  rapidjson::StringBuffer sb;
  rapidjson::Writer<rapidjson::StringBuffer> writer(sb);
  obj.Serialize(writer);
  cout << "Writer:\n"<< sb.GetString() << endl;
  cout << endl;

  sb.Clear();
  rapidjson::PrettyWriter<rapidjson::StringBuffer> prettyWriter(sb);
  obj.Serialize(prettyWriter);
  cout << "PrettyWriter:\n"<< sb.GetString() << endl;
  cout << endl;
}
示例#14
0
 bool VisitTypedefDecl(TypedefDecl * TD) {
     if(TD == TD->getCanonicalDecl() && TD->getDeclContext()->getDeclKind() == Decl::TranslationUnit) {
         llvm::StringRef name = TD->getName();
         QualType QT = Context->getCanonicalType(TD->getUnderlyingType());
         Obj typ;
         if(GetType(QT,&typ)) {
             typ.push();
             general.setfield(name.str().c_str());
         } else {
             SetErrorReport(name.str().c_str());
         }
     }
     return true;
 }
示例#15
0
int main(int argc, char *argv[])
{
  MPI_Comm       comm;
  Options        options;
  PetscErrorCode ierr;

  PetscFunctionBegin;
  ierr = PetscInitialize(&argc, &argv, (char *) 0, NULL);CHKERRQ(ierr);
  comm = PETSC_COMM_WORLD;

  try {
    ierr = ProcessOptions(comm, &options);CHKERRQ(ierr);
    Obj<ALE::Mesh> mesh;
    Mesh mesh_set[options.levels];
    for (int i = 0; i < options.levels; i++) {
      ierr = MeshCreate(comm, &mesh_set[i]);CHKERRQ(ierr);
    };
    ierr = CreateMesh(comm, mesh, &options);CHKERRQ(ierr);
    
    MeshSetMesh(mesh_set[0], mesh);
    ierr = MeshIDBoundary(mesh_set[0]);
    mesh->markBoundaryCells("marker");
    ierr = PetscPrintf(mesh->comm(), "%d boundary vertices, %d boundary cells\n", mesh->getLabelStratum("marker", 1)->size(), mesh->getLabelStratum("marker", 2)->size());
    ierr = MeshSpacingFunction(mesh_set[0]);
    //ierr = MeshIDBoundary(mesh_set[0]);
//    mesh->createLabel("marker");
//    mesh->markBoundaryCells("marker", 1, 2, false);
    MeshCreateHierarchyLabel_Link(mesh_set[0], options.coarseFactor, options.levels, &mesh_set[1],NULL,options.curvatureCutoff );
    Obj<ALE::Mesh> ale_meshes[options.levels];
    for (int i = 0; i < options.levels; i++) {
      MeshGetMesh(mesh_set[i], ale_meshes[i]);
    }
    Hierarchy_qualityInfo(ale_meshes, options.levels);
    //ierr = MeshCoarsenMesh(m, pow(options.coarseFactor, 2), &n);
    //ierr = MeshGetMesh(n, mesh);
    //ierr = MeshLocateInMesh(m, n);
   // Obj<ALE::Mesh::sieve_type> sieve = new ALE::Mesh::sieve_type(mesh->comm(), 0);
   // mesh->getTopology()->setPatch(options.levels, sieve);
   // mesh->getTopology()->stratify();
    char vtkfilename[128];
    for (int i = 0; i < options.levels; i++) {
      sprintf(vtkfilename, "testMesh%d.vtk", i);
      ierr = OutputVTK(ale_meshes[i], &options, vtkfilename);CHKERRQ(ierr);
    }
  } catch (ALE::Exception e) {
    std::cout << e << std::endl;
  }
  ierr = PetscFinalize();CHKERRQ(ierr);
  PetscFunctionReturn(0);
}
 void
 check_remove ()
   {
     reg_->forget (o2);
     
     Iter13 i (reg_->candidates(q4));
     CHECK ( i.hasNext());
     CHECK ( *i == o1); ++i;    // ordered according to the degree of the queries
                                // but the o2 entries are missing
     CHECK ( *i == o3); ++i;
                                // o2 missing
                                // o2 missing
     CHECK ( *i == o1);
     CHECK (!i.hasNext());
     
     o3.reset(); // killing the only reference....
                //  expires the weak ref in the registry
     
     i = reg_->candidates(Q13 ("something"));
     CHECK ( i.hasNext());
     CHECK ( *i == o1); ++i;    // ordered according to the degree of the queries
                                // but now also the o3 entry is missing...
     CHECK ( *i == o1);
     CHECK (!i.hasNext());
     
     CHECK ( reg_->put (o1, q5));   // trying to register the same object at the same place
                                    // doesn't change anything (but counts as "success")
     i = reg_->candidates(q5);
     CHECK ( *i == o1); ++i; // direct match
     CHECK ( *i == o1); ++i;
     CHECK ( *i == o1); ++i;
     CHECK (!i.hasNext());
     
     CHECK (!reg_->put (o2, q5));   // trying to (re)register o2 with a existing query
                                    // counts as failure (nothing changes)
     i = reg_->candidates(q5);
     CHECK ( *i == o1); ++i; // direct match
     CHECK ( *i == o1); ++i;
     CHECK ( *i == o1); ++i;
     CHECK (!i.hasNext());
     
     CHECK ( reg_->put (o2, q2));   // trying to (re)register o2 with another query succeeds
     i = reg_->candidates(q2);
     CHECK ( *i == o2); ++i; // direct match
     CHECK ( *i == o1); ++i;
     CHECK ( *i == o2); ++i; // inserted here in the dataset, since q2 has degree 2
     CHECK ( *i == o1); ++i;
     CHECK (!i.hasNext());
     
     CHECK ( reg_->forget (o1));
     CHECK (!reg_->forget (o1)); // failure, because it's already removed
     CHECK ( reg_->forget (o2));
     
     o3 = fabricate<13>();    // another object is another object (it's irrelevant...)
     
     i = reg_->candidates(q2);
     CHECK (! (*i));  // empty
   }
示例#17
0
 bool GetFuncType(const FunctionType * f, Obj * typ) {
     Obj returns,parameters;
     resulttable->newlist(&returns);
     resulttable->newlist(&parameters);
     
     bool valid = true; //decisions about whether this function can be exported or not are delayed until we have seen all the potential problems
     QualType RT = f->getResultType();
     if(!RT->isVoidType()) {
         Obj rt;
         if(!GetType(RT,&rt)) {
             valid = false;
         } else {
             rt.push();
             returns.addentry();
         }
     }
    
     
     const FunctionProtoType * proto = f->getAs<FunctionProtoType>();
     //proto is null if the function was declared without an argument list (e.g. void foo() and not void foo(void))
     //we don't support old-style C parameter lists, we just treat them as empty
     if(proto) {
         for(size_t i = 0; i < proto->getNumArgs(); i++) {
             QualType PT = proto->getArgType(i);
             Obj pt;
             if(!GetType(PT,&pt)) {
                 valid = false; //keep going with attempting to parse type to make sure we see all the reasons why we cannot support this function
             } else if(valid) {
                 pt.push();
                 parameters.addentry();
             }
         }
     }
     
     if(valid) {
         PushTypeFunction("functype");
         parameters.push();
         returns.push();
         lua_pushboolean(L, proto ? proto->isVariadic() : false);
         lua_call(L, 3, 1);
         typ->initFromStack(L,ref_table);
     }
     
     return valid;
 }
示例#18
0
文件: meshcreate.c 项目: Kun-Qu/petsc
PetscErrorCode DMMeshCreateMeshFromAdjacencyHybrid(MPI_Comm comm, PetscInt dim, PetscInt numCells, PetscInt numCorners[], PetscInt cellVertices[], PetscInt spatialDim, PetscInt numVertices, const PetscReal coordinates[], PetscBool interpolate, DM *dm) {
  PetscInt       debug = 0;
  PetscErrorCode ierr;

  PetscFunctionBegin;
  PetscValidPointer(numCorners, 4);
  PetscValidPointer(cellVertices, 5);
  /* PetscValidLogicalCollectiveBool(comm,interpolate,6); */
  PetscValidPointer(dm, 7);
  if (interpolate) {SETERRQ(comm, PETSC_ERR_SUP, "Interpolation (creation of faces and edges) is not yet supported.");}
  ierr = PetscOptionsGetInt(PETSC_NULL, "-dmmesh_debug", &debug, PETSC_NULL);CHKERRQ(ierr);
  Obj<PETSC_MESH_TYPE>             mesh  = new PETSC_MESH_TYPE(comm, dim, debug);
  Obj<PETSC_MESH_TYPE::sieve_type> sieve = new PETSC_MESH_TYPE::sieve_type(comm, 0, numCells+numVertices, debug);

  mesh->setSieve(sieve);
  for(PetscInt c = 0; c < numCells; ++c) {
    sieve->setConeSize(c, numCorners[c]);
  }
  //sieve->symmetrizeSizes(numCells, numCorners, cellVertices);
  sieve->allocate();
  for(PetscInt c = 0, offset = 0; c < numCells; offset += numCorners[c], ++c) {
    sieve->setCone(&cellVertices[offset], c);
  }
  sieve->symmetrize();
  PetscFunctionReturn(0);
}
示例#19
0
void HGame::hEvent()
{
	sf::Event event;
	while(HScreen::getScreen()->pollEvent(event))
	{
		if(event.type == sf::Event::Closed)
		{
			isRunning = false;
			break;
		}
		if(didRoomChange){break;}
		for(unsigned int i = 0; i < objectList.size(); i++)
		{
		    Obj* o = objectList.at(i);
			o->onEvent(event);
		}
	}
}
		boost::optional<T> object_cast_nothrow_impl(const Obj& obj, const Policies&)
		{
			typedef typename detail::find_conversion_policy<0, Policies>::type converter_policy;
			typename converter_policy::template generate_converter<T, lua_to_cpp>::type converter;

			obj.pushvalue();

			lua_State* L = obj.lua_state();
			detail::stack_pop p(L, 1);

#ifndef LUABIND_NO_ERROR_CHECKING

			if (converter.match(L, LUABIND_DECORATE_TYPE(T), -1) < 0)
				return boost::optional<T>();
#endif

			return boost::optional<T>(converter.apply(L, LUABIND_DECORATE_TYPE(T), -1));
		}
示例#21
0
文件: Reader.hpp 项目: questor/git-ws
					inline Val parseObj()
					{
						Obj obj;

						// Skip '{'
						++idx;

						// Empty object
						if(isC('}')) goto end;

						// Reserve some memory
						obj.reserve(10);

						while(true)
						{
							// Read string key
							if(!isC('"')) throwError("Invalid object", std::string{"Expected `\"` , got `"} + getC() + "`");
							auto key(readStr());

							// Read ':'
							if(!isC(':')) throwError("Invalid object", std::string{"Expected `:` , got `"} + getC() + "`");

							// Skip ':'
							++idx;

							// Read value
							obj[std::move(key)] = parseVal();

							// Check for another key-value pair
							if(isC(',')) { ++idx; continue; }

							// Check for end of the object
							if(isC('}')) break;

							throwError("Invalid object", std::string{"Expected either `,` or `}`, got `"} + getC() + "`");
						}

						end:

						// Skip '}'
						++idx;

						return Val{obj};
					}
示例#22
0
		VOID StdImpact059_T::BroadcastTargetListMessage( OWN_IMPACT& rImp, Obj_Character& rMe, OBJLIST& rTargets, HitFlagsForOBJLIST_T& rHitFlagsForObjList ) const
		{
			__ENTER_FUNCTION
			SkillInfo_T& rSkillInfo = rMe.GetSkillInfo();
			TargetingAndDepletingParams_T& rParams = rMe.GetTargetingAndDepletingParams();
			GCTargetListAndHitFlags msg;
			GCTargetListAndHitFlags::HitFlagList_T& rHitFlags		= msg.GetHitFlagList();
			msg.SetDataType(msg.BUFF_ACTIVETE);
			msg.SetObjID(rMe.GetID());
			msg.SetUserPos(*(rMe.getWorldPos()));
			msg.SetLogicCount(rMe.GetLogicCount());
			msg.SetSkillOrSpecialObjDataID(rImp.GetSkillID());
			msg.SetTargetID(rParams.GetTargetObj());
			msg.SetTargetPos(rParams.GetTargetPosition());
			msg.SetDir(rParams.GetTargetDirection());
			BYTE nNum = rTargets.m_Count;
			if(msg.MAX_TARGET_LIST_SIZE<nNum)
			{
				nNum = msg.MAX_TARGET_LIST_SIZE;
			}
			msg.SetTargetNum(nNum);
			int iTemp = nNum;

			INT nIdx=0;
			for(nIdx=0; nNum>nIdx; ++nIdx)
			{
				Obj* pTarget = rTargets.m_aObj[nIdx];
				if(NULL!=pTarget)
				{
					msg.SetTargetObjIDByIndex(nIdx, pTarget->GetID());
					if(TRUE == rHitFlagsForObjList.GetFlagByIndex(nIdx))
					{
						rHitFlags.MarkFlagByIndex(nIdx);
						//msg.SetBallIDByIndex( nIdx, m_aBallUniqueID[nIdx].m_uUniqueID );
					}
				}
			}
			Scene* pScene = rMe.getScene();
			if(NULL!=pScene)
			{
				pScene->BroadCast(&msg, &rMe, TRUE);
			}
			__LEAVE_FUNCTION
		}
示例#23
0
		inline T object_cast_impl(const Obj& obj, const Policies&)
		{
			if (obj.lua_state() == 0) 
			{
#ifndef LUABIND_NO_EXCEPTIONS
				throw cast_failed(0, typeid(T));
#else
				lua_State* L = obj.lua_state();
				cast_failed_callback_fun e = get_cast_failed_callback();
				if (e) e(L, typeid(T));

				assert(0 && "object_cast failed. If you want to handle this error use luabind::set_error_callback()");
				std::terminate();
#endif
			}

			LUABIND_CHECK_STACK(obj.lua_state());

			typedef typename detail::find_conversion_policy<0, Policies>::type converter_policy;
			typename mpl::apply_wrap2<converter_policy,T,lua_to_cpp>::type converter;

			obj.pushvalue();

			lua_State* L = obj.lua_state();
			detail::stack_pop p(L, 1);

#ifndef LUABIND_NO_ERROR_CHECKING

			if (converter.match(L, LUABIND_DECORATE_TYPE(T), -1) < 0)
			{
#ifndef LUABIND_NO_EXCEPTIONS
				throw cast_failed(L, typeid(T));
#else
				cast_failed_callback_fun e = get_cast_failed_callback();
				if (e) e(L, typeid(T));

				assert(0 && "object_cast failed. If you want to handle this error use luabind::set_error_callback()");
				std::terminate();
#endif
			}
#endif

			return converter.apply(L, LUABIND_DECORATE_TYPE(T), -1);
		}
示例#24
0
void ConcurrencyTest::execute()
{

    Obj *mX = d_collector_p; const Obj *MX = mX;

    balm::MetricRecord empty(MX->metricId());
    balm::MetricRecord r1(MX->metricId(), 1, 2, 3, 5);
    balm::MetricRecord r2(MX->metricId(), 7, 8, 9, 10);

    // Test simultaneous set and loads, verify values are set/loaded
    // atomically.
    d_barrier.wait();
    for(int i = 0; i < 10; ++i) {
        balm::MetricRecord  result;
        balm::MetricRecord *rec = (0 == i % 2) ? &r1 : &r2;
        mX->setCountTotalMinMax(rec->count(),
                                rec->total(),
                                rec->min(),
                                rec->max());
        MX->load(&result);
        ASSERT(r1 == result || r2 == result);

    }
    d_barrier.wait();

    mX->reset();

    // Test simultaneous accumulate and loads, verify values are
    // accumulated/loaded atomically.
    d_barrier.wait();
    for(int i = 0; i < 10; ++i) {
        balm::MetricRecord  result;
        mX->accumulateCountTotalMinMax(1, 1, -i, i);
        MX->load(&result);

        ASSERT(result.count() >= i);
        ASSERT(result.total() >= i);
        ASSERT(result.count() == result.total());
        ASSERT(result.min() <= -i);
        ASSERT(result.max() >= i);
        ASSERT(result.min() == -result.max());
    }
    d_barrier.wait();

    mX->reset();

    // Test simultaneous set and loadAndReset, verify values are loaded and
    // reset atomically.
    d_barrier.wait();
    for(int i = 0; i < 10; ++i) {
        balm::MetricRecord  result;
        mX->setCountTotalMinMax(r1.count(), r1.total(), r1.min(), r1.max());
        mX->loadAndReset(&result);

        ASSERT(result == r1 || result == empty);
    }
    d_barrier.wait();
}
示例#25
0
		VOID StdImpact033_T::OnFadeOut(OWN_IMPACT& rImp, Obj_Character& rMe) const
		{
			INT nValue = 0;
			if(Obj::OBJ_TYPE_MONSTER == rMe.GetObjType())
			{
				Obj_Monster& rMonster = (Obj_Monster&)rMe;
				INT nAI_Type = GetAiTypeRefix(rImp);
				rMonster.SetAIType(nAI_Type);
				AI_Monster * pAI = rMonster.GetMonsterAI();
				if(NULL!=pAI)
				{
					Obj* pObj = Impact_GetCaster(rMe, rImp);
					if(NULL!=pObj)
					{					
						pAI->AddPrimaryEnemy(pObj->GetID());
					}
				}
			}
		}
示例#26
0
PetscErrorCode CreateMesh(MPI_Comm comm, Obj<ALE::Mesh>& mesh, Options *options)
{
  PetscErrorCode ierr;
  PetscFunctionBegin;
  ALE::LogStage stage = ALE::LogStageRegister("MeshCreation");
  ALE::LogStagePush(stage);
  ierr = PetscPrintf(comm, "Creating mesh\n");CHKERRQ(ierr);
  mesh = ALE::PCICE::Builder::readMesh(comm, 2, options->baseFilename, options->useZeroBase, true, options->debug);
  ALE::Coarsener::IdentifyBoundary(mesh, 2);
  ALE::Coarsener::make_coarsest_boundary(mesh, 2, options->levels + 1);
  ALE::LogStagePop(stage);
  Obj<ALE::Mesh::topology_type> topology = mesh->getTopology();
  ierr = PetscPrintf(comm, "  Read %d elements\n", topology->heightStratum(0, 0)->size());CHKERRQ(ierr);
  ierr = PetscPrintf(comm, "  Read %d vertices\n", topology->depthStratum(0, 0)->size());CHKERRQ(ierr);
  if (options->debug) {
    topology->view("Serial topology");
  }
  PetscFunctionReturn(0);
}
int main()
{
    Obj o;
    if (o.value() != "mutable")
        return 1;

    const Obj &co = o;
    if (co.value() != "const")
        return 1;

    Obj && mo = std::move(o);
    if (o.value() != "mutable") // mo is an lvalue, hence can only be resolved to & or const &
        return 1;

    Obj && mo = std::move(o);
    if (std::move(o).value() != "movable")
        return 1;

    return 0;
}
示例#28
0
BOOL PetManager::RemovePet( ObjID_t idObj )
{
__ENTER_FUNCTION

	Scene* pScene = GetScene();
	if (pScene)
	{
		Obj* pPet = pScene->GetPetManager()->GetPet(idObj);
		if (pPet && pPet->GetObjType() == Obj::OBJ_TYPE_PET)
		{
			pPet->SetActiveFlag( FALSE );
			pPet->CleanUp();
			pScene->DeleteObject( pPet );
		}
	}

	return TRUE;
__LEAVE_FUNCTION
	return TRUE;
}
示例#29
0
int main(){


//	input.push_back(0);
	obj.method();

//	std::cout << "vector[0]:" << input[0] << std::endl;
	

	return 0;
}
示例#30
0
文件: meshcreate.c 项目: Kun-Qu/petsc
/*@
  DMMeshCreateMeshFromAdjacency - Create an unstrctured mesh from a list of the vertices for each cell, and the coordinates for each vertex.

 Collective on comm

  Input Parameters:
+ comm - An MPI communicator
. dim - The dimension of the cells, e.g. triangles have dimension 2
. numCells - The number of cells in the mesh
. numCorners - The number of vertices in each cell
. cellVertices - An array of the vertices for each cell, numbered 0 to numVertices-1
. spatialDim - The dimension for coordinates, e.g. for a triangle in 3D this would be 3
. numVertices - The number of mesh vertices
. coordinates - An array of the coordinates for each vertex
- interpolate - Flag to create faces and edges

  Output Parameter:
. dm - The DMMesh object

  Level: beginner

.seealso DMMESH, DMMeshCreateMeshFromAdjacencyHybrid(), DMMeshCreateBoxMesh()
@*/
PetscErrorCode DMMeshCreateMeshFromAdjacency(MPI_Comm comm, PetscInt dim, PetscInt numCells, PetscInt numCorners, PetscInt cellVertices[], PetscInt spatialDim, PetscInt numVertices, const PetscReal coordinates[], PetscBool interpolate, DM *dm) {
  PetscInt      *cone;
  PetscInt      *coneO;
  PetscInt       debug = 0;
  PetscErrorCode ierr;

  PetscFunctionBegin;
  PetscValidPointer(cellVertices, 5);
  /* PetscValidLogicalCollectiveBool(comm,interpolate,6); */
  PetscValidPointer(dm, 7);
  if (interpolate) {SETERRQ(comm, PETSC_ERR_SUP, "Interpolation (creation of faces and edges) is not yet supported.");}
  ierr = PetscOptionsGetInt(PETSC_NULL, "-dm_mesh_debug", &debug, PETSC_NULL);CHKERRQ(ierr);
  Obj<PETSC_MESH_TYPE>             mesh  = new PETSC_MESH_TYPE(comm, dim, debug);
  Obj<PETSC_MESH_TYPE::sieve_type> sieve = new PETSC_MESH_TYPE::sieve_type(comm, 0, numCells+numVertices, debug);

  mesh->setSieve(sieve);
  for(PetscInt c = 0; c < numCells; ++c) {
    sieve->setConeSize(c, numCorners);
  }
  sieve->symmetrizeSizes(numCells, numCorners, cellVertices, numCells);
  sieve->allocate();
  ierr = PetscMalloc2(numCorners,PetscInt,&cone,numCorners,PetscInt,&coneO);CHKERRQ(ierr);
  for(PetscInt v = 0; v < numCorners; ++v) {
    coneO[v] = 1;
  }
  for(PetscInt c = 0; c < numCells; ++c) {
    for(PetscInt v = 0; v < numCorners; ++v) {
      cone[v] = cellVertices[c*numCorners+v]+numCells;
    }
    sieve->setCone(cone, c);
    sieve->setConeOrientation(coneO, c);
  }
  ierr = PetscFree2(cone,coneO);CHKERRQ(ierr);
  sieve->symmetrize();
  mesh->stratify();
  ALE::SieveBuilder<PETSC_MESH_TYPE>::buildCoordinates(mesh, spatialDim, coordinates, numCells);
  ierr = DMCreate(comm, dm);CHKERRQ(ierr);
  ierr = DMSetType(*dm, DMMESH);CHKERRQ(ierr);
  ierr = DMMeshSetMesh(*dm, mesh);CHKERRQ(ierr);
  PetscFunctionReturn(0);
}