Skip to content

Commit 46607a9

Browse files
authored
refactor(basetype): Refactor functions of Coord3D, Region3D to take reference instead of pointer (TheSuperHackers#2830)
1 parent 124daa9 commit 46607a9

107 files changed

Lines changed: 357 additions & 357 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Core/GameEngine/Source/Common/Audio/AudioEventRTS.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ AudioEventRTS::AudioEventRTS( const AsciiString& eventName, const Coord3D *posit
206206
m_delay(0.0f),
207207
m_uninterruptible(FALSE)
208208
{
209-
m_positionOfAudio.set( positionOfAudio );
209+
m_positionOfAudio.set( *positionOfAudio );
210210
m_attackName.clear();
211211
m_decayName.clear();
212212
}
@@ -239,7 +239,7 @@ AudioEventRTS::AudioEventRTS( const AudioEventRTS& right )
239239

240240
if( m_ownerType == OT_Positional || m_ownerType == OT_Dead )
241241
{
242-
m_positionOfAudio.set( &right.m_positionOfAudio );
242+
m_positionOfAudio.set( right.m_positionOfAudio );
243243
}
244244
else if( m_ownerType == OT_Drawable )
245245
{
@@ -280,7 +280,7 @@ AudioEventRTS& AudioEventRTS::operator=( const AudioEventRTS& right )
280280

281281
if( m_ownerType == OT_Positional || m_ownerType == OT_Dead )
282282
{
283-
m_positionOfAudio.set( &right.m_positionOfAudio );
283+
m_positionOfAudio.set( right.m_positionOfAudio );
284284
}
285285
else if( m_ownerType == OT_Drawable )
286286
{
@@ -732,7 +732,7 @@ const Coord3D *AudioEventRTS::getCurrentPosition()
732732
case OT_Object:
733733
if (Object *obj = TheGameLogic->findObjectByID(m_objectID))
734734
{
735-
m_positionOfAudio.set( obj->getPosition() );
735+
m_positionOfAudio.set( *obj->getPosition() );
736736
}
737737
else
738738
{
@@ -743,7 +743,7 @@ const Coord3D *AudioEventRTS::getCurrentPosition()
743743
case OT_Drawable:
744744
if (Drawable *draw = TheGameClient->findDrawableByID(m_drawableID))
745745
{
746-
m_positionOfAudio.set( draw->getPosition() );
746+
m_positionOfAudio.set( *draw->getPosition() );
747747
}
748748
else
749749
{

Core/GameEngine/Source/Common/Audio/GameAudio.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,8 @@ void AudioManager::update()
302302
//of making sure we only go a certain percentage towards the camera or the desired height, whichever occurs first.
303303
Coord3D cameraPos = TheTacticalView->get3DCameraPosition();
304304
Coord3D groundToCameraVector;
305-
groundToCameraVector.set( &cameraPos );
306-
groundToCameraVector.sub( &cameraPivot );
305+
groundToCameraVector.set( cameraPos );
306+
groundToCameraVector.sub( cameraPivot );
307307
Real bestScaleFactor;
308308

309309
if( cameraPos.z <= desiredHeightAbs || groundToCameraVector.z <= 0.0f )
@@ -325,8 +325,8 @@ void AudioManager::update()
325325

326326
//Set the microphone to be the ground position adjusted for terrain plus the vector we just calculated.
327327
Coord3D microphonePos;
328-
microphonePos.set( &cameraPivot );
329-
microphonePos.add( &groundToCameraVector );
328+
microphonePos.set( cameraPivot );
329+
microphonePos.add( groundToCameraVector );
330330

331331
//Viola! A properly placed microphone.
332332
setListenerPosition( &microphonePos, &lookTo );
@@ -345,7 +345,7 @@ void AudioManager::update()
345345
{
346346
//How far away is the camera from the microphone?
347347
Coord3D vector = cameraPos;
348-
vector.sub( &microphonePos );
348+
vector.sub( microphonePos );
349349
Real dist = vector.length();
350350

351351
if( dist < minDist )

Core/GameEngine/Source/Common/Audio/GameSounds.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ Bool SoundManager::canPlayNow( AudioEventRTS *event )
174174
const Coord3D *pos = event->getCurrentPosition();
175175
if (pos)
176176
{
177-
distance.sub(pos);
177+
distance.sub(*pos);
178178
if (distance.length() >= event->getAudioEventInfo()->m_maxDistance)
179179
{
180180
#ifdef INTENSIVE_AUDIO_DEBUG

Core/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa
959959
case GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_UP:
960960
{
961961
Coord3D cameraPos = TheTacticalView->getPosition();
962-
cameraPos.sub(&m_deselectDownCameraPosition);
962+
cameraPos.sub(m_deselectDownCameraPosition);
963963

964964
ICoord2D pixel = msg->getArgument( 0 )->pixel;
965965
UnsignedInt currentTime = (UnsignedInt) msg->getArgument( 2 )->integer;

Core/GameEngine/Source/GameClient/System/ParticleSys.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,8 +1518,8 @@ const Coord3D *ParticleSystem::computeParticleVelocity( const Coord3D *pos )
15181518
up.x = 0.0;
15191519
up.y = 0.0;
15201520
up.z = 1.0;
1521-
perp.crossProduct( &up, &along, &perp );
1522-
up.crossProduct( &along, &perp, &up );
1521+
perp.crossProduct( up, along, perp );
1522+
up.crossProduct( along, perp, up );
15231523

15241524
// "speed" is in 'horizontal' plane, and "otherSpeed" is 'vertical'
15251525
newVel.x = speed * perp.x + otherSpeed * up.x;

Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5451,8 +5451,8 @@ Bool Pathfinder::adjustToLandingDestination(Object *obj, Coord3D *dest)
54515451
TheTerrainLogic->getMaximumPathfindExtent(&extent);
54525452
// If the object is off the map & the goal is off the map, it is a scripted setup, so just
54535453
// go to the dest.
5454-
if (!extent.isInRegionNoZ(dest)) {
5455-
if (!extent.isInRegionNoZ(obj->getPosition())) {
5454+
if (!extent.isInRegionNoZ(*dest)) {
5455+
if (!extent.isInRegionNoZ(*obj->getPosition())) {
54565456
return true;
54575457
}
54585458
}

Core/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2069,7 +2069,7 @@ bool GameLogic::onPlaceBeacon(MAYBE_UNUSED GameMessage *msg)
20692069
Coord3D pos = msg->getArgument( 0 )->location;
20702070
Region3D r;
20712071
TheTerrainLogic->getExtent(&r);
2072-
if (!r.isInRegionNoZ(&pos))
2072+
if (!r.isInRegionNoZ(pos))
20732073
pos = TheTerrainLogic->findClosestEdgePoint(&pos);
20742074
const ThingTemplate *thing = TheThingFactory->findTemplate( msgPlayer->getPlayerTemplate()->getBeaconTemplate() );
20752075

Core/GameEngineDevice/Source/MilesAudioDevice/MilesAudioManager.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ void MilesAudioManager::audioDebugDisplay(DebugDisplayInterface *dd, void *, FIL
139139
Coord3D lookPos = TheTacticalView->getPosition();
140140
const Coord3D *mikePos = TheAudio->getListenerPosition();
141141
Coord3D distanceVector = TheTacticalView->get3DCameraPosition();
142-
distanceVector.sub( mikePos );
142+
distanceVector.sub( *mikePos );
143143

144144
Int now = TheGameLogic->getFrame();
145145
static Int lastCheck = now;
@@ -307,7 +307,7 @@ void MilesAudioManager::audioDebugDisplay(DebugDisplayInterface *dd, void *, FIL
307307
if( pos )
308308
{
309309
Coord3D vector = *microphonePos;
310-
vector.sub( pos );
310+
vector.sub( *pos );
311311
dist = vector.length();
312312
sprintf( distStr, "%d", REAL_TO_INT( dist ) );
313313
}
@@ -2555,7 +2555,7 @@ Real MilesAudioManager::getEffectiveVolume(AudioEventRTS *event) const
25552555
if (pos)
25562556
{
25572557
Coord3D distance = m_listenerPosition;
2558-
distance.sub(pos);
2558+
distance.sub(*pos);
25592559
Real objMinDistance;
25602560
Real objMaxDistance;
25612561

Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DLaserDraw.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -283,21 +283,21 @@ void W3DLaserDraw::doDrawModule(const Matrix3D* transformMtx)
283283

284284
//Get the desired direct line
285285
Coord3D lineStart, lineEnd, lineVector;
286-
lineStart.set( update->getStartPos() );
287-
lineEnd.set( update->getEndPos() );
286+
lineStart.set( *update->getStartPos() );
287+
lineEnd.set( *update->getEndPos() );
288288
//This is critical -- in the case we have sloped lines (at the end, we'll fix it)
289289
// lineEnd.z = lineStart.z;
290290

291291
//Get the length of the line
292-
lineVector.set( &lineEnd );
293-
lineVector.sub( &lineStart );
292+
lineVector.set( lineEnd );
293+
lineVector.sub( lineStart );
294294
Real lineLength = lineVector.length();
295295

296296
//Get the middle point (we'll use this to determine how far we are from
297297
//that to calculate our height -- middle point is the highest).
298298
Coord3D lineMiddle;
299-
lineMiddle.set( &lineStart );
300-
lineMiddle.add( &lineEnd );
299+
lineMiddle.set( lineStart );
300+
lineMiddle.add( lineEnd );
301301
lineMiddle.scale( 0.5 );
302302

303303
//The half length is used to scale with the distance from middle to
@@ -321,34 +321,34 @@ void W3DLaserDraw::doDrawModule(const Matrix3D* transformMtx)
321321

322322
//Calculate our start segment position on the *ground*.
323323
Coord3D segmentStart, segmentEnd, vector;
324-
vector.set( &lineVector );
324+
vector.set( lineVector );
325325
vector.scale( startSegmentRatio );
326-
segmentStart.set( &lineStart );
327-
segmentStart.add( &vector );
326+
segmentStart.set( lineStart );
327+
segmentStart.add( vector );
328328

329329
//Calculate our end segment position on the *ground*.
330-
vector.set( &lineVector );
330+
vector.set( lineVector );
331331
vector.scale( endSegmentRatio );
332-
segmentEnd.set( &lineStart );
333-
segmentEnd.add( &vector );
332+
segmentEnd.set( lineStart );
333+
segmentEnd.add( vector );
334334

335335
//--------------------------------------------------------------------------------
336336
//Now at this point, we have our segment line in the level positions that we want.
337337
//Calculate the raised height for the start/end segment positions using cosine.
338338
//--------------------------------------------------------------------------------
339339

340340
//Calculate the distance from midpoint for the start positions.
341-
vector.set( &lineMiddle );
342-
vector.sub( &segmentStart );
341+
vector.set( lineMiddle );
342+
vector.sub( segmentStart );
343343
Real dist = vector.length();
344344
Real scaledRadians = dist / halfLength * PI * 0.5f;
345345
Real height = cos( scaledRadians );
346346
height *= data->m_arcHeight;
347347
segmentStart.z += height;
348348

349349
//Now do the same thing for the end position.
350-
vector.set( &lineMiddle );
351-
vector.sub( &segmentEnd );
350+
vector.set( lineMiddle );
351+
vector.sub( segmentEnd );
352352
dist = vector.length();
353353
scaledRadians = dist / halfLength * PI * 0.5f;
354354
height = cos( scaledRadians );

Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTreeBuffer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,7 @@ void W3DTreeBuffer::unitMoved(Object *unit)
11861186
}
11871187
Coord3D delta;
11881188
delta.set(m_trees[treeNdx].location.X, m_trees[treeNdx].location.Y, m_trees[treeNdx].location.Z );
1189-
delta.sub(&pos);
1189+
delta.sub(pos);
11901190
if (radius*radius>delta.lengthSqr()) {
11911191
bool canTopple = unit->getCrusherLevel() > 1;
11921192
if (canTopple && m_treeTypes[m_trees[treeNdx].treeType].m_data->m_doTopple) {
@@ -1500,7 +1500,7 @@ void W3DTreeBuffer::pushAsideTree(DrawableID id, const Coord3D *pusherPos,
15001500
m_trees[i].pushAsideSource = pusherID;
15011501
Coord3D delta;
15021502
delta.set(m_trees[i].location.X, m_trees[i].location.Y, m_trees[i].location.Z);
1503-
delta.sub(pusherPos);
1503+
delta.sub(*pusherPos);
15041504

15051505
if (pusherDirection->x*delta.y - pusherDirection->y*delta.x > 0.0f) {
15061506
m_trees[i].pushAsideCos = -pusherDirection->y;

0 commit comments

Comments
 (0)