Skip to content

Commit 9305ad0

Browse files
committed
unify(ww3d2): Equalize files between Zero Hour and Generals in WW3d2
1 parent 54b8765 commit 9305ad0

File tree

25 files changed

+194
-65
lines changed

25 files changed

+194
-65
lines changed

Generals/Code/Libraries/Source/WWVegas/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ add_subdirectory(WWAudio)
1919
add_subdirectory(WW3D2)
2020
add_subdirectory(WWDownload)
2121

22+
target_link_libraries(g_ww3d2 PRIVATE
23+
gi_always
24+
)
25+
2226
# Helpful interface to bundle the ww modules together.
2327
add_library(g_wwvegas INTERFACE)
2428

Generals/Code/Libraries/Source/WWVegas/WW3D2/animobj.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** Command & Conquer Generals(tm)
2+
** Command & Conquer Generals Zero Hour(tm)
33
** Copyright 2025 Electronic Arts Inc.
44
**
55
** This program is free software: you can redistribute it and/or modify
@@ -26,9 +26,9 @@
2626
* *
2727
* Author:: Greg_h *
2828
* *
29-
* $Modtime:: 8/28/01 12:12p $*
29+
* $Modtime:: 12/13/01 6:56p $*
3030
* *
31-
* $Revision:: 7 $*
31+
* $Revision:: 10 $*
3232
* *
3333
*---------------------------------------------------------------------------------------------*
3434
* Functions: *
@@ -498,7 +498,6 @@ void Animatable3DObjClass::Set_Animation(HAnimClass * motion, float frame, int m
498498
Set_Hierarchy_Valid(false);
499499
}
500500

501-
502501
/***********************************************************************************************
503502
* Animatable3DObjClass::Set_Animation -- set the animation state to a blend of two anims *
504503
* *
@@ -869,8 +868,10 @@ bool Animatable3DObjClass::Simple_Evaluate_Bone(int boneindex, Matrix3D *tm) con
869868
//
870869
// Only do this for simple animations
871870
//
872-
if (CurMotionMode == SINGLE_ANIM) {
873-
871+
if ( CurMotionMode == NONE ||
872+
CurMotionMode == BASE_POSE ||
873+
CurMotionMode == SINGLE_ANIM)
874+
{
874875
//
875876
// Determine which frame we should be on, then use this
876877
// information to determine the bone's transform.
@@ -880,7 +881,8 @@ bool Animatable3DObjClass::Simple_Evaluate_Bone(int boneindex, Matrix3D *tm) con
880881

881882
} else {
882883

883-
*tm = Transform;
884+
const_cast <Animatable3DObjClass *>(this)->Update_Sub_Object_Transforms();
885+
*tm = HTree->Get_Transform(boneindex);
884886

885887
}
886888

@@ -909,9 +911,15 @@ bool Animatable3DObjClass::Simple_Evaluate_Bone(int boneindex, float frame, Matr
909911
// Only do this for simple animations
910912
//
911913
if (HTree != NULL) {
914+
912915
if (CurMotionMode == SINGLE_ANIM) {
913916
retval = HTree->Simple_Evaluate_Pivot (ModeAnim.Motion, boneindex, frame, Get_Transform (), tm);
917+
} else if (CurMotionMode == NONE || CurMotionMode == BASE_POSE) {
918+
retval = HTree->Simple_Evaluate_Pivot (boneindex, Get_Transform (), tm);
919+
} else {
920+
*tm = Transform;
914921
}
922+
915923
} else {
916924
*tm = Transform;
917925
}

Generals/Code/Libraries/Source/WWVegas/WW3D2/animobj.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** Command & Conquer Generals(tm)
2+
** Command & Conquer Generals Zero Hour(tm)
33
** Copyright 2025 Electronic Arts Inc.
44
**
55
** This program is free software: you can redistribute it and/or modify

Generals/Code/Libraries/Source/WWVegas/WW3D2/boxrobj.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** Command & Conquer Generals(tm)
2+
** Command & Conquer Generals Zero Hour(tm)
33
** Copyright 2025 Electronic Arts Inc.
44
**
55
** This program is free software: you can redistribute it and/or modify
@@ -460,7 +460,7 @@ void BoxRenderObjClass::render_box(RenderInfoClass & rinfo,const Vector3 & cente
460460
*/
461461
DWORD color = DX8Wrapper::Convert_Color(Color,Opacity);
462462

463-
int buffer_type = BUFFER_TYPE_DYNAMIC_SORTING;
463+
int buffer_type = BUFFER_TYPE_DYNAMIC_DX8;
464464

465465
DynamicVBAccessClass vbaccess(buffer_type,dynamic_fvf_type,NUM_BOX_VERTS);
466466
{
@@ -805,6 +805,9 @@ void AABoxRenderObjClass::update_cached_box(void)
805805
bool AABoxRenderObjClass::Cast_Ray(RayCollisionTestClass & raytest)
806806
{
807807
if ((Get_Collision_Type() & raytest.CollisionType) == 0) return false;
808+
if (Is_Animation_Hidden()) return false;
809+
if (raytest.Result->StartBad) return false;
810+
808811
if (CollisionMath::Collide(raytest.Ray,CachedBox,raytest.Result)) {
809812
raytest.CollidedRenderObj = this;
810813
return true;
@@ -828,6 +831,8 @@ bool AABoxRenderObjClass::Cast_Ray(RayCollisionTestClass & raytest)
828831
bool AABoxRenderObjClass::Cast_AABox(AABoxCollisionTestClass & boxtest)
829832
{
830833
if ((Get_Collision_Type() & boxtest.CollisionType) == 0) return false;
834+
if (boxtest.Result->StartBad) return false;
835+
831836
if (CollisionMath::Collide(boxtest.Box,boxtest.Move,CachedBox,boxtest.Result)) {
832837
boxtest.CollidedRenderObj = this;
833838
return true;
@@ -851,6 +856,8 @@ bool AABoxRenderObjClass::Cast_AABox(AABoxCollisionTestClass & boxtest)
851856
bool AABoxRenderObjClass::Cast_OBBox(OBBoxCollisionTestClass & boxtest)
852857
{
853858
if ((Get_Collision_Type() & boxtest.CollisionType) == 0) return false;
859+
if (boxtest.Result->StartBad) return false;
860+
854861
if (CollisionMath::Collide(boxtest.Box,boxtest.Move,CachedBox,Vector3(0,0,0),boxtest.Result)) {
855862
boxtest.CollidedRenderObj = this;
856863
return true;
@@ -1181,6 +1188,9 @@ void OBBoxRenderObjClass::update_cached_box(void)
11811188
bool OBBoxRenderObjClass::Cast_Ray(RayCollisionTestClass & raytest)
11821189
{
11831190
if ((Get_Collision_Type() & raytest.CollisionType) == 0) return false;
1191+
if (Is_Animation_Hidden()) return false;
1192+
if (raytest.Result->StartBad) return false;
1193+
11841194
if (CollisionMath::Collide(raytest.Ray,CachedBox,raytest.Result)) {
11851195
raytest.CollidedRenderObj = this;
11861196
return true;
@@ -1204,6 +1214,8 @@ bool OBBoxRenderObjClass::Cast_Ray(RayCollisionTestClass & raytest)
12041214
bool OBBoxRenderObjClass::Cast_AABox(AABoxCollisionTestClass & boxtest)
12051215
{
12061216
if ((Get_Collision_Type() & boxtest.CollisionType) == 0) return false;
1217+
if (boxtest.Result->StartBad) return false;
1218+
12071219
if (CollisionMath::Collide(boxtest.Box,boxtest.Move,CachedBox,Vector3(0,0,0),boxtest.Result)) {
12081220
boxtest.CollidedRenderObj = this;
12091221
return true;
@@ -1227,6 +1239,8 @@ bool OBBoxRenderObjClass::Cast_AABox(AABoxCollisionTestClass & boxtest)
12271239
bool OBBoxRenderObjClass::Cast_OBBox(OBBoxCollisionTestClass & boxtest)
12281240
{
12291241
if ((Get_Collision_Type() & boxtest.CollisionType) == 0) return false;
1242+
if (boxtest.Result->StartBad) return false;
1243+
12301244
if (CollisionMath::Collide(boxtest.Box,boxtest.Move,CachedBox,Vector3(0,0,0),boxtest.Result)) {
12311245
boxtest.CollidedRenderObj = this;
12321246
return true;

Generals/Code/Libraries/Source/WWVegas/WW3D2/boxrobj.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** Command & Conquer Generals(tm)
2+
** Command & Conquer Generals Zero Hour(tm)
33
** Copyright 2025 Electronic Arts Inc.
44
**
55
** This program is free software: you can redistribute it and/or modify

Generals/Code/Libraries/Source/WWVegas/WW3D2/hanimmgr.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** Command & Conquer Generals(tm)
2+
** Command & Conquer Generals Zero Hour(tm)
33
** Copyright 2025 Electronic Arts Inc.
44
**
55
** This program is free software: you can redistribute it and/or modify
@@ -16,7 +16,7 @@
1616
** along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
*/
1818

19-
/* $Header: /Commando/Code/ww3d2/hanimmgr.cpp 1 1/22/01 3:36p Greg_h $ */
19+
/* $Header: /Commando/Code/ww3d2/hanimmgr.cpp 3 1/16/02 9:51a Jani_p $ */
2020
/***********************************************************************************************
2121
*** Confidential - Westwood Studios ***
2222
***********************************************************************************************
@@ -27,9 +27,9 @@
2727
* *
2828
* Author:: Greg_h *
2929
* *
30-
* $Modtime:: 1/08/01 10:04a $*
30+
* $Modtime:: 1/16/02 9:49a $*
3131
* *
32-
* $Revision:: 1 $*
32+
* $Revision:: 3 $*
3333
* *
3434
*---------------------------------------------------------------------------------------------*
3535
* Functions: *
@@ -92,6 +92,7 @@ HAnimManagerClass::HAnimManagerClass(void)
9292
HAnimManagerClass::~HAnimManagerClass(void)
9393
{
9494
Free_All_Anims();
95+
Reset_Missing(); // Jani: Deleting missing animations as well
9596

9697
delete AnimPtrTable;
9798
AnimPtrTable = NULL;

Generals/Code/Libraries/Source/WWVegas/WW3D2/hanimmgr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** Command & Conquer Generals(tm)
2+
** Command & Conquer Generals Zero Hour(tm)
33
** Copyright 2025 Electronic Arts Inc.
44
**
55
** This program is free software: you can redistribute it and/or modify

Generals/Code/Libraries/Source/WWVegas/WW3D2/hlod.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** Command & Conquer Generals(tm)
2+
** Command & Conquer Generals Zero Hour(tm)
33
** Copyright 2025 Electronic Arts Inc.
44
**
55
** This program is free software: you can redistribute it and/or modify
@@ -3511,6 +3511,14 @@ void HLodClass::Add_Lod_Model(int lod, RenderObjClass * robj, int boneindex)
35113511
{
35123512
WWASSERT(robj != NULL);
35133513

3514+
// (gth) survive the case where the skeleton for this object no longer has
3515+
// the bone that we're trying to use. This happens when a skeleton is re-exported
3516+
// but the models that depend on it aren't re-exported...
3517+
if (boneindex >= HTree->Num_Pivots()) {
3518+
WWDEBUG_SAY(("ERROR: Model %s tried to use bone %d in skeleton %s. Please re-export!",Get_Name(),boneindex,HTree->Get_Name()));
3519+
boneindex = 0;
3520+
}
3521+
35143522
ModelNodeClass newnode;
35153523
newnode.Model = robj;
35163524
newnode.Model->Add_Ref();

Generals/Code/Libraries/Source/WWVegas/WW3D2/hlod.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** Command & Conquer Generals(tm)
2+
** Command & Conquer Generals Zero Hour(tm)
33
** Copyright 2025 Electronic Arts Inc.
44
**
55
** This program is free software: you can redistribute it and/or modify

Generals/Code/Libraries/Source/WWVegas/WW3D2/hmorphanim.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** Command & Conquer Generals(tm)
2+
** Command & Conquer Generals Zero Hour(tm)
33
** Copyright 2025 Electronic Arts Inc.
44
**
55
** This program is free software: you can redistribute it and/or modify
@@ -26,11 +26,11 @@
2626
* *
2727
* Original Author:: Greg Hjelstrom *
2828
* *
29-
* $Author:: Jani_p $*
29+
* $Author:: Byon_g $*
3030
* *
31-
* $Modtime:: 6/27/01 7:50p $*
31+
* $Modtime:: 1/16/02 6:39p $*
3232
* *
33-
* $Revision:: 5 $*
33+
* $Revision:: 7 $*
3434
* *
3535
*---------------------------------------------------------------------------------------------*
3636
* Functions: *
@@ -343,7 +343,7 @@ bool HMorphAnimClass::Import(const char *hierarchy_name, TextFileClass &text_des
343343
//
344344
// Copy the hierarchy name into a class variable
345345
//
346-
::strlcpy(HierarchyName, hierarchy_name, W3D_NAME_LEN);
346+
strlcpy (HierarchyName, hierarchy_name, W3D_NAME_LEN);
347347

348348
//
349349
// Attempt to load the new base pose
@@ -516,9 +516,12 @@ int HMorphAnimClass::Create_New_Morph(const int channels, HAnimClass *anim[])
516516

517517
// set up info
518518
// FrameCount = anim[0]->Get_Num_Frames();
519-
// FrameRate = anim[0]->Get_Frame_Rate();
520519
FrameCount = 0;
520+
#if RTS_GENERALS
521521
FrameRate = 30.0f;
522+
#elif RTS_ZEROHOUR
523+
FrameRate = anim[0]->Get_Frame_Rate();
524+
#endif
522525
NumNodes = anim[0]->Get_Num_Pivots();
523526

524527
// Set up the anim data for all the channels

0 commit comments

Comments
 (0)