Chunk.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  1. #include "Chunk.h"
  2. #include <Shader.h>
  3. #include "ChunkFluidModel.h"
  4. #include "ChunkGroundModel.h"
  5. #include "Constants.h"
  6. #include "CustomDX11API.h"
  7. #include "FactoryCraftModel.h"
  8. #include "Globals.h"
  9. #include "TransparentChunkGroundModel.h"
  10. Chunk::Chunk(Framework::Point location)
  11. : ReferenceCounter(),
  12. location(location),
  13. isLoading(0),
  14. lightChanged(0),
  15. modelChanged(0)
  16. {
  17. blocks = new Block*[CHUNK_SIZE * CHUNK_SIZE * WORLD_HEIGHT];
  18. memset(blocks, 0, CHUNK_SIZE * CHUNK_SIZE * WORLD_HEIGHT * sizeof(Block*));
  19. FactoryCraftModel* ground = new FactoryCraftModel();
  20. Model3DData* chunkModel
  21. = uiFactory.initParam.bildschirm->zGraphicsApi()->getModel(
  22. Text("chunk_ground_") + location.x + location.y);
  23. if (!chunkModel)
  24. {
  25. chunkModel
  26. = uiFactory.initParam.bildschirm->zGraphicsApi()->createModel(
  27. Text("chunk_ground_") + location.x + location.y);
  28. }
  29. chunkModel->setAmbientFactor(0.f);
  30. chunkModel->setDiffusFactor(1.f);
  31. chunkModel->setSpecularFactor(0.f);
  32. chunkModel->setVertecies(0, 0);
  33. ground->setModelData(chunkModel);
  34. ground->setPosition(
  35. (float)location.x, (float)location.y, (float)WORLD_HEIGHT / 2.f);
  36. ground->tick(0);
  37. ChunkModelBuilder* groundModel = new ChunkGroundModel(ground, this);
  38. modelBuilders.add(groundModel);
  39. FactoryCraftModel* transparentGround = new FactoryCraftModel();
  40. chunkModel = uiFactory.initParam.bildschirm->zGraphicsApi()->getModel(
  41. Text("transparent_chunk_ground_") + location.x + location.y);
  42. if (!chunkModel)
  43. {
  44. chunkModel
  45. = uiFactory.initParam.bildschirm->zGraphicsApi()->createModel(
  46. Text("transparent_chunk_ground_") + location.x + location.y);
  47. }
  48. chunkModel->setAmbientFactor(0.f);
  49. chunkModel->setDiffusFactor(1.f);
  50. chunkModel->setSpecularFactor(0.f);
  51. chunkModel->setVertecies(0, 0);
  52. transparentGround->setModelData(chunkModel);
  53. transparentGround->setPosition(
  54. (float)location.x, (float)location.y, (float)WORLD_HEIGHT / 2.f);
  55. transparentGround->tick(0);
  56. ChunkModelBuilder* transparentGroundModel
  57. = new TransparentChunkGroundModel(transparentGround, this);
  58. modelBuilders.add(transparentGroundModel);
  59. FactoryCraftModel* fluids = new FactoryCraftModel();
  60. chunkModel = uiFactory.initParam.bildschirm->zGraphicsApi()->getModel(
  61. Text("chunk_fluids_") + location.x + location.y);
  62. if (!chunkModel)
  63. {
  64. chunkModel
  65. = uiFactory.initParam.bildschirm->zGraphicsApi()->createModel(
  66. Text("chunk_fluids_") + location.x + location.y);
  67. }
  68. chunkModel->setAmbientFactor(0.f);
  69. chunkModel->setDiffusFactor(1.f);
  70. chunkModel->setSpecularFactor(0.f);
  71. chunkModel->setVertecies(0, 0);
  72. fluids->setModelData(chunkModel);
  73. fluids->setPosition(
  74. (float)location.x, (float)location.y, (float)WORLD_HEIGHT / 2.f);
  75. fluids->tick(0);
  76. ChunkModelBuilder* fluidModel = new ChunkFluidModel(fluids, this);
  77. modelBuilders.add(fluidModel);
  78. }
  79. Chunk::Chunk(Framework::Point location, Framework::StreamReader* zReader)
  80. : Chunk(location)
  81. {
  82. load(zReader);
  83. for (ChunkModelBuilder* builder : modelBuilders)
  84. {
  85. buildModel(builder);
  86. }
  87. }
  88. Chunk::~Chunk()
  89. {
  90. char msg = 1; // remove observer
  91. if (World::INSTANCE)
  92. {
  93. World::INSTANCE->zClient()->chunkAPIRequest(location, &msg, 1);
  94. }
  95. for (int i = 0; i < CHUNK_SIZE * CHUNK_SIZE * WORLD_HEIGHT; i++)
  96. {
  97. if (blocks[i])
  98. {
  99. blocks[i]->release();
  100. blocks[i] = 0;
  101. }
  102. }
  103. delete[] blocks;
  104. }
  105. void Chunk::appendAnimation(
  106. Block* zB, int boneId, double time, Vec3<float> pos, Vec3<float> rot)
  107. {
  108. if (!zB->zSkeleton() || !zB->zSkeleton()->zBone(boneId)) return;
  109. acs.lock();
  110. for (BlockAnimation* animation : animations)
  111. {
  112. if (animation->zBlock() == zB)
  113. {
  114. animation->appendAnimation(boneId, time, pos, rot);
  115. acs.unlock();
  116. return;
  117. }
  118. }
  119. SkeletonAnimation* sa = new SkeletonAnimation();
  120. Bone* bone = zB->zSkeleton()->zBone(boneId);
  121. sa->addAnimation(boneId, bone->getPosition(), bone->getRotation());
  122. sa->addKeyFrame(boneId, time, pos, rot);
  123. animations.add(new BlockAnimation(dynamic_cast<Block*>(zB->getThis()), sa));
  124. acs.unlock();
  125. }
  126. void Chunk::load(Framework::StreamReader* zReader)
  127. {
  128. cs.lock();
  129. for (int i = 0; i < CHUNK_SIZE * CHUNK_SIZE * WORLD_HEIGHT; i++)
  130. {
  131. if (blocks[i])
  132. {
  133. blocks[i]->release();
  134. blocks[i] = 0;
  135. }
  136. }
  137. cs.unlock();
  138. isLoading = 1;
  139. Framework::Vec3<int> pos = {0, 0, 0};
  140. unsigned short id;
  141. zReader->read((char*)&id, 2);
  142. int count = 0;
  143. while (id)
  144. {
  145. int index;
  146. zReader->read((char*)&index, 4);
  147. char state = 0;
  148. zReader->read(&state, 1);
  149. char flowOptions = 0;
  150. char distanceToSource = 0;
  151. if (state & 1)
  152. {
  153. zReader->read(&flowOptions, 1);
  154. zReader->read(&distanceToSource, 1);
  155. }
  156. bool passable = 0;
  157. float speedModifier = 1.f;
  158. if (state & 2)
  159. {
  160. passable = 1;
  161. zReader->read((char*)&speedModifier, 4);
  162. }
  163. pos = Vec3<int>((index / WORLD_HEIGHT) / CHUNK_SIZE,
  164. (index / WORLD_HEIGHT) % CHUNK_SIZE,
  165. index % WORLD_HEIGHT);
  166. Direction dir = blockTypes[id]->getDefaultFrontDirection();
  167. if (state & 4)
  168. {
  169. zReader->read((char*)&dir, 1);
  170. }
  171. if (blockTypes[id]->doesNeedInstance())
  172. {
  173. cs.lock();
  174. Block* b = blockTypes[id]->createBlock(
  175. {pos.x + location.x - CHUNK_SIZE / 2,
  176. pos.y + location.y - CHUNK_SIZE / 2,
  177. pos.z},
  178. passable,
  179. speedModifier,
  180. dir);
  181. b->setFlow(flowOptions, distanceToSource);
  182. blocks[index] = b;
  183. cs.unlock();
  184. vcs.lock();
  185. if (b->isVisible())
  186. {
  187. if (!blockTypes[id]->getModelInfo().getModelName().isEqual(
  188. "cube")
  189. && !blockTypes[id]->getModelInfo().getModelName().isEqual(
  190. "grass"))
  191. {
  192. b->tick(0);
  193. visibleBlocks.add(b);
  194. }
  195. }
  196. count++;
  197. vcs.unlock();
  198. }
  199. zReader->read((char*)&id, 2);
  200. }
  201. std::cout << "Loaded " << count << " blocks\n";
  202. int index = 0;
  203. // light
  204. zReader->read((char*)&index, 4);
  205. char lightData[6];
  206. while (index >= -1)
  207. {
  208. if (index == -1)
  209. {
  210. int x = 0;
  211. int y = 0;
  212. int z = 0;
  213. zReader->read((char*)&x, 4);
  214. zReader->read((char*)&y, 4);
  215. zReader->read((char*)&z, 4);
  216. zReader->read(lightData, 6);
  217. if (x == -1)
  218. {
  219. int cacheIndex = y * WORLD_HEIGHT + z;
  220. Block* zB = blocks[cacheIndex];
  221. if (zB)
  222. {
  223. zB->setLightData(WEST, (unsigned char*)lightData, 0);
  224. }
  225. }
  226. else if (y == -1)
  227. {
  228. int cacheIndex = (x * CHUNK_SIZE) * WORLD_HEIGHT + z;
  229. Block* zB = blocks[cacheIndex];
  230. if (zB)
  231. {
  232. zB->setLightData(NORTH, (unsigned char*)lightData, 0);
  233. }
  234. }
  235. else if (x == CHUNK_SIZE)
  236. {
  237. int cacheIndex
  238. = ((CHUNK_SIZE - 1) * CHUNK_SIZE + y) * WORLD_HEIGHT + z;
  239. Block* zB = blocks[cacheIndex];
  240. if (zB)
  241. {
  242. zB->setLightData(EAST, (unsigned char*)lightData, 0);
  243. }
  244. }
  245. else if (y == CHUNK_SIZE)
  246. {
  247. int cacheIndex
  248. = (x * CHUNK_SIZE + (CHUNK_SIZE - 1)) * WORLD_HEIGHT + z;
  249. Block* zB = blocks[cacheIndex];
  250. if (zB)
  251. {
  252. zB->setLightData(SOUTH, (unsigned char*)lightData, 0);
  253. }
  254. }
  255. }
  256. else
  257. {
  258. zReader->read(lightData, 6);
  259. Framework::Vec3<int> location((index / WORLD_HEIGHT) / CHUNK_SIZE,
  260. (index / WORLD_HEIGHT) % CHUNK_SIZE,
  261. index % WORLD_HEIGHT);
  262. for (int i = 0; i < 6; i++)
  263. {
  264. Framework::Vec3<int> pos
  265. = location + getDirection(getDirectionFromIndex(i));
  266. if (pos.z >= 0 && pos.z < WORLD_HEIGHT)
  267. {
  268. if (pos.x >= 0 && pos.x < CHUNK_SIZE && pos.y >= 0
  269. && pos.y < CHUNK_SIZE)
  270. {
  271. int cacheIndex
  272. = (pos.x * CHUNK_SIZE + pos.y) * WORLD_HEIGHT
  273. + pos.z;
  274. Block* zB = blocks[cacheIndex];
  275. if (zB)
  276. {
  277. bool visible = zB->isVisible();
  278. zB->setLightData(
  279. getOppositeDirection(getDirectionFromIndex(i)),
  280. (unsigned char*)lightData,
  281. 0);
  282. if (zB->isVisible() && !visible)
  283. {
  284. vcs.lock();
  285. zB->tick(0);
  286. visibleBlocks.add(zB);
  287. vcs.unlock();
  288. }
  289. }
  290. }
  291. else
  292. {
  293. pos.x += this->location.x - CHUNK_SIZE / 2;
  294. pos.y += this->location.y - CHUNK_SIZE / 2;
  295. Chunk* c = World::INSTANCE->zChunk(
  296. World::INSTANCE->getChunkCenter(pos.x, pos.y));
  297. Block* zB = c ? c->zBlockAt(pos) : 0;
  298. if (zB)
  299. {
  300. bool visible = zB->isVisible();
  301. zB->setLightData(
  302. getOppositeDirection(getDirectionFromIndex(i)),
  303. (unsigned char*)lightData,
  304. c);
  305. if (zB->isVisible() && !visible)
  306. {
  307. c->vcs.lock();
  308. zB->tick(0);
  309. c->visibleBlocks.add(zB);
  310. c->vcs.unlock();
  311. }
  312. }
  313. }
  314. }
  315. }
  316. }
  317. zReader->read((char*)&index, 4);
  318. }
  319. isLoading = 0;
  320. }
  321. void Chunk::buildModel(ChunkModelBuilder* builder)
  322. {
  323. vcs.lock();
  324. modelChanged &= ~builder->getType();
  325. lightChanged &= ~builder->getType();
  326. builder->buildModel();
  327. vcs.unlock();
  328. }
  329. void Chunk::updateLight(ChunkModelBuilder* builder)
  330. {
  331. vcs.lock();
  332. lightChanged &= ~builder->getType();
  333. builder->updateLightning();
  334. vcs.unlock();
  335. }
  336. void Chunk::renderSolid(std::function<void(Model3D*)> f)
  337. {
  338. vcs.lock();
  339. CustomDX11API* api
  340. = (CustomDX11API*)uiFactory.initParam.bildschirm->zGraphicsApi();
  341. api->setCullBack(false);
  342. for (ChunkModelBuilder* builder : modelBuilders)
  343. {
  344. if (!builder->isTransparent())
  345. {
  346. f(builder->zModel());
  347. }
  348. }
  349. api->setCullBack(true);
  350. float dist = 0.f;
  351. for (Block* b : visibleBlocks)
  352. {
  353. f(b);
  354. }
  355. vcs.unlock();
  356. }
  357. void Chunk::renderTransparent(std::function<void(Model3D*)> f)
  358. {
  359. CustomDX11API* api
  360. = (CustomDX11API*)uiFactory.initParam.bildschirm->zGraphicsApi();
  361. api->setCullBack(false);
  362. for (ChunkModelBuilder* builder : modelBuilders)
  363. {
  364. if (builder->isTransparent())
  365. {
  366. f(builder->zModel());
  367. }
  368. }
  369. api->setCullBack(true);
  370. }
  371. bool Chunk::tick(std::function<void(Model3D*)> f, double time)
  372. {
  373. acs.lock();
  374. vcs.lock(); // TODO: enshure no dead lock occures
  375. for (ChunkModelBuilder* builder : modelBuilders)
  376. {
  377. if ((modelChanged | builder->getType()) == modelChanged)
  378. buildModel(builder);
  379. }
  380. for (ChunkModelBuilder* builder : modelBuilders)
  381. {
  382. if ((lightChanged | builder->getType()) == lightChanged)
  383. updateLight(builder);
  384. }
  385. bool res = 0;
  386. for (ChunkModelBuilder* builder : modelBuilders)
  387. {
  388. res |= builder->zModel()->tick(time);
  389. }
  390. auto iterator = animations.begin();
  391. while (iterator)
  392. {
  393. if (iterator->tick(time))
  394. {
  395. res |= iterator->zBlock()->tick(time);
  396. if (iterator->isFinished())
  397. {
  398. iterator.remove();
  399. continue;
  400. }
  401. }
  402. else
  403. {
  404. iterator.remove();
  405. continue;
  406. }
  407. ++iterator;
  408. }
  409. vcs.unlock();
  410. acs.unlock();
  411. return 1;
  412. }
  413. void Chunk::destroy()
  414. {
  415. for (ChunkModelBuilder* builder : modelBuilders)
  416. {
  417. Model3DData* chunkModel = builder->zModel()->zModelData();
  418. // remove old model
  419. while (chunkModel->getPolygonCount() > 0)
  420. {
  421. chunkModel->removePolygon(0);
  422. }
  423. chunkModel->setVertecies(0, 0);
  424. }
  425. }
  426. void Chunk::api(char* message)
  427. {
  428. switch (message[0])
  429. {
  430. case 0: // set block
  431. {
  432. unsigned short id = *(int*)(message + 1);
  433. int index = *(int*)(message + 3);
  434. char state = message[7];
  435. char flowOptions = 0;
  436. char distanceToSource = 0;
  437. int i = 8;
  438. if (state & 1)
  439. {
  440. flowOptions = message[i++];
  441. distanceToSource = message[i++];
  442. }
  443. bool passable = 0;
  444. float speedModifier = 1.f;
  445. if (state & 2)
  446. {
  447. passable = 1;
  448. speedModifier = *(float*)(message + i);
  449. i += 4;
  450. }
  451. Direction dir = blockTypes[id]->getDefaultFrontDirection();
  452. if (state & 4)
  453. {
  454. dir = (Direction)message[i++];
  455. }
  456. Framework::Vec3<int> location((index / WORLD_HEIGHT) / CHUNK_SIZE,
  457. (index / WORLD_HEIGHT) % CHUNK_SIZE,
  458. index % WORLD_HEIGHT);
  459. location.x += this->location.x - CHUNK_SIZE / 2;
  460. location.y += this->location.y - CHUNK_SIZE / 2;
  461. if (blockTypes[id]->doesNeedInstance())
  462. {
  463. Block* zB = blockTypes[id]->createBlock(
  464. location, passable, speedModifier, dir);
  465. zB->setFlow(flowOptions, distanceToSource);
  466. setBlock(zB);
  467. }
  468. else
  469. {
  470. Block* zB = zBlockAt(location);
  471. if (zB) removeBlock(zB);
  472. }
  473. break;
  474. }
  475. case 1: // animate block
  476. {
  477. int index = *(int*)(message + 1);
  478. int boneId = *(int*)(message + 5);
  479. double time = *(double*)(message + 9);
  480. Framework::Vec3<float> pos;
  481. pos.x = *(float*)(message + 17);
  482. pos.y = *(float*)(message + 21);
  483. pos.z = *(float*)(message + 25);
  484. Framework::Vec3<float> rot;
  485. rot.x = *(float*)(message + 29);
  486. rot.y = *(float*)(message + 33);
  487. rot.z = *(float*)(message + 37);
  488. Framework::Vec3<int> location((index / WORLD_HEIGHT) / CHUNK_SIZE,
  489. (index / WORLD_HEIGHT) % CHUNK_SIZE,
  490. index % WORLD_HEIGHT);
  491. location.x += this->location.x - CHUNK_SIZE / 2;
  492. location.y += this->location.y - CHUNK_SIZE / 2;
  493. Block* zB = zBlockAt(location);
  494. if (zB) appendAnimation(zB, boneId, time, pos, rot);
  495. break;
  496. }
  497. }
  498. }
  499. Block* Chunk::zBlockAt(Framework::Vec3<int> location)
  500. {
  501. if (location.z < 0 || location.z >= WORLD_HEIGHT) return 0;
  502. location.x = location.x % CHUNK_SIZE;
  503. location.y = location.y % CHUNK_SIZE;
  504. if (location.x < 0) location.x += CHUNK_SIZE;
  505. if (location.y < 0) location.y += CHUNK_SIZE;
  506. int index
  507. = (location.x * CHUNK_SIZE + location.y) * WORLD_HEIGHT + location.z;
  508. return blocks[index];
  509. }
  510. void Chunk::setBlock(Block* block)
  511. {
  512. cs.lock();
  513. Framework::Vec3<int> pos = block->getLocation();
  514. pos.x = pos.x % CHUNK_SIZE;
  515. pos.y = pos.y % CHUNK_SIZE;
  516. if (pos.x < 0) pos.x += CHUNK_SIZE;
  517. if (pos.y < 0) pos.y += CHUNK_SIZE;
  518. int index = (pos.x * CHUNK_SIZE + pos.y) * WORLD_HEIGHT + pos.z;
  519. int affectsGround = 0;
  520. int newAffectsGround = 0;
  521. for (ChunkModelBuilder* builder : modelBuilders)
  522. {
  523. if (block && builder->isPartOfModel(block))
  524. {
  525. newAffectsGround |= builder->getType();
  526. }
  527. if (blocks[index] && builder->isPartOfModel(blocks[index]))
  528. {
  529. affectsGround |= builder->getType();
  530. }
  531. }
  532. if (blocks[index])
  533. {
  534. vcs.lock();
  535. for (Framework::ArrayIterator<Block*> vi = visibleBlocks.begin(); vi;
  536. vi++)
  537. {
  538. if (blocks[index] == (Block*)vi)
  539. {
  540. vi.remove();
  541. break;
  542. }
  543. }
  544. vcs.unlock();
  545. blocks[index]->copyLightTo(block);
  546. blocks[index]->release();
  547. blocks[index] = block;
  548. cs.unlock();
  549. vcs.lock();
  550. modelChanged |= affectsGround | newAffectsGround;
  551. if (block && block->isVisible() && !newAffectsGround)
  552. {
  553. block->tick(0);
  554. visibleBlocks.add(block);
  555. }
  556. vcs.unlock();
  557. return;
  558. }
  559. blocks[index] = block;
  560. cs.unlock();
  561. vcs.lock();
  562. modelChanged |= affectsGround | newAffectsGround;
  563. if (block && block->isVisible() && !newAffectsGround)
  564. {
  565. block->tick(0);
  566. visibleBlocks.add(block);
  567. }
  568. vcs.unlock();
  569. }
  570. void Chunk::removeBlock(Block* zBlock)
  571. {
  572. cs.lock();
  573. vcs.lock();
  574. for (Framework::ArrayIterator<Block*> iterator = visibleBlocks.begin();
  575. iterator;
  576. iterator++)
  577. {
  578. if (zBlock == (Block*)iterator)
  579. {
  580. iterator.remove();
  581. break;
  582. }
  583. }
  584. vcs.unlock();
  585. Vec3<int> pos = zBlock->getLocation();
  586. pos.x = pos.x % CHUNK_SIZE;
  587. pos.y = pos.y % CHUNK_SIZE;
  588. if (pos.x < 0) pos.x += CHUNK_SIZE;
  589. if (pos.y < 0) pos.y += CHUNK_SIZE;
  590. int index = (pos.x * CHUNK_SIZE + pos.y) * WORLD_HEIGHT + pos.z;
  591. if (blocks[index])
  592. {
  593. modelChanged |= blocks[index]->getPartOfModels();
  594. blocks[index]->release();
  595. blocks[index] = 0;
  596. }
  597. cs.unlock();
  598. }
  599. void Chunk::blockVisibilityChanged(Block* zB)
  600. {
  601. vcs.lock();
  602. if (zB->isVisible())
  603. {
  604. zB->tick(0);
  605. visibleBlocks.add(zB);
  606. }
  607. else
  608. {
  609. for (Framework::ArrayIterator<Block*> iterator = visibleBlocks.begin();
  610. iterator;
  611. iterator++)
  612. {
  613. if (zB == (Block*)iterator)
  614. {
  615. iterator.remove();
  616. break;
  617. }
  618. }
  619. }
  620. vcs.unlock();
  621. }
  622. Framework::Point Chunk::getCenter() const
  623. {
  624. return location;
  625. }
  626. Framework::Vec3<int> Chunk::getMin() const
  627. {
  628. return {location.x - CHUNK_SIZE / 2, location.y - CHUNK_SIZE / 2, 0};
  629. }
  630. Framework::Vec3<int> Chunk::getMax() const
  631. {
  632. return {
  633. location.x + CHUNK_SIZE / 2, location.y + CHUNK_SIZE / 2, WORLD_HEIGHT};
  634. }
  635. void Chunk::setModelChanged(int type)
  636. {
  637. modelChanged |= type;
  638. }
  639. void Chunk::setLightChanged(int type)
  640. {
  641. lightChanged |= type;
  642. }