From a2be88ad741a1c2eb4279d39c18a4872accd3470 Mon Sep 17 00:00:00 2001 From: david Date: Sat, 29 Dec 2001 13:19:09 +0000 Subject: [PATCH] Initialization fixes. --- src/Objects/newmat.cxx | 39 +++++++++++++++++++-------------------- src/Objects/newmat.hxx | 13 ++++++++++++- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/src/Objects/newmat.cxx b/src/Objects/newmat.cxx index 39da01c39..d2b1674e4 100644 --- a/src/Objects/newmat.cxx +++ b/src/Objects/newmat.cxx @@ -52,42 +52,41 @@ local_file_exists( const string& path ) { } -// Constructor - -FGNewMat::FGNewMat () - : texture_path(""), - state(0), - textured(0), - nontextured(0), - alpha(false), - xsize(0), - ysize(0), - wrapu(true), - wrapv(true), - mipmap(true), - texture_loaded(false), - refcount(0) +void +FGNewMat::init () { - for (int i = 0; i < 4; i++) - ambient[i] = diffuse[i] = specular[i] = emission[i] = 0.0; + texture_path = ""; + state = 0; + textured = 0; + nontextured = 0; + alpha = false; + xsize = 0; + ysize = 0; + wrapu = true; + wrapv = true; + mipmap = true; + texture_loaded = false; + refcount = 0; + for (int i = 0; i < 4; i++) + ambient[i] = diffuse[i] = specular[i] = emission[i] = 0.0; } FGNewMat::FGNewMat (const SGPropertyNode * props) { - FGNewMat(); + init(); read_properties(props); build_ssg_state(false); } FGNewMat::FGNewMat (const string &texture_path) { - FGNewMat(); + init(); build_ssg_state(true); } FGNewMat::FGNewMat (ssgSimpleState * s) { - FGNewMat(); + init(); set_ssg_state(s); } diff --git a/src/Objects/newmat.hxx b/src/Objects/newmat.hxx index 28199619e..0aaee654f 100644 --- a/src/Objects/newmat.hxx +++ b/src/Objects/newmat.hxx @@ -170,6 +170,18 @@ public: */ virtual inline int getRef() const { return refcount; } +protected: + + + //////////////////////////////////////////////////////////////////// + // Protected methods. + //////////////////////////////////////////////////////////////////// + + /** + * Initialization method, invoked by all public constructors. + */ + virtual void init(); + private: @@ -217,7 +229,6 @@ private: // Internal constructors and methods. //////////////////////////////////////////////////////////////////// - FGNewMat (); FGNewMat (const FGNewMat &mat); // unimplemented void read_properties (const SGPropertyNode * props); -- 2.39.5