示例#1
0
void CullSystem::Cull( Frustum& frus, TreeNode<VisCell>& node, std::vector<std::list<Ptr<Renderable>>>& outRenderables)
{
	InterSectResult result = frus.InterSect(node.GetContent().GetAABB());
	if ( !result==INTERSECTOUT )
	{
		std::list<Ptr<Renderable>>::iterator iter = node.GetContent().GetRenderables().begin();
		if (result== INTERSECTIN)
		{
			for (;iter!=node.GetContent().GetRenderables().end();iter++)
			{
				RenderType rType = (*iter)->GetRenderType();
				outRenderables[rType].push_back((*iter));
			}
		}
		else
		{
			for (;iter!=node.GetContent().GetRenderables().end();iter++)
			{
				if ( frus.InterSect((*iter)->GetSubMesh()->GetVertexBuffer()->GetBBox())!= INTERSECTOUT)
				{
					RenderType rType = (*iter)->GetRenderType();
					outRenderables[rType].push_back((*iter));
				}
			}
		}
		for (int i = 0 ;i<(int)node.GetChildren().size();i++)
		{
			Cull( frus,*node.GetChildren()[i],outRenderables );
		}
		
	}
	
}
示例#2
0
		void CRenderLayer::DoRender(SDL_Renderer* pRen)
		{
			util::math::Type2<int> logical_size;
			SDL_GetRendererOutputSize(pRen, &logical_size.w, &logical_size.h);
			util::math::vec2 half_dims(logical_size.x * 0.5f, logical_size.y * 0.5f);
			const util::shape::AABB view = m_pCamera->CalcViewAabb(half_dims);
			
			Cull(view);

			//__todo()//remove this when you don't want to see the camera box anymore
			//CRenderNodeRect cam_box;
			//cam_box.SetAABB(m_pCamera->CalcViewAabb(half_dims));
			//cam_box.SetFill(false);
			//cam_box(pRen, util::math::Matrix2D()); //this is incorrect and should use the actual camera matrix


			__todo() //replace this with the nodes found after the cull
				//also use the actuall camera matrix

			util::math::Matrix2D inv_cam = util::math::Matrix2D::Matrix_Inverse(m_pCamera->GetMatrix());
			for (auto iter = m_vCulledNodes.begin(); iter != m_vCulledNodes.end(); ++iter)
			{
				(*iter)->operator()(pRen, inv_cam);
			}
		}
示例#3
0
void FMRUList::AddMRUItem(const FString& InItem)
{
	FString CleanedName = FPaths::ConvertRelativePathToFull(InItem);

	// See if the item already exists in the list.  If so,
	// move it to the top of the list and leave.
	const int32 ItemIndex = Items.Find( CleanedName );
	if ( ItemIndex != INDEX_NONE )
	{
		MoveToTop( ItemIndex );
	}
	else
	{
		// Item is new, so add it to the bottom of the list.
		if( CleanedName.Len() )
		{
			new(Items) FString( *CleanedName );
			MoveToTop( Items.Num()-1 );
		}

		Cull();
	}
	
	WriteToINI();
}
示例#4
0
//----------------------------
// Update
//----------------------------
bool COrientedParticle::Update()
{
	// Game pausing can cause dumb time things to happen, so kill the effect in this instance
	if ( mTimeStart > theFxHelper.mTime )
	{
		return false;
	}
		
	if (( mTimeStart < theFxHelper.mTime ) && UpdateOrigin() == false )
	{
		// we are marked for death
		return false;
	}

	if ( !Cull())
	{
		UpdateSize();
		UpdateRGB();
		UpdateAlpha();
		UpdateRotation();

		Draw();
	}

	return true;
}
示例#5
0
void CullSystem::Cull( matrix44& vp, TreeNode<VisCell>& node, std::vector<std::list<Ptr<Renderable>>>& outRenderables )
{
	InterSectResult result = node.GetContent().GetAABB().InterSect(vp);
	if ( !result==INTERSECTOUT )
	{
		std::list<Ptr<Renderable>>::iterator iter = node.GetContent().GetRenderables().begin();
		if (result== INTERSECTIN)
		{
			for (;iter!=node.GetContent().GetRenderables().end();iter++)
			{
				RenderType rType = (*iter)->GetRenderType();
				outRenderables[rType].push_back((*iter));
			}
		}
		else
		{
			for (;iter!=node.GetContent().GetRenderables().end();iter++)
			{
				if ( (*iter)->GetWorldBBox().InterSect(vp)!= INTERSECTOUT)
				{
					RenderType rType = (*iter)->GetRenderType();
					outRenderables[rType].push_back((*iter));
				}
			}
		}
		for (int i = 0 ;i<(int)node.GetChildren().size();i++)
		{
			Cull( vp,*node.GetChildren()[i],outRenderables );
		}

	}
}
示例#6
0
文件: ItemMng.cpp 项目: gthgame/gth
void CItemMng::ProcessEntityFrame()
{
	itementity_t *entity;
	int *linkedCount;

	m_MDLMng->ClearItemLinkedCount();
	linkedCount = m_MDLMng->GetItemVisibleLinkedCount();
	m_MDLMng->m_focusedItem = -1;

	entity = m_linked;
	while( entity )
	{
		if( Cull( entity->mins , entity->maxs , entity->origin , entity->linkedCluster ) )
		{
			m_MDLMng->m_MDLItemEntities[ entity->idxMDLEntity ].visible = false;
			entity->visible = false;
		}
		else
		{
			linkedCount[ m_MDLMng->m_MDLItemEntities[ entity->idxMDLEntity ].idxClass ]++;
			m_MDLMng->m_MDLItemEntities[ entity->idxMDLEntity ].visible = true;
			entity->visible = true;
		}
		
		entity = entity->next;
	}
}
示例#7
0
	void Map::Draw()
	{
		Cull();
		DrawMap(0);
		//DrawMap(1);
		//DrawMap(2);
	}
void PredatorController::update(Player *p, ExplosionController * ec, std::vector<Obstacle*> *o) {
	Cull();
	for (int i = 0; i < container.size(); i++) {
		container.at(i)->update(&container, p, ec, o);
	}

	//Check Predators for Colisions
	for (int i = 0; i < container.size(); i++) 
	{
		if (container[i]->isAlive()) {
			//Preditor Collide with Player Check
			if (p->getGlobalBounds().intersects(container[i]->getGlobalBounds()) == true) {
				//If perpixal is true
				if (PixelPerfect::Collision(*p, *container[i], p->getTextureImage(), container[i]->getTextureImage()))	{
					ec->AddExplosion(container[i]->getPosition());
					container[i]->Destroy();
					if (p->IsShieldActive() == false)
						p->setHealth((p->getHealth() - 35));
					std::cout << "Predator Colided with player and dealt 35 damage. Player now has " << p->getHealth() << " health." << std::endl;
				}
			}
		}
		//Preditor Collide with Player Bullets
		if (p->CheckBulletsCollision(container.at(i)->getGlobalBounds(), *container.at(i), container.at(i)->getTextureImage()) == true)
		{
			//for (int j = 0; j < p->bullets.size(); j = 0)
			//{
				//Per Pixel
				//if (PixelPerfect::Collision(*p->bullets.at(j), *container[i], p->bullets.at(j)->GetTextureImage(), container[i]->getTextureImage())) {
					ec->AddExplosion(container.at(i)->getPosition());
					container.at(i)->Destroy();
					std::cout << "Players Bullet destroyed predator at index" << i << std::endl;
				//}
			//}
		}
		//Preditor Collide with obsticles check
		for (int j = 0; j < o->size(); j++) {
			if (container[i]->getGlobalBounds().intersects(o->at(j)->getGlobalBounds())) {
				if (PixelPerfect::Collision(*container.at(i), *o->at(j), container.at(i)->getTextureImage(), o->at(j)->getTextureImage())) {
					ec->AddExplosion(container[i]->getPosition());
					container[i]->Destroy();
					std::cout << "Obstacle with index " << j << " was hit with Predator at index " << i << std::endl;
				}
			}
		}
	}
}
示例#9
0
//----------------------------
// Update
//----------------------------
bool CPoly::Update()
{
	vec3_t mOldOrigin;
	
	// Game pausing can cause dumb time things to happen, so kill the effect in this instance
	if ( mTimeStart > theFxHelper.mTime )
	{
		return false;
	}

	// If our timestamp hasn't exired yet, we won't even consider doing any kind of motion
	if ( theFxHelper.mTime > mTimeStamp )
	{
		VectorCopy( mOrigin1, mOldOrigin );

		if (( mTimeStart < theFxHelper.mTime ) && UpdateOrigin() == false )
		{
			// we are marked for death
			return false;
		}
	}

	if ( !Cull() )
	{
		// only rotate when our start timestamp has expired
		if ( theFxHelper.mTime > mTimeStamp )
		{
			// Only rotate whilst moving
			if ( !VectorCompare( mOldOrigin, mOrigin1 ))
			{
				Rotate();
			}
		}

		UpdateRGB();
		UpdateAlpha();

		Draw();
	}

	return true;
}
示例#10
0
void ModelComponent::DrawDeferred(const tt::GameContext& context)
{
	if(m_pMaterial == nullptr)
		throw exception();
	
	if( Cull(context) )
		return;	
	
	auto pMat = dynamic_cast<SkinnedMaterial*>(m_pMaterial.get() );
	if(pMat){
		if(!m_pModel->HasAnimData())
			MyServiceLocator::GetInstance()->GetService<DebugService>()->Log(_T("SkinnedMaterial cannot be assigned to a model without animation data"), LogLevel::Error);
		
		m_pMeshAnimator->Draw(context);
		pMat->SetBoneTransforms(m_pMeshAnimator->GetBoneTransforms() );
		pMat->SetDualQuats(m_pMeshAnimator->GetDualQuats() );
		pMat->SetLightDirection(tt::Vector3(0,-1,0) );
	}

	MyServiceLocator::GetInstance()->GetService<IGraphicsService>()->DrawDeferred(m_pModel, m_pTransform->GetWorldMatrix(), m_pMaterial, context);
}
示例#11
0
void SgObjectManager::Update( SgMap *map , SgViewPort *viewport , SgInputManager* pInput )
{
	//if the game is paused we just draw the objects (and don't animate them)
	if(m_pTimer->IsPaused())
	{
		return;
	}
	//Create a new random seed for randomness.
	RandomSeed(timeGetTime());
	//animate each object individually (if user object we pass the input along)
	for(int i=0; i<m_dwMaxObjects; i++){
		//if object exists
		if(m_ppObject[i]!=NULL){
			if(i!=(m_dwUserObject-1)){
				m_ppObject[i]->Animate(m_pTimer, map, NULL, this);
			}else{
				m_ppObject[i]->Animate(m_pTimer, map, pInput, this);
			}
		}
	}

	//set the viewport to the user objects
	viewport->update(m_pTimer->Time());

	if((m_dwUserObject>0) && (m_ppObject[m_dwUserObject-1]!=NULL) )
	{
		viewport->force_position(m_ppObject[m_dwUserObject-1]->GetX(), m_ppObject[m_dwUserObject-1]->GetY());
		
	}
	else
	{
		viewport->stop_scroll();
	}

	//detect collisions (which will do all necessary steps if there is a collision)
	DetectCollisions();
	
	Cull(); //cull old objects
}
bool FXSpawner::Update( void )
{
	UpdateOrigin();
	UpdateVelocity();
	UpdateScale();
	UpdateAlpha();
	
	//FIXME: This is being double called...
	if ( Cull() == false )
	{
		if ( m_nextThink < cg.time )
		{
			if (Think != NULL)
				Think( m_origin, m_angles, m_velocity, m_startRGB );

			m_nextThink = cg.time + ( ( m_delay + ( m_variance * crandom() )) );

			if ( m_flags & FXF_SPAWN_ONCE )
				return false;
		}
	}
	
	return true;
}
示例#13
0
void Puzzle::WorkerGenerator()
{
	m_generation = 0;
	CreatePopulation(m_populationSize);

	m_generation = 1;

	std::ofstream file;
	file.open(m_saveFileName);

	while(true)
	{
		std::cout << "Starting Generation " << m_generation << std::endl;
		try
		{
			//Check to see if the main thread has signled us to stop
			boost::this_thread::interruption_point();
		}
		catch(boost::thread_interrupted&)
		{
			//If we have been signled to stop then shutdown all worker threads and wait
			StopWorkers();
			file.close();
			return;
		}

		boost::this_thread::disable_interruption disableInterruption;

		int lastSize = m_polulation->size();

		while (m_polulation->size() >= 2)
		{
			Creature* c1;
			Creature* c2;

			{
				boost::unique_lock<boost::recursive_mutex> lock(m_populationLock);

				unsigned int creature1Index = 0, creature2Index = 0;

				SelectNextParents(creature1Index, creature2Index);

				c1 = (*m_polulation)[creature1Index];
				c2 = (*m_polulation)[creature2Index];

				if (c1 == c2)
					break;

				m_polulation->erase(m_polulation->begin() + creature1Index);
				if (creature1Index < creature2Index)
					creature2Index -= 1;
				m_polulation->erase(m_polulation->begin() + creature2Index);
			}


			{
				boost::unique_lock<boost::mutex> pairLock(m_pairsAccess);
				boost::unique_lock<boost::recursive_mutex> jobCountLock(m_jobCountAccess);

				m_pairs.push(std::pair<Creature*, Creature*>(c1, c2));
				m_jobCount++;
			}

			m_workerTrigger.notify_one();
		}

		while(m_jobCount != 0)
		{
			boost::this_thread::yield();
		}

		SwapPopulations();
#ifdef USE_ELITE
		Elite();
#elif !USE_BASELINE
		Cull();
#endif

		if(m_generation % 5 == 0)
		{
			int half = m_polulation->size() / 2;
			auto& popRef = *m_polulation;

			Creature* best = popRef[0];
			Creature* worst = popRef[popRef.size() - 1];
			Creature* med = popRef[half];

			file << m_generation << "," << best->GetScore() << "," << worst->GetScore() << "," << med->GetScore() << std::endl;
		}

		m_generation++;

		boost::this_thread::restore_interruption enableInterruption(disableInterruption);
	}
}
示例#14
0
//----------------------------
bool CTail::Update()
{
	// Game pausing can cause dumb time things to happen, so kill the effect in this instance
	if ( mTimeStart > theFxHelper.mTime )
	{
		return false;
	}
	
	if ( !fx_freeze.integer )
	{
		VectorCopy( mOrigin1, mOldOrigin );
	}

	if ( mFlags & FX_RELATIVE )
	{
		if ( mClientID < 0 || mClientID >= ENTITYNUM_WORLD )
		{
			// the thing we are bolted to is no longer valid, so we may as well just die.
			return false;
		}

		vec3_t	dir, org;
//		vec3_t	right, up;
		vec3_t 	realVel, realAccel;

		// Get our current position and direction
		GetOrigin( mClientID, org );
		GetDir( mClientID, dir );

		vec3_t ang, ax[3];

		vectoangles( dir, ang );
		AngleVectors( ang, ax[0], ax[1], ax[2] );

		VectorMA( org, mOrgOffset[0], ax[0], org );
		VectorMA( org, mOrgOffset[1], ax[1], org );
		VectorMA( org, mOrgOffset[2], ax[2], org );

		// calc the real velocity and accel vectors
		// FIXME: if you want right and up movement in addition to the forward movement, you'll have to convert dir into a set of perp. axes and do some extra work
		VectorScale( ax[0], mVel[0], realVel );
		VectorMA( realVel, mVel[1], ax[1], realVel );
		VectorMA( realVel, mVel[2], ax[2], realVel );

		VectorScale( ax[0], mAccel[0], realAccel );
		VectorMA( realAccel, mAccel[1], ax[1], realAccel );
		VectorMA( realAccel, mAccel[2], ax[2], realAccel );

		// Get our real velocity at the current time, taking into account the effects of acceleration.  NOTE: not sure if this is even 100% correct math-wise
		VectorMA( realVel, (theFxHelper.mTime - mTimeStart) * 0.001f, realAccel, realVel );

		// Now move us to where we should be at the given time
		VectorMA( org, (theFxHelper.mTime - mTimeStart) * 0.001f, realVel, mOrigin1 );

		// Just calc an old point some time in the past, doesn't really matter when
		VectorMA( org, ((theFxHelper.mTime - mTimeStart) - 3) * 0.001f, realVel, mOldOrigin );
	}
	else if (( mTimeStart < theFxHelper.mTime ) && UpdateOrigin() == false )
	{
		// we are marked for death
		return false;
	}

	if ( !Cull() )
	{
		UpdateSize();
		UpdateLength();
		UpdateRGB();
		UpdateAlpha();

		CalcNewEndpoint();

		Draw();
	}

	return true;
}
示例#15
0
//----------------------------
// Update
//----------------------------
bool CParticle::Update()
{
	// Game pausing can cause dumb time things to happen, so kill the effect in this instance
	if ( mTimeStart > theFxHelper.mTime )
	{
		return false;
	}

	if ( mFlags & FX_RELATIVE )
	{
		if ( mClientID < 0 || mClientID >= ENTITYNUM_WORLD )
		{
			// we are somehow not bolted even though the flag is on?
			return false;
		}

		vec3_t	dir, org;
		vec3_t 	realVel, realAccel;
		float	time = (theFxHelper.mTime - mTimeStart) * 0.001f;

		// Get our current position and direction
		GetOrigin( mClientID, org );
		GetDir( mClientID, dir );
	
		vec3_t ang, ax[3];

		vectoangles( dir, ang );
		AngleVectors( ang, ax[0], ax[1], ax[2] );
//		VectorCopy( dir, ax[0] );

//		CrossProduct( up, ax[0], ax[1] );
//		VectorNormalize( ax[1] );
//		CrossProduct( ax[0], ax[1], ax[2] );

		VectorMA( org, mOrgOffset[0], ax[0], org );
		VectorMA( org, mOrgOffset[1], ax[1], org );
		VectorMA( org, mOrgOffset[2], ax[2], org );

		// calc the real velocity and accel vectors
		VectorScale( ax[0], mVel[0], realVel );
		VectorMA( realVel, mVel[1], ax[1], realVel );
		VectorMA( realVel, mVel[2], ax[2], realVel );
		realVel[2] += 0.5f * mGravity * time;

		VectorScale( ax[0], mAccel[0], realAccel );
		VectorMA( realAccel, mAccel[1], ax[1], realAccel );
		VectorMA( realAccel, mAccel[2], ax[2], realAccel );

		// Get our real velocity at the current time, taking into account the effects of acceleartion.  NOTE: not sure if this is even 100% correct math-wise
		VectorMA( realVel, time, realAccel, realVel );

		// Now move us to where we should be at the given time
		VectorMA( org, time, realVel, mOrigin1 );
		
	}
	else if (( mTimeStart < theFxHelper.mTime ) && UpdateOrigin() == false )
	{
		// we are marked for death
		return false;
	}

	if ( !Cull())
	{
		UpdateSize();
		UpdateRGB();
		UpdateAlpha();
		UpdateRotation();

		Draw();
	}

	return true;
}
示例#16
0
文件: EntityMng.cpp 项目: gthgame/gth
void CEntityMng::ProcessEntity()
{
	worldentity_t         *entity;
	int  worldIdx;
	int  visType;
	int  idxClass;

	m_MDLMng->ClearRenderWorldLink();
	m_MDLMng->ClearBlendWorldLink();
	
	entity = m_linked;
	while( entity )
	{
		if( !entity->inuse )  
		{
			entity = entity->next;
			continue;
		}

		switch( entity->classType )
		{
		case GTH_WORLD_ENTITY_TYPE_PLAYER_POS :
			        break;
		
		case GTH_WORLD_ENTITY_TYPE_MODEL :
			visType = ChechVisibleDistance( entity->origin , entity->mins , entity->maxs , entity->radius );
			if( visType == ENTITY_OVER_THAN_VISIBLE )
			{
				m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ].visible = false;
				break;
			}

			if( Cull( entity->mins , entity->maxs , entity->origin , entity->linkedCluster ) )
				m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ].visible = false;
			else
			{
				idxClass = m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ].idxClass;
				 


				if( ( visType == ENTITY_CLOSED_THAN_CHARACTER ) && m_MDLMng->m_MDLWorldClasses[ idxClass ].hideFlag )
				{
					
					m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ].blendNext = m_MDLMng->m_linkedBlendMDLWorldEntities[ idxClass ];
					m_MDLMng->m_linkedBlendMDLWorldEntities[ idxClass ] = &m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ];
					m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ].visible = visType;
				}
				else
				{
					m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ].renderNext = m_MDLMng->m_linkedRenderMDLWorldEntities[ idxClass ];
					m_MDLMng->m_linkedRenderMDLWorldEntities[ idxClass ] = &m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ];
					m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ].visible = visType;
				}
			}

			break;

		case GTH_WORLD_ENTITY_TYPE_TELEPORT :

			if ( g_cgv.flagChangeWorld ) break;

			visType = ChechVisibleDistance( entity->origin , entity->mins , entity->maxs , entity->radius );
			if( visType == ENTITY_OVER_THAN_VISIBLE )
			{
				m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ].visible = false;
				break;
			}

			if( Cull( entity->mins , entity->maxs , entity->origin , entity->linkedCluster ) )
				m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ].visible = false;
			else
			{
				idxClass = m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ].idxClass;
				if( visType == ENTITY_CLOSED_THAN_CHARACTER )
				{
					m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ].blendNext = m_MDLMng->m_linkedBlendMDLWorldEntities[ idxClass ];
					m_MDLMng->m_linkedBlendMDLWorldEntities[ idxClass ] = &m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ];
					m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ].visible = visType;
				}
				else
				{
					m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ].renderNext = m_MDLMng->m_linkedRenderMDLWorldEntities[ idxClass ];
					m_MDLMng->m_linkedRenderMDLWorldEntities[ idxClass ] = &m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ];
					m_MDLMng->m_MDLWorldEntities[ entity->idxMDLEntity ].visible = visType;
				}
			}

			if( !ChechEffectiveDistance( entity->origin , entity->effectiveDist ) )  break;

			
			if(g_SkillLogic.CancelTransform(true)) return ;
			
			
			
			if(true == g_ifMng->m_Item_ScrollWin->IfWorldChangeing())
			{	
				g_ifMng->AddSysMessage( g_LPACK.GetMassage(LPACK_TYPE_NORMAL2, 588 ));
				return;
			}

			
			if( g_pApp->m_myCharacter->isTransform ) return ;

			worldIdx = GTH_WorldToIndex( entity->target );
			if( worldIdx < 0 ) break;
			m_spawnID = entity->spawnid;

			
			GTH_RequestChangeWorld( worldIdx, m_spawnID ); 
			break;

		case GTH_WORLD_ENTITY_TYPE_ACTIVATOR :
			if( !ChechEffectiveDistance( entity->origin , entity->effectiveDist ) )  break;
			break;

		case GTH_WORLD_ENTITY_TYPE_DEACTIVATOR :
			if( !ChechEffectiveDistance( entity->origin , entity->effectiveDist ) )  break;
			break;

		case GTH_WORLD_ENTITY_TYPE_DOOR :
			break;

		case GTH_WORLD_ENTITY_TYPE_PATH :
			ProcessPath( entity );
			break;

		case GTH_WORLD_ENTITY_TYPE_CAMERA_PATH :
			ProcessCameraPath( entity );
			break;

		case GTH_WORLD_ENTITY_TYPE_SOUND :
				
			if( !CheckEffectiveSoundDistance( entity->origin , entity->soundRangeX , entity->soundRangeY ) )
			{
				if( entity->soundInPlaying )
				{
					 
					g_musicMng->Stop ( entity->soundIdx );
					entity->soundInPlaying = false;
				}
				break;
			}
			if( entity->soundInPlaying )  break;

			g_musicMng->PlaySample ( entity->soundIdx, GTH_SOUND_PLAY_LOOP );
			entity->soundInPlaying = true;
				
				    break;

		default:
			        break;
		}

		entity = entity->next;
	}
}
示例#17
0
void GraphicsGL2::CullScenePass(
	const GraphicsConfigPass & pass,
	std::ostream & error_output)
{
	// for each pass, we have which camera and which draw layer to use
	// we want to do culling for each unique camera and draw layer combination
	// use camera/layer as the unique key
	assert(!pass.draw.empty());

	if (pass.draw.back() == "postprocess" || !pass.conditions.Satisfied(conditions))
		return;

	for (std::vector <std::string>::const_iterator d = pass.draw.begin(); d != pass.draw.end(); d++)
	{
		// determine if we're dealing with a cubemap
		RenderOutputMap::iterator oi = render_outputs.find(pass.output);
		if (oi == render_outputs.end())
		{
			ReportOnce(&pass, "Render output "+pass.output+" couldn't be found", error_output);
			return;
		}

		const bool cubemap = (oi->second.IsFBO() && oi->second.RenderToFBO().IsCubemap());
		const int cubesides = cubemap ? 6 : 1;
		std::string cameraname = pass.camera;
		for (int cubeside = 0; cubeside < cubesides; cubeside++)
		{
			if (cubemap)
			{
				// build a name for the sub camera
				{
					std::ostringstream s;
					s << pass.camera << "_cubeside" << cubeside;
					cameraname = s.str();
				}

				// get the base camera
				CameraMap::iterator bci = cameras.find(pass.camera);
				if (bci == cameras.end())
				{
					ReportOnce(&pass, "Camera " + pass.camera + " couldn't be found", error_output);
					return;
				}

				// create our sub-camera
				GraphicsCamera & cam = cameras[cameraname];
				cam = bci->second;

				// set the sub-camera's properties
				cam.rot = GetCubeSideOrientation(cubeside, cam.rot, error_output);
				cam.fov = 90;
				assert(oi->second.IsFBO());
				const FrameBufferObject & fbo = oi->second.RenderToFBO();
				cam.w = fbo.GetWidth();
				cam.h = fbo.GetHeight();
			}

			const std::string drawlist_name = BuildKey(cameraname, *d);
			CulledDrawList & drawlist = culled_drawlists[drawlist_name];
			if (drawlist.valid)
				break;

			drawlist.valid = true;
			if (pass.cull)
			{
				// cull static drawlist
				reseatable_reference <AabbTreeNodeAdapter <Drawable> > container = static_drawlist.GetByName(*d);
				if (!container)
				{
					ReportOnce(&pass, "Drawable container " + *d + " couldn't be found", error_output);
					return;
				}

				CameraMap::iterator ci = cameras.find(cameraname);
				if (ci == cameras.end())
				{
					ReportOnce(&pass, "Camera " + cameraname + " couldn't be found", error_output);
					return;
				}
				const GraphicsCamera & cam = ci->second;

				Frustum frustum;
				frustum.Extract(GetProjMatrix(cam).GetArray(), GetViewMatrix(cam).GetArray());

				container->Query(frustum, drawlist.drawables);

				// cull dynamic drawlist
				reseatable_reference <PtrVector <Drawable> > container_dynamic = dynamic_drawlist.GetByName(*d);
				if (!container_dynamic)
				{
					ReportOnce(&pass, "Drawable container " + *d + " couldn't be found", error_output);
					return;
				}
				for (size_t i = 0; i < container_dynamic->size(); ++i)
				{
					if (!Cull(frustum, *(*container_dynamic)[i]))
						drawlist.drawables.push_back((*container_dynamic)[i]);
				}
			}
			else
			{
				// copy static drawlist
				reseatable_reference <AabbTreeNodeAdapter <Drawable> > container = static_drawlist.GetByName(*d);
				if (!container)
				{
					ReportOnce(&pass, "Drawable container " + *d + " couldn't be found", error_output);
					return;
				}
				container->Query(Aabb<float>::IntersectAlways(), drawlist.drawables);

				// copy dynamic drawlist
				reseatable_reference <PtrVector <Drawable> > container_dynamic = dynamic_drawlist.GetByName(*d);
				if (!container_dynamic)
				{
					ReportOnce(&pass, "Drawable container " + *d + " couldn't be found", error_output);
					return;
				}
				drawlist.drawables.insert(
					drawlist.drawables.end(),
					container_dynamic->begin(),
					container_dynamic->end());
			}
		}
	}
}
示例#18
0
bool AABBox::Intersects(const Frustum &_Frustum)
{
	return ( Cull(_Frustum.planes, Frustum::VF_PLANE_COUNT) != SGP_CULLED );
}