Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Core/GameEngine/Source/Common/Audio/AudioEventRTS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ AudioEventRTS::AudioEventRTS( const AsciiString& eventName, const Coord3D *posit
m_delay(0.0f),
m_uninterruptible(FALSE)
{
m_positionOfAudio.set( positionOfAudio );
m_positionOfAudio.set( *positionOfAudio );
m_attackName.clear();
m_decayName.clear();
}
Expand Down Expand Up @@ -239,7 +239,7 @@ AudioEventRTS::AudioEventRTS( const AudioEventRTS& right )

if( m_ownerType == OT_Positional || m_ownerType == OT_Dead )
{
m_positionOfAudio.set( &right.m_positionOfAudio );
m_positionOfAudio.set( right.m_positionOfAudio );
}
else if( m_ownerType == OT_Drawable )
{
Expand Down Expand Up @@ -280,7 +280,7 @@ AudioEventRTS& AudioEventRTS::operator=( const AudioEventRTS& right )

if( m_ownerType == OT_Positional || m_ownerType == OT_Dead )
{
m_positionOfAudio.set( &right.m_positionOfAudio );
m_positionOfAudio.set( right.m_positionOfAudio );
}
else if( m_ownerType == OT_Drawable )
{
Expand Down Expand Up @@ -732,7 +732,7 @@ const Coord3D *AudioEventRTS::getCurrentPosition()
case OT_Object:
if (Object *obj = TheGameLogic->findObjectByID(m_objectID))
{
m_positionOfAudio.set( obj->getPosition() );
m_positionOfAudio.set( *obj->getPosition() );
}
else
{
Expand All @@ -743,7 +743,7 @@ const Coord3D *AudioEventRTS::getCurrentPosition()
case OT_Drawable:
if (Drawable *draw = TheGameClient->findDrawableByID(m_drawableID))
{
m_positionOfAudio.set( draw->getPosition() );
m_positionOfAudio.set( *draw->getPosition() );
}
else
{
Expand Down
10 changes: 5 additions & 5 deletions Core/GameEngine/Source/Common/Audio/GameAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,8 @@ void AudioManager::update()
//of making sure we only go a certain percentage towards the camera or the desired height, whichever occurs first.
Coord3D cameraPos = TheTacticalView->get3DCameraPosition();
Coord3D groundToCameraVector;
groundToCameraVector.set( &cameraPos );
groundToCameraVector.sub( &cameraPivot );
groundToCameraVector.set( cameraPos );
groundToCameraVector.sub( cameraPivot );
Real bestScaleFactor;

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

//Set the microphone to be the ground position adjusted for terrain plus the vector we just calculated.
Coord3D microphonePos;
microphonePos.set( &cameraPivot );
microphonePos.add( &groundToCameraVector );
microphonePos.set( cameraPivot );
microphonePos.add( groundToCameraVector );

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

if( dist < minDist )
Expand Down
2 changes: 1 addition & 1 deletion Core/GameEngine/Source/Common/Audio/GameSounds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ Bool SoundManager::canPlayNow( AudioEventRTS *event )
const Coord3D *pos = event->getCurrentPosition();
if (pos)
{
distance.sub(pos);
distance.sub(*pos);
if (distance.length() >= event->getAudioEventInfo()->m_maxDistance)
{
#ifdef INTENSIVE_AUDIO_DEBUG
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa
case GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_UP:
{
Coord3D cameraPos = TheTacticalView->getPosition();
cameraPos.sub(&m_deselectDownCameraPosition);
cameraPos.sub(m_deselectDownCameraPosition);

ICoord2D pixel = msg->getArgument( 0 )->pixel;
UnsignedInt currentTime = (UnsignedInt) msg->getArgument( 2 )->integer;
Expand Down
4 changes: 2 additions & 2 deletions Core/GameEngine/Source/GameClient/System/ParticleSys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1518,8 +1518,8 @@ const Coord3D *ParticleSystem::computeParticleVelocity( const Coord3D *pos )
up.x = 0.0;
up.y = 0.0;
up.z = 1.0;
perp.crossProduct( &up, &along, &perp );
up.crossProduct( &along, &perp, &up );
perp.crossProduct( up, along, perp );
up.crossProduct( along, perp, up );

// "speed" is in 'horizontal' plane, and "otherSpeed" is 'vertical'
newVel.x = speed * perp.x + otherSpeed * up.x;
Expand Down
4 changes: 2 additions & 2 deletions Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5451,8 +5451,8 @@ Bool Pathfinder::adjustToLandingDestination(Object *obj, Coord3D *dest)
TheTerrainLogic->getMaximumPathfindExtent(&extent);
// If the object is off the map & the goal is off the map, it is a scripted setup, so just
// go to the dest.
if (!extent.isInRegionNoZ(dest)) {
if (!extent.isInRegionNoZ(obj->getPosition())) {
if (!extent.isInRegionNoZ(*dest)) {
if (!extent.isInRegionNoZ(*obj->getPosition())) {
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2069,7 +2069,7 @@ bool GameLogic::onPlaceBeacon(MAYBE_UNUSED GameMessage *msg)
Coord3D pos = msg->getArgument( 0 )->location;
Region3D r;
TheTerrainLogic->getExtent(&r);
if (!r.isInRegionNoZ(&pos))
if (!r.isInRegionNoZ(pos))
pos = TheTerrainLogic->findClosestEdgePoint(&pos);
const ThingTemplate *thing = TheThingFactory->findTemplate( msgPlayer->getPlayerTemplate()->getBeaconTemplate() );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void MilesAudioManager::audioDebugDisplay(DebugDisplayInterface *dd, void *, FIL
Coord3D lookPos = TheTacticalView->getPosition();
const Coord3D *mikePos = TheAudio->getListenerPosition();
Coord3D distanceVector = TheTacticalView->get3DCameraPosition();
distanceVector.sub( mikePos );
distanceVector.sub( *mikePos );

Int now = TheGameLogic->getFrame();
static Int lastCheck = now;
Expand Down Expand Up @@ -307,7 +307,7 @@ void MilesAudioManager::audioDebugDisplay(DebugDisplayInterface *dd, void *, FIL
if( pos )
{
Coord3D vector = *microphonePos;
vector.sub( pos );
vector.sub( *pos );
dist = vector.length();
sprintf( distStr, "%d", REAL_TO_INT( dist ) );
}
Expand Down Expand Up @@ -2555,7 +2555,7 @@ Real MilesAudioManager::getEffectiveVolume(AudioEventRTS *event) const
if (pos)
{
Coord3D distance = m_listenerPosition;
distance.sub(pos);
distance.sub(*pos);
Real objMinDistance;
Real objMaxDistance;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,21 +283,21 @@ void W3DLaserDraw::doDrawModule(const Matrix3D* transformMtx)

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

//Get the length of the line
lineVector.set( &lineEnd );
lineVector.sub( &lineStart );
lineVector.set( lineEnd );
lineVector.sub( lineStart );
Real lineLength = lineVector.length();

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

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

//Calculate our start segment position on the *ground*.
Coord3D segmentStart, segmentEnd, vector;
vector.set( &lineVector );
vector.set( lineVector );
vector.scale( startSegmentRatio );
segmentStart.set( &lineStart );
segmentStart.add( &vector );
segmentStart.set( lineStart );
segmentStart.add( vector );

//Calculate our end segment position on the *ground*.
vector.set( &lineVector );
vector.set( lineVector );
vector.scale( endSegmentRatio );
segmentEnd.set( &lineStart );
segmentEnd.add( &vector );
segmentEnd.set( lineStart );
segmentEnd.add( vector );

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

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

//Now do the same thing for the end position.
vector.set( &lineMiddle );
vector.sub( &segmentEnd );
vector.set( lineMiddle );
vector.sub( segmentEnd );
dist = vector.length();
scaledRadians = dist / halfLength * PI * 0.5f;
height = cos( scaledRadians );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,7 @@ void W3DTreeBuffer::unitMoved(Object *unit)
}
Coord3D delta;
delta.set(m_trees[treeNdx].location.X, m_trees[treeNdx].location.Y, m_trees[treeNdx].location.Z );
delta.sub(&pos);
delta.sub(pos);
if (radius*radius>delta.lengthSqr()) {
bool canTopple = unit->getCrusherLevel() > 1;
if (canTopple && m_treeTypes[m_trees[treeNdx].treeType].m_data->m_doTopple) {
Expand Down Expand Up @@ -1500,7 +1500,7 @@ void W3DTreeBuffer::pushAsideTree(DrawableID id, const Coord3D *pusherPos,
m_trees[i].pushAsideSource = pusherID;
Coord3D delta;
delta.set(m_trees[i].location.X, m_trees[i].location.Y, m_trees[i].location.Z);
delta.sub(pusherPos);
delta.sub(*pusherPos);

if (pusherDirection->x*delta.y - pusherDirection->y*delta.x > 0.0f) {
m_trees[i].pushAsideCos = -pusherDirection->y;
Expand Down
46 changes: 23 additions & 23 deletions Core/Libraries/Include/Lib/BaseType.h
Original file line number Diff line number Diff line change
Expand Up @@ -438,11 +438,11 @@ struct Coord3D
}
}

static void crossProduct( const Coord3D *a, const Coord3D *b, Coord3D *r )
static void crossProduct( const Coord3D &a, const Coord3D &b, Coord3D &r )
{
r->x = (a->y * b->z - a->z * b->y);
r->y = (a->z * b->x - a->x * b->z);
r->z = (a->x * b->y - a->y * b->x);
r.x = (a.y * b.z - a.z * b.y);
r.y = (a.z * b.x - a.x * b.z);
r.z = (a.x * b.y - a.y * b.x);
}

void zero()
Expand All @@ -457,25 +457,25 @@ struct Coord3D
return x == value && y == value && z == value;
}

void add( const Coord3D *a )
void add( const Coord3D &a )
{
x += a->x;
y += a->y;
z += a->z;
x += a.x;
y += a.y;
z += a.z;
}

void sub( const Coord3D *a )
void sub( const Coord3D &a )
{
x -= a->x;
y -= a->y;
z -= a->z;
x -= a.x;
y -= a.y;
z -= a.z;
}

void set( const Coord3D *a )
void set( const Coord3D &a )
{
x = a->x;
y = a->y;
z = a->z;
x = a.x;
y = a.y;
z = a.z;
}

void set( Real ax, Real ay, Real az )
Expand Down Expand Up @@ -582,17 +582,17 @@ struct Region3D
}
}

Bool isInRegionNoZ( const Coord3D *query ) const
Bool isInRegionNoZ( const Coord3D &query ) const
{
return (lo.x < query->x) && (query->x < hi.x) &&
(lo.y < query->y) && (query->y < hi.y);
return (lo.x < query.x) && (query.x < hi.x) &&
(lo.y < query.y) && (query.y < hi.y);
}

Bool isInRegion( const Coord3D *query ) const
Bool isInRegion( const Coord3D &query ) const
{
return (lo.x < query->x) && (query->x < hi.x) &&
(lo.y < query->y) && (query->y < hi.y) &&
(lo.z < query->z) && (query->z < hi.z);
return (lo.x < query.x) && (query.x < hi.x) &&
(lo.y < query.y) && (query.y < hi.y) &&
(lo.z < query.z) && (query.z < hi.z);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ const Coord3D& BezFwdIterator::getCurrent() const
//-------------------------------------------------------------------------------------------------
void BezFwdIterator::next()
{
mCurrPoint.add(&mDq);
mDq.add(&mDDq);
mDDq.add(&mDDDq);
mCurrPoint.add(mDq);
mDq.add(mDDq);
mDDq.add(mDDDq);

++mStep;
}
Expand Down
10 changes: 5 additions & 5 deletions Generals/Code/GameEngine/Source/Common/Bezier/BezierSegment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ void BezierSegment::splitSegmentAtT(Real tValue, BezierSegment &outSeg1, BezierS
p1p2.scale(tValue);
p2p3.scale(tValue);

p0p1.add(&m_controlPoints[0]);
p1p2.add(&m_controlPoints[1]);
p2p3.add(&m_controlPoints[2]);
p0p1.add(m_controlPoints[0]);
p1p2.add(m_controlPoints[1]);
p2p3.add(m_controlPoints[2]);

Coord3D triLeft = { p1p2.x - p0p1.x,
p1p2.y - p0p1.y,
Expand All @@ -222,8 +222,8 @@ void BezierSegment::splitSegmentAtT(Real tValue, BezierSegment &outSeg1, BezierS
triLeft.scale(tValue);
triRight.scale(tValue);

triLeft.add(&p0p1);
triRight.add(&p1p2);
triLeft.add(p0p1);
triRight.add(p1p2);

outSeg1.m_controlPoints[0] = m_controlPoints[0];
outSeg1.m_controlPoints[1] = p0p1;
Expand Down
2 changes: 1 addition & 1 deletion Generals/Code/GameEngine/Source/Common/RTS/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2381,7 +2381,7 @@ void Player::doBountyForKill(const Object* killer, const Object* victim)
moneyString.format( TheGameText->fetch( "GUI:AddCash" ), bounty );
Coord3D pos;
pos.zero();
pos.add( killer->getPosition() );
pos.add( *killer->getPosition() );
pos.z += 10.0f; //add a little z to make it show up above the unit.
TheInGameUI->addFloatingText( moneyString, &pos, GameMakeColor( 255, 255, 0, 255 ) );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ LegalBuildCode BuildAssistant::isLocationLegalToBuild( const Coord3D *worldPos,
/* You just can't never build off the map, regardless of options. jba. */
Region3D mapExtent;
TheTerrainLogic->getMaximumPathfindExtent(&mapExtent);
if (!mapExtent.isInRegionNoZ(worldPos)) {
if (!mapExtent.isInRegionNoZ(*worldPos)) {
return LBC_RESTRICTED_TERRAIN;
}

Expand Down
4 changes: 2 additions & 2 deletions Generals/Code/GameEngine/Source/Common/Thing/Thing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ void Thing::setOrientation( Real angle )
u.y = Sin(angle);
u.z = 0.0f;

y.crossProduct( &z, &u, &y );
x.crossProduct( &y, &z, &x );
y.crossProduct( z, u, y );
x.crossProduct( y, z, x );

m_transform.Set( x.x, y.x, z.x, pos.x,
x.y, y.y, z.y, pos.y,
Expand Down
Loading
Loading