44#include  " WorldOctreeNode.hpp" 
55#include  " MeshProcessor.hpp" 
66#include  " DefaultOptions.h" 
7+ #include  " DMCChunk.hpp" 
78#include  < iostream> 
89
910ChunkGenerator::ChunkGenerator () : ThreadDebug(" ChunkGenerator"  )
@@ -34,16 +35,17 @@ void ChunkGenerator::process_queue(SmartContainer<WorldOctreeNode*>& batch)
3435}
3536}
3637
37- extract_samples (batch, &binary_allocator, &float_allocator);
38+ extract_chunk (batch);
39+ /* extract_samples(batch);
3840extract_dual_vertices(batch); 
3941extract_octrees(batch); 
4042extract_base_meshes(batch); 
41- extract_format_meshes (batch);
43+ extract_format_meshes(batch);*/  
4244
43- for  (int  i = 0 ; i < count; i++)
45+ /* for (int i = 0; i < count; i++)
4446{ 
4547batch[i]->generation_stage = GENERATION_STAGES_NEEDS_UPLOAD; 
46- }
48+ }*/  
4749
4850/* if (stitcher.stage == STITCHING_STAGES_READY)
4951{ 
@@ -74,7 +76,50 @@ void ChunkGenerator::generate_chunk(WorldOctreeNode* n)
7476world->create_chunk (n);
7577}
7678
77- void  ChunkGenerator::extract_samples (SmartContainer<class  WorldOctreeNode *>& batch, ResourceAllocator<BinaryBlock>* binary_allocator, ResourceAllocator<FloatBlock>* float_allocator)
79+ void  ChunkGenerator::extract_chunk (SmartContainer<class  WorldOctreeNode *>& batch)
80+ {
81+ int  count = (int )batch.count ;
82+ int  i;
83+ #pragma  omp parallel for
84+ for  (i = 0 ; i < count; i++)
85+ {
86+ if  (batch[i]->generation_stage  == GENERATION_STAGES_GENERATING)
87+ {
88+ if  (update_still_needed (batch[i]))
89+ {
90+ batch[i]->chunk ->label_grid (&binary_allocator, &isovertex_allocator, &noise_allocator);
91+ 
92+ batch[i]->chunk ->label_edges (&vi_allocator, &cell_allocator, &inds_allocator, &isovertex_allocator);
93+ 
94+ batch[i]->chunk ->generate_octree ();
95+ if  (!batch[i]->chunk ->octree .is_leaf ())
96+ {
97+ memcpy (batch[i]->children , batch[i]->chunk ->octree .children , sizeof (OctreeNode*) * 8 );
98+ batch[i]->leaf_flag  = false ;
99+ }
100+ 
101+ batch[i]->chunk ->polygonize ();
102+ 
103+ binary_allocator.free_element (batch[i]->chunk ->binary_block );
104+ batch[i]->chunk ->binary_block  = 0 ;
105+ isovertex_allocator.free_element (batch[i]->chunk ->density_block );
106+ batch[i]->chunk ->density_block  = 0 ;
107+ cell_allocator.free_element (batch[i]->chunk ->cell_block );
108+ batch[i]->chunk ->cell_block  = 0 ;
109+ inds_allocator.free_element (batch[i]->chunk ->indexes_block );
110+ batch[i]->chunk ->indexes_block  = 0 ;
111+ }
112+ }
113+ 
114+ batch[i]->format (&world->gl_allocator );
115+ 
116+ batch[i]->generation_stage  = GENERATION_STAGES_NEEDS_UPLOAD;
117+ }
118+ 
119+ 
120+ }
121+ 
122+ void  ChunkGenerator::extract_samples (SmartContainer<class  WorldOctreeNode *>& batch)
78123{
79124using  namespace  std ; 
80125// cout << "-Generating samples...";
@@ -87,8 +132,10 @@ void ChunkGenerator::extract_samples(SmartContainer<class WorldOctreeNode*>& bat
87132{
88133if  (batch[i]->generation_stage  == GENERATION_STAGES_GENERATING)
89134{
90- if (update_still_needed (batch[i]))
91- batch[i]->chunk ->generate_samples (binary_allocator, float_allocator);
135+ if  (update_still_needed (batch[i]))
136+ {
137+ batch[i]->chunk ->label_grid (&binary_allocator, &isovertex_allocator, &noise_allocator);
138+ }
92139}
93140}
94141
@@ -111,8 +158,8 @@ void ChunkGenerator::extract_filter(SmartContainer<WorldOctreeNode*>& batch)
111158#pragma  omp parallel for
112159for  (i = 0 ; i < count; i++)
113160{
114- if  (batch[i]->generation_stage  == GENERATION_STAGES_GENERATING)
115- batch[i]->chunk ->filter ();
161+ // if (batch[i]->generation_stage == GENERATION_STAGES_GENERATING)
162+ // batch[i]->chunk->filter();
116163}
117164
118165double  ms = clock () - start_clock;
@@ -132,7 +179,7 @@ void ChunkGenerator::extract_dual_vertices(SmartContainer<WorldOctreeNode*>& bat
132179for  (int  i = 0 ; i < count; i++)
133180{
134181if  (batch[i]->generation_stage  == GENERATION_STAGES_GENERATING)
135- batch[i]->chunk ->generate_dual_vertices (&vi_allocator, &cell_allocator, &inds_allocator, &float_allocator );
182+ batch[i]->chunk ->label_edges (&vi_allocator, &cell_allocator, &inds_allocator, &isovertex_allocator );
136183}
137184}
138185
@@ -160,8 +207,8 @@ void ChunkGenerator::extract_octrees(SmartContainer<WorldOctreeNode*>& batch)
160207memcpy (batch[i]->children , batch[i]->chunk ->octree .children , sizeof (OctreeNode*) * 8 );
161208batch[i]->leaf_flag  = false ;
162209}
163- else 
164- cout << " WARNING: Octree is leaf."   << endl;
210+ // else
211+ // cout << "WARNING: Octree is leaf." << endl;
165212}
166213}
167214}
@@ -188,11 +235,11 @@ void ChunkGenerator::extract_base_meshes(SmartContainer<WorldOctreeNode*>& batch
188235{
189236if  (batch[i]->generation_stage  == GENERATION_STAGES_GENERATING)
190237{
191- batch[i]->chunk ->generate_base_mesh (&vi_allocator); 
238+ batch[i]->chunk ->polygonize (); 
192239if  (!iters || !batch[i]->chunk ->contains_mesh  || !batch[i]->chunk ->vi ->vertices .count  || !batch[i]->chunk ->vi ->mesh_indexes .count )
193240continue ;
194241
195- auto & v_out = batch[i]->chunk ->vi ->vertices ;
242+ /* auto& v_out = batch[i]->chunk->vi->vertices;
196243auto& i_out = batch[i]->chunk->vi->mesh_indexes; 
197244Processing::MeshProcessor<4> mp(true, SMOOTH_NORMALS); 
198245mp.init(batch[i]->chunk->vi->vertices, batch[i]->chunk->vi->mesh_indexes, sampler); 
@@ -222,8 +269,8 @@ void ChunkGenerator::extract_base_meshes(SmartContainer<WorldOctreeNode*>& batch
222269v_out.count = 0; 
223270i_out.count = 0; 
224271mp.flush(v_out, i_out); 
225- }
226- 
272+ }*/  
273+ 
227274}
228275}
229276}
0 commit comments