예제 #1
0
void DeleteLODCommand::Redo()
{
    DVASSERT(deletedBatches.size() == 0);

    DAVA::Entity *entity = GetEntity();
    DAVA::RenderObject *ro = DAVA::GetRenderObject(entity);

    //save renderbatches
    DAVA::int32 count = (DAVA::int32)ro->GetRenderBatchCount();
    for(DAVA::int32 i = count-1; i >= 0; --i)
    {
        DAVA::int32 lodIndex = 0, switchIndex = 0;
        DAVA::RenderBatch *batch = ro->GetRenderBatch(i, lodIndex, switchIndex);
        if(lodIndex == deletedLodIndex && (requestedSwitchIndex == switchIndex || requestedSwitchIndex == -1))
        {
            DeleteRenderBatchCommand *command = new DeleteRenderBatchCommand(entity, ro, i);
            deletedBatches.push_back(command);

            RedoInternalCommand(command);
        }
    }
    
    //update indexes
    count = ro->GetRenderBatchCount();
    for(DAVA::int32 i = (DAVA::int32)count - 1; i >= 0; --i)
    {
        DAVA::int32 lodIndex = 0, switchIndex = 0;
        DAVA::RenderBatch *batch = ro->GetRenderBatch(i, lodIndex, switchIndex);
        if(lodIndex > deletedLodIndex && (requestedSwitchIndex == switchIndex || requestedSwitchIndex == -1))
        {
            batch->Retain();
            
            ro->RemoveRenderBatch(i);
            ro->AddRenderBatch(batch, lodIndex - 1, switchIndex);
            
            batch->Release();
        }
    }

    //update distances
    for(DAVA::int32 i = deletedLodIndex; i < DAVA::LodComponent::MAX_LOD_LAYERS-1; ++i)
    {
        lodComponent->lodLayersArray[i] = lodComponent->lodLayersArray[i+1];
    }
    
    //last lod
    DAVA::uint32 layersSize = ro->GetMaxLodIndex() + 1;
    if(layersSize)
    {
        lodComponent->lodLayersArray[layersSize-1].SetFarDistance(2 * DAVA::LodComponent::MAX_LOD_DISTANCE);
    }
    
    //first lod
    lodComponent->SetLodLayerDistance(0, 0);
    lodComponent->lodLayersArray[0].SetNearDistance(0.0f);
    
    //visual part
    lodComponent->currentLod = DAVA::LodComponent::INVALID_LOD_LAYER;
    lodComponent->forceLodLayer = DAVA::LodComponent::INVALID_LOD_LAYER;
}
예제 #2
0
void CommandBatch::AddAndExec(Command2 *command)
{
	if(NULL != command)
	{
		commandList.push_back(command);
		RedoInternalCommand(command);
	}
}
예제 #3
0
void CommandBatch::Redo()
{
	std::list<Command2 *>::iterator i = commandList.begin();
	std::list<Command2 *>::iterator end = commandList.end(); 

	for(; i != end; i++)
	{
		RedoInternalCommand(*i);
	}
}