Fixed some memory issues

This commit is contained in:
Michaël Lemaire 2015-08-12 19:29:28 +02:00
parent 44c03e46a9
commit 6f8e0c3cfd
7 changed files with 44 additions and 48 deletions

54
TODO
View file

@ -1,58 +1,26 @@
Technology Preview 2 :
- Add initial terrain offset so that the (0,0) coordinates are above water (to avoid starting at the middle of a sea).
- Use water height as 0.0 (offset the terrain).
- Add missing cloud models.
- Finish material dialog.
- Finish texture dialog.
Technlology Preview 2 :
- Rewrite UI in QtQuick, with full-window OpenGL editor.
- Streamline the definition system, with undo and events.
- Implement copy-on-write on definitions (to avoid copying whole heightmaps for instance).
- Add clouds to OpenGL with 3d textures.
- Fix potential holes in land rendering (OpenGL and software).
Technology Preview 3 :
- Alter aerial perspective using estimation of the amount of light left after cloud layers traversal.
- Fix rendering when inside a cloud layer, with other upper or lower layers.
- Fix the moon being backlit by its own light.
- Translations.
Technlogy Preview 3 :
- FOCUS : Streamlining, with undo system
- FOCUS : Vegetation
- Implement copy-on-write on definitions (to avoid copying whole heightmaps for instance).
- Alter aerial perspective using estimation of the amount of light left after cloud layers traversal.
- Add a map preview to terrain editor.
- Better time selection widget for atmosphere.
- Clouds should keep distance to ground.
- Fully move layer management from BaseForm to BaseFormLayer.
- Allow render saving in HDR compatible format.
- Add clouds to explorer with 3d textures.
- Add fresnel effect to specular lighting.
- Add shadow control ("minimum lighting") to material.
- Start using OpenCL to optimize rendering.
- Fully restore render progress (with first pass).
- Rethink the quality settings and detail smoothing in the distance.
=> When quality setting is set to 10, add boost options
=> Add detail boost (adds granularity)
=> Add step boost (for marching algorithms)
- Add logarithmic sliders for some float values.
- Improve previews.
=> Add user markers on OSD.
=> Add areas marking.
- Add a noise automatic filler.
- Lock some previews together (eg: terrain height and colored preview).
- Find a new licence.
Technology Preview 4 :
- Implement Sub Surface Scattering for water, textures and clouds.
- Implement earth curvature.
- Use bicubic interpolation for antialiasing.
- Allow for larger renders/antialias (will need several two-pass chunks).
- Add a progress indicator on previews.
- Mark modified tabs and ask for losing modifications (idem for layers).
- Fix potential holes in land rendering.
- Progressive final render (increasing resolution, for second pass only).
- Improve 3d explorer
=> Restore LOD and intelligent poly count (and raise max tessellation)
=> Better handling of high altitude
=> Interrupt chunk rendering when quitting dialog
=> Don't display the water if it's below all ground
=> Try to overcome the near frustum cutting
=> Add toggles (for water...)
=> Max texture size should depend on GPU memory available
- Interrupt preview chunk renderings that will be discarded at commit, or that are no more visible.
- Add translations.
- Find a new licence.
Release Candidate :
- Polish all features and UI.

View file

@ -24,7 +24,9 @@ BaseDefinition::~BaseDefinition()
parent = NULL;
}
for (auto child:children)
// Work on a copy, because the child destructor will modify the array by removing itself using removeChild
std::vector<BaseDefinition*> children_copy = children;
for (auto child:children_copy)
{
if (child->getParent() == this)
{

View file

@ -28,6 +28,7 @@ public:
inline const BaseDefinition* getParent() const {return parent;}
inline const BaseDefinition* getRoot() const {return root;}
inline int getChildrenCount() const {return children.size();}
/**
* Return a string representation of the tree (mainly for debugging purposes).

View file

@ -92,6 +92,7 @@ int Layers::addLayer(BaseDefinition* layer)
else
{
logWarning("Add layer ignored because limit of %d reached", max_layer_count);
delete layer;
return -1;
}
}

View file

@ -6,14 +6,14 @@
PaintedGridData::PaintedGridData()
{
rows_count = 0;
rows = new HeightMapRow[1];
rows = (HeightMapRow *)malloc(sizeof(HeightMapRow));
memsize = 0;
}
PaintedGridData::~PaintedGridData()
{
clear();
delete[] rows;
free(rows);
}
void PaintedGridData::copy(PaintedGridData *destination) const
@ -119,7 +119,7 @@ void PaintedGridData::clear()
free(rows[i].pixel_groups);
}
rows_count = 0;
delete[] rows;
rows = new HeightMapRow[1];
free(rows);
rows = (HeightMapRow *)malloc(sizeof(HeightMapRow));
memsize = 0;
}

View file

@ -14,6 +14,9 @@ TextureLayerDefinition::TextureLayerDefinition(BaseDefinition* parent):
_displacement_noise = new NoiseGenerator;
_detail_noise = new NoiseGenerator;
material = new SurfaceMaterial;
displacement_height = 0.0;
displacement_scaling = 1.0;
}
TextureLayerDefinition::~TextureLayerDefinition()

View file

@ -12,3 +12,24 @@ TEST(BaseDefinition, toString)
EXPECT_EQ("root\n branch\n leaf1\n leaf2", root.toString());
EXPECT_EQ("branch\n leaf1\n leaf2", branch.toString());
}
TEST(BaseDefinition, attachDetach)
{
BaseDefinition* root = new BaseDefinition(NULL, "root");
BaseDefinition* child1 = new BaseDefinition(root, "child1");
BaseDefinition* child2 = new BaseDefinition(root, "child2");
EXPECT_EQ(root, child1->getParent());
EXPECT_EQ(root, child2->getParent());
EXPECT_EQ(2, root->getChildrenCount());
delete child1;
EXPECT_EQ(1, root->getChildrenCount());
delete child2;
EXPECT_EQ(0, root->getChildrenCount());
delete root;
}