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
18 changes: 8 additions & 10 deletions Core/GameEngine/Include/GameClient/View.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,10 @@ class View : public Snapshot
virtual Real getPitch() { return m_pitch; } ///< Return current camera pitch
virtual void setAngleToDefault(); ///< Set the view angle back to default
virtual void setPitchToDefault(); ///< Set the view pitch back to default
void setPosition( const Coord3D *pos ) { m_pos = *pos; }
void getPosition(Coord3D *pos) { *pos = m_pos;} ///< Returns position camera is looking at (z will be zero)
void setPosition( const Coord3D &pos ) { m_pos = pos; }
void setPosition2D( const Coord2D &pos ) { m_pos.x = pos.x; m_pos.y = pos.y; }
const Coord3D &getPosition() const { return m_pos; } ///< Returns position camera is looking at
Coord2D getPosition2D() const { Coord2D c = { m_pos.x, m_pos.y }; return c; } ///< Returns position camera is looking at

virtual const Coord3D& get3DCameraPosition() const = 0; ///< Returns the actual camera position

Expand All @@ -195,7 +197,7 @@ class View : public Snapshot
virtual void setOkToAdjustHeight( Bool val ) { m_okToAdjustHeight = val; } ///< Set this to adjust camera height

// TheSuperHackers @info Functions to call for user camera controls, not by the scripted camera.
Bool userSetPosition(const Coord3D *pos) { return doUserAction(&View::setPosition, pos); }
Bool userSetPosition(const Coord3D &pos) { return doUserAction(&View::setPosition, pos); }
Bool userSetAngle(Real radians) { return doUserAction(&View::setAngle, radians); }
Bool userSetAngleToDefault() { return doUserAction(&View::setAngleToDefault); }
Bool userSetPitch(Real radians) { return doUserAction(&View::setPitch, radians); }
Expand Down Expand Up @@ -261,8 +263,6 @@ class View : public Snapshot
virtual void xfer( Xfer *xfer ) override;
virtual void loadPostProcess() override { }

const Coord3D *getPosition() const { return &m_pos; }

virtual View *prependViewToList( View *list ); ///< Prepend this view to the given list, return the new list
virtual View *getNextView() { return m_next; } ///< Return next view in the set

Expand Down Expand Up @@ -302,7 +302,7 @@ class View : public Snapshot
UnsignedInt m_userControlLockedUntilFrame; ///< Locks the user control over camera until the given frame is reached
Bool m_isUserControlled; ///< True if the user moved the camera last, false if the scripted camera moved the camera last

Coord3D m_pos; ///< Pivot of the camera, in world coordinates // TheSuperHackers @todo Make this Coord2D or use the Z component
Coord3D m_pos; ///< Pivot of the camera, in world coordinates
Int m_width, m_height; ///< Dimensions of the view
Int m_originX, m_originY; ///< Location of top/left view corner

Expand Down Expand Up @@ -356,12 +356,10 @@ class ViewLocation
Real getPitch() const { return m_pitch; }
Real getZoom() const { return m_zoom; }

void init(Real x, Real y, Real z, Real angle, Real pitch, Real zoom)
void init(Coord3D pos, Real angle, Real pitch, Real zoom)
{
m_valid = true;
m_pos.x = x;
m_pos.y = y;
m_pos.z = z;
m_pos = pos;
m_angle = angle;
m_pitch = pitch;
m_zoom = zoom;
Expand Down
13 changes: 6 additions & 7 deletions Core/GameEngine/Source/Common/Audio/GameAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,16 +282,16 @@ void AudioManager::reset()
//-------------------------------------------------------------------------------------------------
void AudioManager::update()
{
Coord3D groundPos, microphonePos;
TheTacticalView->getPosition( &groundPos );
Coord3D microphonePos;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to line 327 where it is used for the first time

Coord3D cameraPivot = TheTacticalView->getPosition();
Real angle = TheTacticalView->getAngle();
Matrix3D rot = Matrix3D::Identity;
rot.Rotate_Z( angle );
Vector3 forward( 0, 1, 0 );
rot.mulVector3( forward );

Real desiredHeight = m_audioSettings->m_microphoneDesiredHeightAboveTerrain;
Real maxPercentage = m_audioSettings->m_microphoneMaxPercentageBetweenGroundAndCamera;
const Real desiredHeight = m_audioSettings->m_microphoneDesiredHeightAboveTerrain + cameraPivot.z;
const Real maxPercentage = m_audioSettings->m_microphoneMaxPercentageBetweenGroundAndCamera;

Coord3D lookTo;
lookTo.set(forward.X, forward.Y, forward.Z);
Expand All @@ -303,7 +303,7 @@ void AudioManager::update()
Coord3D cameraPos = TheTacticalView->get3DCameraPosition();
Coord3D groundToCameraVector;
groundToCameraVector.set( &cameraPos );
groundToCameraVector.sub( &groundPos );
groundToCameraVector.sub( &cameraPivot );
Real bestScaleFactor;

if( cameraPos.z <= desiredHeight || groundToCameraVector.z <= 0.0f )
Expand All @@ -324,8 +324,7 @@ void AudioManager::update()
groundToCameraVector.scale( bestScaleFactor );

//Set the microphone to be the ground position adjusted for terrain plus the vector we just calculated.
groundPos.z = TheTerrainLogic->getGroundHeight( groundPos.x, groundPos.y );
microphonePos.set( &groundPos );
microphonePos.set( &cameraPivot );
microphonePos.add( &groundToCameraVector );

//Viola! A properly placed microphone.
Expand Down
16 changes: 5 additions & 11 deletions Core/GameEngine/Source/GameClient/View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,11 @@ void View::zoom( Real height )
*/
void View::lookAt( const Coord3D *o )
{

/// @todo this needs to be changed to be 3D, this is still old 2D stuff
Coord3D pos = *getPosition();
Coord2D pos = getPosition2D();
pos.x = o->x - m_width * 0.5f;
pos.y = o->y - m_height * 0.5f;
setPosition(&pos);
setPosition2D(pos);
}

/**
Expand Down Expand Up @@ -203,10 +202,7 @@ void View::setHeightAboveGround(Real z)
*/
void View::getLocation( ViewLocation *location )
{

const Coord3D *pos = getPosition();
location->init( pos->x, pos->y, pos->z, getAngle(), getPitch(), getZoom() );

location->init( getPosition(), getAngle(), getPitch(), getZoom() );
}


Expand All @@ -217,11 +213,10 @@ void View::setLocation( const ViewLocation *location )
{
if ( location->isValid() )
{
setPosition(&location->getPosition());
setPosition(location->getPosition());
setAngle(location->getAngle());
setPitch(location->getPitch());
setZoom(location->getZoom());
forceRedraw();
}

}
Expand Down Expand Up @@ -287,8 +282,7 @@ void View::xfer( Xfer *xfer )
setAngle( angle );

// view position
Coord3D viewPos;
getPosition( &viewPos );
Coord3D viewPos = getPosition();
xfer->xferReal( &viewPos.x );
xfer->xferReal( &viewPos.y );
xfer->xferReal( &viewPos.z );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ class W3DView : public View, public SubsystemInterface
Coord2D m_scrollAmount; ///< scroll speed
Real m_scrollAmountCutoffSqr; ///< scroll speed at which we do not adjust height

Real m_groundLevel; ///< height of ground.
#if PRESERVE_RETAIL_SCRIPTED_CAMERA
// TheSuperHackers @tweak Uses the initial ground level for preserving the original look of the scripted camera,
// because alterations to the ground level do affect the positioning in subtle ways.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,7 @@ void MilesAudioManager::audioDebugDisplay(DebugDisplayInterface *dd, void *, FIL
AIL_MSS_version(buffer, 128);
}

Coord3D lookPos;
TheTacticalView->getPosition( &lookPos );
lookPos.z = TheTerrainLogic->getGroundHeight( lookPos.x, lookPos.y );
Coord3D lookPos = TheTacticalView->getPosition();
const Coord3D *mikePos = TheAudio->getListenerPosition();
Coord3D distanceVector = TheTacticalView->get3DCameraPosition();
distanceVector.sub( mikePos );
Expand Down
Loading
Loading