ChunkModelBuilder.cpp 958 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include "ChunkModelBuilder.h"
  2. #include "Chunk.h"
  3. ChunkModelBuilder::ChunkModelBuilder(
  4. FactoryCraftModel* target, Chunk* zChunk, int type)
  5. : ReferenceCounter(),
  6. zChunk(zChunk),
  7. type(type),
  8. target(target)
  9. {}
  10. ChunkModelBuilder::~ChunkModelBuilder()
  11. {
  12. target->release();
  13. }
  14. Block** ChunkModelBuilder::blocks()
  15. {
  16. return zChunk->blocks;
  17. }
  18. void ChunkModelBuilder::setBlockPartOfModel(Block* zBlock, bool partOfModel)
  19. {
  20. int state = zBlock->getPartOfModels();
  21. if (!state && partOfModel)
  22. {
  23. zChunk->visibleBlocks.removeValue(zBlock);
  24. }
  25. zBlock->setPartOfModel(type, partOfModel);
  26. if (state && !zBlock->getPartOfModels())
  27. {
  28. zChunk->visibleBlocks.add(zBlock);
  29. }
  30. }
  31. Framework::Punkt ChunkModelBuilder::chunkCenter()
  32. {
  33. return zChunk->location;
  34. }
  35. FactoryCraftModel* ChunkModelBuilder::zModel() const
  36. {
  37. return target;
  38. }
  39. int ChunkModelBuilder::getType() const
  40. {
  41. return type;
  42. }