1
0
Fork 0

Changes from NHV to make the code more dynamic with fewer hard coded limits.

This commit is contained in:
curt 1998-10-12 23:49:17 +00:00
parent 71b78dc87c
commit 18b093927f
2 changed files with 32 additions and 13 deletions

View file

@ -55,8 +55,8 @@ fgMATERIAL_MGR material_mgr;
// Constructor // Constructor
fgMATERIAL::fgMATERIAL ( void ) fgMATERIAL::fgMATERIAL ( void )
: texture_name(""), : texture_name(""),
alpha(0), alpha(0)
list_size(0) // , list_size(0)
{ {
ambient[0] = ambient[1] = ambient[2] = ambient[3] = 0.0; ambient[0] = ambient[1] = ambient[2] = ambient[3] = 0.0;
diffuse[0] = diffuse[1] = diffuse[2] = diffuse[3] = 0.0; diffuse[0] = diffuse[1] = diffuse[2] = diffuse[3] = 0.0;
@ -64,7 +64,7 @@ fgMATERIAL::fgMATERIAL ( void )
emissive[0] = emissive[1] = emissive[2] = emissive[3] = 0.0; emissive[0] = emissive[1] = emissive[2] = emissive[3] = 0.0;
} }
/*
int int
fgMATERIAL::append_sort_list( fgFRAGMENT *object ) fgMATERIAL::append_sort_list( fgFRAGMENT *object )
{ {
@ -75,6 +75,7 @@ fgMATERIAL::append_sort_list( fgFRAGMENT *object )
return 0; return 0;
} }
} }
*/
istream& istream&
operator >> ( istream& in, fgMATERIAL& m ) operator >> ( istream& in, fgMATERIAL& m )
@ -248,9 +249,11 @@ fgMATERIAL::render_fragments()
} }
fgTILE* last_tile_ptr = NULL; fgTILE* last_tile_ptr = NULL;
for ( size_t i = 0; i < list_size; ++i ) frag_list_iterator current = list.begin();
{ frag_list_iterator last = list.end();
fgFRAGMENT* frag_ptr = list[i];
for ( ; current != last; ++current ) {
fgFRAGMENT* frag_ptr = *current;
current_view.tris_rendered += frag_ptr->num_faces(); current_view.tris_rendered += frag_ptr->num_faces();
if ( frag_ptr->tile_ptr != last_tile_ptr ) if ( frag_ptr->tile_ptr != last_tile_ptr )
{ {
@ -354,6 +357,9 @@ fgMATERIAL_MGR::render_fragments()
// $Log$ // $Log$
// Revision 1.8 1998/10/12 23:49:17 curt
// Changes from NHV to make the code more dynamic with fewer hard coded limits.
//
// Revision 1.7 1998/09/17 18:35:52 curt // Revision 1.7 1998/09/17 18:35:52 curt
// Tweaks and optimizations by Norman Vine. // Tweaks and optimizations by Norman Vine.
// //

View file

@ -48,6 +48,7 @@ extern "C" void *memset(void *, int, size_t);
#include <string> // Standard C++ string library #include <string> // Standard C++ string library
#include <map> // STL associative "array" #include <map> // STL associative "array"
#include <vector> // STL "array"
#ifdef NEEDNAMESPACESTD #ifdef NEEDNAMESPACESTD
using namespace std; using namespace std;
@ -57,7 +58,13 @@ using namespace std;
class fgFRAGMENT; class fgFRAGMENT;
#define FG_MAX_MATERIAL_FRAGS 800 // convenience types
typedef vector < fgFRAGMENT * > frag_list_type;
typedef frag_list_type::iterator frag_list_iterator;
typedef frag_list_type::const_iterator frag_list_const_iterator;
// #define FG_MAX_MATERIAL_FRAGS 800
// Material property class // Material property class
@ -79,23 +86,26 @@ private:
// transient list of objects with this material type (used for sorting // transient list of objects with this material type (used for sorting
// by material to reduce GL state changes when rendering the scene // by material to reduce GL state changes when rendering the scene
fgFRAGMENT * list[FG_MAX_MATERIAL_FRAGS]; frag_list_type list;
size_t list_size; // size_t list_size;
public: public:
// Constructor // Constructor
fgMATERIAL ( void ); fgMATERIAL ( void );
size_t size() const { return list_size; } int size() const { return list.size(); }
bool empty() const { return list_size == 0; } bool empty() const { return list.size() == 0; }
// Sorting routines // Sorting routines
void init_sort_list( void ) { void init_sort_list( void ) {
list_size = 0; list.erase( list.begin(), list.end() );
} }
int append_sort_list( fgFRAGMENT *object ); bool append_sort_list( fgFRAGMENT *object ) {
list.push_back( object );
return true;
}
void render_fragments(); void render_fragments();
@ -160,6 +170,9 @@ extern fgMATERIAL_MGR material_mgr;
// $Log$ // $Log$
// Revision 1.5 1998/10/12 23:49:18 curt
// Changes from NHV to make the code more dynamic with fewer hard coded limits.
//
// Revision 1.4 1998/09/17 18:35:53 curt // Revision 1.4 1998/09/17 18:35:53 curt
// Tweaks and optimizations by Norman Vine. // Tweaks and optimizations by Norman Vine.
// //