refactor: group command use a non parameter constructor and a reentrant init function

This commit is contained in:
Huabing.Xu 2013-12-03 11:24:03 +08:00
parent d33f05b3f0
commit d4b9e0538b
3 changed files with 15 additions and 5 deletions

View File

@ -63,15 +63,23 @@ void GroupCommandManager::releaseGroupID(int groupID)
_groupMapping[groupID] = false;
}
GroupCommand::GroupCommand(int viewport, int32_t depth)
GroupCommand::GroupCommand()
:RenderCommand()
, _viewport(viewport)
, _depth(depth)
, _viewport(0)
, _depth(0)
{
_type = GROUP_COMMAND;
_renderQueueID = GroupCommandManager::getInstance()->getGroupID();
}
void GroupCommand::init(int viewport, int32_t depth)
{
_viewport = viewport;
_depth = depth;
GroupCommandManager::getInstance()->releaseGroupID(_renderQueueID);
_renderQueueID = GroupCommandManager::getInstance()->getGroupID();
}
GroupCommand::~GroupCommand()
{
GroupCommandManager::getInstance()->releaseGroupID(_renderQueueID);

View File

@ -35,7 +35,8 @@ class GroupCommand : public RenderCommand
{
public:
GroupCommand(int viewport, int32_t depth);
GroupCommand();
void init(int viewport, int32_t depth);
~GroupCommand();
// +----------+----------+-----+-----------------------------------+

View File

@ -85,7 +85,8 @@ void NewClippingNode::visit()
Renderer* renderer = Renderer::getInstance();
GroupCommand* groupCommand = new GroupCommand(0,_vertexZ);
GroupCommand* groupCommand = new GroupCommand();
groupCommand->init(0,_vertexZ);
renderer->addCommand(groupCommand);
renderer->pushGroup(groupCommand->getRenderQueueID());