Clear MeshChunks on Dimension leave.
parent
50af55beee
commit
e0b8651b8a
|
@ -85,6 +85,7 @@ DimensionPtr LocalWorld::getActiveDimension() {
|
|||
}
|
||||
|
||||
void LocalWorld::setActiveDimension(DimensionPtr dim) {
|
||||
this->activeDimension->deactivate();
|
||||
this->activeDimension = dim.l();
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,20 @@
|
|||
LocalDimension::LocalDimension(SubgamePtr game, LocalWorld& world, const std::string& identifier, unsigned int ind) :
|
||||
Dimension(game, static_cast<World&>(world), identifier, ind), meshGenStream(std::make_shared<MeshGenStream>(game, *this)) {}
|
||||
|
||||
|
||||
/**
|
||||
* Deactivates a dimension, cleaning up all mesh chunks.
|
||||
* Called on the active dimension when the player leaves it.
|
||||
*/
|
||||
|
||||
void LocalDimension::deactivate() {
|
||||
while (!renderElems.empty()) {
|
||||
auto chunk = renderElems.front();
|
||||
renderRefs.erase(chunk->getPos());
|
||||
renderElems.pop_front();
|
||||
}
|
||||
}
|
||||
|
||||
void LocalDimension::update(double delta) {
|
||||
finishMeshes();
|
||||
|
||||
|
@ -283,4 +297,4 @@ bool LocalDimension::getAdjacentExists(glm::vec3 pos, bool updateAdjacents) {
|
|||
if (chunk == nullptr) return false;
|
||||
if (updateAdjacents) attemptMeshChunk(chunk, false, false);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -25,6 +25,7 @@ public:
|
|||
|
||||
LocalDimension(SubgamePtr game, LocalWorld& world, const std::string& identifier, unsigned int ind);
|
||||
|
||||
void deactivate();
|
||||
void update(double delta) override;
|
||||
|
||||
void setChunk(std::shared_ptr<Chunk> chunk) override;
|
||||
|
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
@ -10,10 +10,10 @@ zepha.register_entity("zeus:default:test", {
|
|||
self.object.anims:set_anim("walk")
|
||||
self.object.anims:play()
|
||||
|
||||
zepha.after(function()
|
||||
-- zepha.after(function()
|
||||
-- local in_desert = self.object.dimension.identifier == 'zeus:world:endless_desert'
|
||||
-- player:set_dimension(in_desert and "zeus:world:default" or "zeus:world:endless_desert")
|
||||
end, 2)
|
||||
-- end, 2)
|
||||
end,
|
||||
on_update = function(self, delta)
|
||||
self.object.pos = self.object.pos +
|
||||
|
|
Loading…
Reference in New Issue