Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
pivot.cpp
Go to the documentation of this file.
1/*
2** Command & Conquer Generals Zero Hour(tm)
3** Copyright 2025 Electronic Arts Inc.
4**
5** This program is free software: you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation, either version 3 of the License, or
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
15** You should have received a copy of the GNU General Public License
16** along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19/* $Header: /Commando/Code/ww3d2/pivot.cpp 1 1/22/01 3:36p Greg_h $ */
20/***********************************************************************************************
21 *** Confidential - Westwood Studios ***
22 ***********************************************************************************************
23 * *
24 * Project Name : Commando / G 3D Library *
25 * *
26 * $Archive:: /Commando/Code/ww3d2/pivot.cpp $*
27 * *
28 * Author:: Greg_h *
29 * *
30 * $Modtime:: 1/08/01 10:04a $*
31 * *
32 * $Revision:: 1 $*
33 * *
34 *---------------------------------------------------------------------------------------------*
35 * Functions: *
36 * PivotClass::PivotClass -- Constructor for PivotClass *
37 * PivotClass::Compute_Transform -- Update the pivot's transformation matrix *
38 * PivotClass::Compute_Transform -- Update the pivot's transformation matrix *
39 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
40
41#include "pivot.h"
42#include "wwmath.h"
43#include <string.h>
44
45
46/***********************************************************************************************
47 * PivotClass::PivotClass -- Constructor for PivotClass *
48 * *
49 * INPUT: *
50 * *
51 * OUTPUT: *
52 * *
53 * WARNINGS: *
54 * *
55 * HISTORY: *
56 * 07/24/1997 GH : Created. *
57 *=============================================================================================*/
59 Parent(NULL),
61 Transform(1),
62#ifdef LAZY_CAP_MTX_ALLOC
63 CapTransformPtr(NULL),
64 Index(0),
67#else
68 CapTransform(1),
69 Index(0),
74#endif
75{
76 Name[0] = 0;
77}
78
80 Parent(that.Parent),
82 Transform(that.Transform),
83#ifdef LAZY_CAP_MTX_ALLOC
84 CapTransformPtr(NULL),
85 Index(that.Index),
86 IsVisible(that.IsVisible),
88#else
90 Index(that.Index),
91 IsVisible(that.IsVisible),
94 Unused(that.Unused)
95#endif
96{
97 memcpy(Name, that.Name, sizeof(Name));
98#ifdef LAZY_CAP_MTX_ALLOC
99 if (that.CapTransformPtr != NULL)
100 {
101 CapTransformPtr = MSGW3DNEW("PivotClassCaptureBoneMtx") DynamicMatrix3D;
102 CapTransformPtr->Mat = that.CapTransformPtr->Mat;
103 }
104#endif
105}
106
108{
109 if (this != &that)
110 {
111 memcpy(Name, that.Name, sizeof(Name));
112 Parent = that.Parent;
114 Transform = that.Transform;
115 #ifdef LAZY_CAP_MTX_ALLOC
116 CapTransformPtr = NULL;
117 Index = that.Index;
118 IsVisible = that.IsVisible;
120 if (that.CapTransformPtr != NULL)
121 {
122 CapTransformPtr = MSGW3DNEW("PivotClassCaptureBoneMtx") DynamicMatrix3D;
123 CapTransformPtr->Mat = that.CapTransformPtr->Mat;
124 }
125 #else
127 Index = that.Index;
128 IsVisible = that.IsVisible;
130 IsCaptured = that.IsCaptured;
131 Unused = that.Unused;
132 #endif
133 }
134 return *this;
135}
136
138{
139#ifdef LAZY_CAP_MTX_ALLOC
140 if (!CapTransformPtr)
141 return;
142
143 const Matrix3D* ct = &CapTransformPtr->Mat;
144#else
145 const Matrix3D* ct = &CapTransform;
146#endif
147
149 {
150 // The Translation of CapTransform is meant to be in world space,
151 // so remove before applying orientation
152 Matrix3D CapOrientation = *ct;
153 CapOrientation.Set_Translation( Vector3( 0,0,0 ) );
154#ifdef ALLOW_TEMPORARIES
155 Matrix3D::Multiply(Transform,CapOrientation,&(Transform));
156#else
157 Transform.postMul(CapOrientation);
158#endif
159 // Now apply translation in world space
160 Transform.Adjust_Translation( ct->Get_Translation() );
161 }
162 else
163 {
164#ifdef ALLOW_TEMPORARIES
166#else
167 Transform.postMul(*ct);
168#endif
169 }
170}
171
#define NULL
Definition BaseType.h:92
#define MSGW3DNEW(MSG)
Definition always.h:107
@ true
Definition bool.h:59
@ false
Definition bool.h:59
static void Multiply(const Matrix3D &A, const Matrix3D &B, Matrix3D *set_result)
Definition matrix3d.cpp:640
WWINLINE void Set_Translation(const Vector3 &t)
Definition matrix3d.h:219
WWINLINE Vector3 Get_Translation(void) const
Definition matrix3d.h:217
Matrix3D CapTransform
Definition pivot.h:102
Matrix3D BaseTransform
Definition pivot.h:92
PivotClass * Parent
Definition pivot.h:91
Matrix3D Transform
Definition pivot.h:93
PivotClass(void)
Definition pivot.cpp:58
bool IsCaptured
Definition pivot.h:106
PivotClass & operator=(const PivotClass &that)
Definition pivot.cpp:107
bool Unused
Definition pivot.h:107
char Name[W3D_NAME_LEN]
Definition pivot.h:90
bool IsVisible
Definition pivot.h:104
bool WorldSpaceTranslation
Definition pivot.h:105
void Capture_Update(void)
Definition pivot.cpp:137
int Index
Definition pivot.h:103