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 : Technlology Preview 2 :
- Add initial terrain offset so that the (0,0) coordinates are above water (to avoid starting at the middle of a sea). - Rewrite UI in QtQuick, with full-window OpenGL editor.
- Use water height as 0.0 (offset the terrain). - Streamline the definition system, with undo and events.
- Add missing cloud models. - Implement copy-on-write on definitions (to avoid copying whole heightmaps for instance).
- Finish material dialog. - Add clouds to OpenGL with 3d textures.
- Finish texture dialog. - 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 rendering when inside a cloud layer, with other upper or lower layers.
- Fix the moon being backlit by its own light. - 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. - Clouds should keep distance to ground.
- Fully move layer management from BaseForm to BaseFormLayer.
- Allow render saving in HDR compatible format. - Allow render saving in HDR compatible format.
- Add clouds to explorer with 3d textures.
- Add fresnel effect to specular lighting. - Add fresnel effect to specular lighting.
- Add shadow control ("minimum lighting") to material. - Add shadow control ("minimum lighting") to material.
- Start using OpenCL to optimize rendering. - 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 : Technology Preview 4 :
- Implement Sub Surface Scattering for water, textures and clouds. - Implement Sub Surface Scattering for water, textures and clouds.
- Implement earth curvature. - Implement earth curvature.
- Use bicubic interpolation for antialiasing. - Use bicubic interpolation for antialiasing.
- Allow for larger renders/antialias (will need several two-pass chunks). - Add translations.
- Add a progress indicator on previews. - Find a new licence.
- 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.
Release Candidate : Release Candidate :
- Polish all features and UI. - Polish all features and UI.

View file

@ -24,7 +24,9 @@ BaseDefinition::~BaseDefinition()
parent = NULL; 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) if (child->getParent() == this)
{ {

View file

@ -28,6 +28,7 @@ public:
inline const BaseDefinition* getParent() const {return parent;} inline const BaseDefinition* getParent() const {return parent;}
inline const BaseDefinition* getRoot() const {return root;} 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). * Return a string representation of the tree (mainly for debugging purposes).

View file

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

View file

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

View file

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

View file

@ -12,3 +12,24 @@ TEST(BaseDefinition, toString)
EXPECT_EQ("root\n branch\n leaf1\n leaf2", root.toString()); EXPECT_EQ("root\n branch\n leaf1\n leaf2", root.toString());
EXPECT_EQ("branch\n leaf1\n leaf2", branch.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;
}