@@ -150,17 +150,11 @@ RenderObjClass * W3DPrototypeClass::Create(void)
150150// ---------------------------------------------------------------------
151151W3DAssetManager::W3DAssetManager (void )
152152{
153- #ifdef INCLUDE_GRANNY_IN_BUILD
154- m_GrannyAnimManager = NEW GrannyAnimManagerClass;
155- #endif
156153}
157154
158155// ---------------------------------------------------------------------
159156W3DAssetManager::~W3DAssetManager (void )
160157{
161- #ifdef INCLUDE_GRANNY_IN_BUILD
162- delete m_GrannyAnimManager;
163- #endif
164158}
165159
166160#ifdef DUMP_PERF_STATS
@@ -700,12 +694,6 @@ RenderObjClass * W3DAssetManager::Create_Render_Obj(
700694 GetPrecisionTimer (&startTime64);
701695 #endif
702696
703- #ifdef INCLUDE_GRANNY_IN_BUILD
704- Bool isGranny = false ;
705- char *pext=strrchr (name,' .' ); // find file extension
706- if (pext)
707- isGranny=(strnicmp (pext," .GR2" ,4 ) == 0 );
708- #endif
709697 Bool reallyscale = (WWMath::Fabs (scale - ident_scale) > scale_epsilon);
710698 Bool reallycolor = (color & 0xFFFFFF ) != 0 ; // black is not a valid color and assumes no custom coloring.
711699 Bool reallytexture = (oldTexture != NULL && newTexture != NULL );
@@ -727,24 +715,13 @@ RenderObjClass * W3DAssetManager::Create_Render_Obj(
727715 // see if we got a cached version
728716 RenderObjClass *rendobj = NULL ;
729717
730- #ifdef INCLUDE_GRANNY_IN_BUILD
731- if (isGranny)
732- { // Granny objects share the same prototype since they allow instance scaling.
733- strcpy (newname,name); // use same name for all granny objects at any scale.
734- }
735- #endif
736718 Set_WW3D_Load_On_Demand (false ); // munged name will never be found in a file.
737719 rendobj = WW3DAssetManager::Create_Render_Obj (newname);
738720 if (rendobj)
739721 { // store the color that we used to create asset so we can read it back out
740722 // when we need to save this render object to a file. Used during saving
741723 // of fog of war ghost objects.
742724 rendobj->Set_ObjectColor (color);
743- #ifdef INCLUDE_GRANNY_IN_BUILD
744- if (isGranny)
745- // /@todo Granny objects are realtime scaled - fix to scale like W3D.
746- rendobj->Set_ObjectScale (scale);
747- #endif
748725 Set_WW3D_Load_On_Demand (true ); // Auto Load.
749726
750727 #ifdef DUMP_PERF_STATS
@@ -767,16 +744,11 @@ RenderObjClass * W3DAssetManager::Create_Render_Obj(
767744 {
768745 // If we didn't find one, try to load on demand
769746 char filename [MAX_PATH];
770- const char *mesh_name = :: strchr (name, ' .' );
747+ const char *mesh_name = strchr (name, ' .' );
771748 if (mesh_name != NULL )
772749 {
773- ::lstrcpyn (filename, name, ((int )mesh_name) - ((int )name) + 1);
774- #ifdef INCLUDE_GRANNY_IN_BUILD
775- if (isGranny)
776- ::lstrcat (filename, " .gr2" );
777- else
778- #endif
779- ::lstrcat (filename, " .w3d" );
750+ lstrcpyn (filename, name, ((int )mesh_name) - ((int )name) + 1 );
751+ lstrcat (filename, " .w3d" );
780752 } else {
781753 sprintf ( filename, " %s.w3d" , name);
782754 }
@@ -785,15 +757,7 @@ RenderObjClass * W3DAssetManager::Create_Render_Obj(
785757 if ( Load_3D_Assets ( filename ) == false )
786758 {
787759 StringClass new_filename = StringClass (" ..\\ " ) + filename;
788- if (Load_3D_Assets ( new_filename ) == false )
789- {
790- #ifdef INCLUDE_GRANNY_IN_BUILD
791- char *mesh_name = ::strchr (filename, ' .' );
792- ::lstrcpyn (mesh_name, " .gr2" ,5 );
793- Load_3D_Assets ( filename );
794- isGranny=true ;
795- #endif
796- }
760+ Load_3D_Assets ( new_filename );
797761 }
798762
799763 proto = Find_Prototype (name); // try again
@@ -823,33 +787,21 @@ RenderObjClass * W3DAssetManager::Create_Render_Obj(
823787 #endif
824788 return NULL ;
825789 }
826- #ifdef INCLUDE_GRANNY_IN_BUILD
827- if (!isGranny)
828- #endif
829- {
830- Make_Unique (rendobj,reallyscale,reallycolor);
831- if (reallytexture)
832- {
833- TextureClass *oldTex = Get_Texture (oldTexture);
834- TextureClass *newTex = Get_Texture (newTexture);
835- replaceAssetTexture (rendobj,oldTex,newTex);
836- REF_PTR_RELEASE (newTex);
837- REF_PTR_RELEASE (oldTex);
838- }
839- if (reallyscale)
840- rendobj->Scale (scale);
841790
842- if (reallycolor)
843- Recolor_Asset (rendobj,color);
844- }
845- #ifdef INCLUDE_GRANNY_IN_BUILD
846- else
791+ Make_Unique (rendobj,reallyscale,reallycolor);
792+ if (reallytexture)
847793 {
848- // /@todo Granny objects are realtime scaled - fix to scale like W3D.
849- rendobj->Set_ObjectScale (scale);
850- return rendobj;
794+ TextureClass *oldTex = Get_Texture (oldTexture);
795+ TextureClass *newTex = Get_Texture (newTexture);
796+ replaceAssetTexture (rendobj,oldTex,newTex);
797+ REF_PTR_RELEASE (newTex);
798+ REF_PTR_RELEASE (oldTex);
851799 }
852- #endif
800+ if (reallyscale)
801+ rendobj->Scale (scale);
802+
803+ if (reallycolor)
804+ Recolor_Asset (rendobj,color);
853805
854806 W3DPrototypeClass *w3dproto = newInstance (W3DPrototypeClass)(rendobj, newname);
855807 rendobj->Release_Ref ();
@@ -986,14 +938,6 @@ bool W3DAssetManager::Load_3D_Assets( const char * filename )
986938 GetPrecisionTimer (&startTime64);
987939#endif
988940
989- #ifdef INCLUDE_GRANNY_IN_BUILD
990- Bool isGranny = false ;
991- char *pext=strrchr (filename,' .' ); // find file extension
992- if (pext)
993- isGranny=(strnicmp (pext," .GR2" ,4 ) == 0 );
994- if (!isGranny)
995- #endif
996-
997941 // Try to find an existing prototype
998942 char basename[512 ];
999943 strcpy (basename, filename);
@@ -1038,40 +982,6 @@ bool W3DAssetManager::Load_3D_Assets( const char * filename )
1038982#endif
1039983 return result;
1040984
1041- #ifdef INCLUDE_GRANNY_IN_BUILD
1042- // Loading assets for Granny File
1043- PrototypeClass * newproto = NULL ;
1044- newproto = _GrannyLoader.Load_W3D (filename);
1045- /*
1046- ** Now, see if the prototype that we loaded has a duplicate
1047- ** name with any of our currently loaded prototypes (can't have that!)
1048- */
1049- if (newproto != NULL ) {
1050- if (!Render_Obj_Exists (newproto->Get_Name ())) {
1051- /*
1052- ** Add the new, unique prototype to our list
1053- */
1054- Add_Prototype (newproto);
1055- } else {
1056- /*
1057- ** Warn the user about a name collision with this prototype
1058- ** and dump it
1059- */
1060- WWDEBUG_SAY ((" Render Object Name Collision: %s\r\n " ,newproto->Get_Name ()));
1061- delete newproto;
1062- newproto = NULL ;
1063- return false ;
1064- }
1065- } else {
1066- /*
1067- ** Warn user that a prototype was not generated from this
1068- ** chunk type
1069- */
1070- WWDEBUG_SAY ((" Could not generate Granny prototype! File = %d\r\n " ,filename));
1071- return false ;
1072- }
1073- return true ;
1074- #endif
1075985}
1076986
1077987#ifdef DUMP_PERF_STATS
@@ -1089,47 +999,17 @@ HAnimClass * W3DAssetManager::Get_HAnim(const char * name)
1089999#endif
10901000 WWPROFILE ( " WW3DAssetManager::Get_HAnim" );
10911001
1092- #ifdef INCLUDE_GRANNY_IN_BUILD
1093- Bool isGranny = false ;
1094- char *pext=strrchr (name,' .' ); // find file extension
1095- if (pext)
1096- isGranny=(strnicmp (pext," .GR2" ,4 ) == 0 );
1097- if (!isGranny)
1098- #endif
1099- {
1100- HAnimClass *anim=WW3DAssetManager::Get_HAnim (name); // we only do custom granny processing.
1002+ HAnimClass *anim=WW3DAssetManager::Get_HAnim (name);
11011003#ifdef DUMP_PERF_STATS
1102- if (HAnim_Recursions == 1 )
1103- {
1104- GetPrecisionTimer (&endTime64);
1105- Total_Get_HAnim_Time += endTime64-startTime64;
1106- }
1107- HAnim_Recursions--;
1108- #endif
1109- return anim;
1110- }
1111-
1112- #ifdef INCLUDE_GRANNY_IN_BUILD
1113- // Try to find the hanim
1114- HAnimClass * anim = m_GrannyAnimManager->Get_Anim (name);
1115- if (WW3D_Load_On_Demand && anim == NULL ) { // If we didn't find it, try to load on demand
1116- if ( !m_GrannyAnimManager->Is_Missing ( name ) ) { // if this is NOT a known missing anim
1117-
1118- // If we can't find it, try the parent directory
1119- if ( m_GrannyAnimManager->Load_Anim (name) == 1 ) {
1120- StringClass new_filename = StringClass (" ..\\ " ) + name;
1121- m_GrannyAnimManager->Load_Anim ( new_filename );
1122- }
1123-
1124- anim = m_GrannyAnimManager->Get_Anim (name); // Try again
1125- if (anim == NULL ) {
1126- // WWDEBUG_SAY(("WARNING: Animation %s not found!\n", name));
1127- m_GrannyAnimManager->Register_Missing ( name ); // This is now a KNOWN missing anim
1128- }
1129- }
1004+ if (HAnim_Recursions == 1 )
1005+ {
1006+ GetPrecisionTimer (&endTime64);
1007+ Total_Get_HAnim_Time += endTime64-startTime64;
11301008 }
1131- return anim ;
1009+ HAnim_Recursions-- ;
11321010#endif
1011+ return anim;
1012+
11331013}
11341014
11351015// ---------------------------------------------------------------------
@@ -1420,11 +1300,6 @@ static inline void Munge_Texture_Name(char *newname, const char *oldname, const
14201300RenderObjClass * W3DAssetManager::Create_Render_Obj(const char * name,float scale, const Vector3 &hsv_shift)
14211301{
14221302 Bool isGranny = false;
1423- #ifdef INCLUDE_GRANNY_IN_BUILD
1424- char *pext=strrchr(name,'.'); //find file extension
1425- if (pext)
1426- isGranny=(strnicmp(pext,".GR2",4) == 0);
1427- #endif
14281303 Bool reallyscale = (WWMath::Fabs(scale - ident_scale) > scale_epsilon);
14291304 Bool reallyhsv_shift = (WWMath::Fabs(hsv_shift.X - ident_HSV.X) > H_epsilon ||
14301305 WWMath::Fabs(hsv_shift.Y - ident_HSV.Y) > S_epsilon || WWMath::Fabs(hsv_shift.Z - ident_HSV.Z) > V_epsilon);
0 commit comments