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
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ endif()

include(cmake/config.cmake)
include(cmake/gamespy.cmake)
if (NOT IS_VS6_BUILD)
include(cmake/gamemath.cmake)
endif()
include(cmake/lzhl.cmake)

if (IS_VS6_BUILD)
Expand Down
7 changes: 5 additions & 2 deletions Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ add_library(corei_always INTERFACE)
add_library(corei_always_no_pch INTERFACE) # Use this for Shared Libs with MFC AFX

target_include_directories(corei_gameengine_include INTERFACE "GameEngine/Include")
target_include_directories(corei_libraries_include INTERFACE "Libraries/Include")
target_include_directories(corei_libraries_include INTERFACE "Libraries/Include" "Libraries/Source/WWVegas/WWMath")
if (NOT IS_VS6_BUILD)
target_link_libraries(corei_libraries_include INTERFACE gamemath)
endif()
target_include_directories(corei_libraries_source_wwvegas INTERFACE "Libraries/Source/WWVegas")
target_include_directories(corei_libraries_source_wwvegas_wwlib INTERFACE "Libraries/Source/WWVegas/WWLib")
target_include_directories(corei_main INTERFACE "Main")

target_sources(corei_libraries_include PRIVATE
Libraries/Include/Lib/BaseType.h
Libraries/Include/Lib/BaseTypeCore.h
Libraries/Include/Lib/trig.h

Libraries/Include/rts/debug.h
Libraries/Include/rts/profile.h
)
Expand Down
2 changes: 1 addition & 1 deletion Core/GameEngine/Include/GameClient/View.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "Common/Snapshot.h"
#include "Lib/BaseType.h"
#include "WW3D2/coltype.h" ///< we don't generally do this, but we need the W3D collision types
#include "WWMath/wwmath.h"
#include "wwmath.h"

#define DEFAULT_VIEW_WIDTH 640
#define DEFAULT_VIEW_HEIGHT 480
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "Common/Diagnostic/SimulationMathCrc.h"
#include "Common/XferCRC.h"
#include "WWMath/matrix3d.h"
#include "WWMath/wwmath.h"
#include "wwmath.h"
#include "GameLogic/FPUControl.h"

#include <math.h>
Expand Down
2 changes: 1 addition & 1 deletion Core/GameEngine/Source/GameClient/RadiusDecal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ void RadiusDecal::update()
{
UnsignedInt now = TheGameLogic->getFrame();
Real theta = (2*PI) * (Real)(now % m_template->m_opacityThrobTime) / (Real)m_template->m_opacityThrobTime;
Real percent = 0.5f * (Sin(theta) + 1.0f);
Real percent = 0.5f * (WWMath::Sin(theta) + 1.0f);
Int opac;
if( TheGameLogic->getDrawIconUI() )
{
Expand Down
6 changes: 3 additions & 3 deletions Core/GameEngine/Source/GameClient/System/ParticleSys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -584,8 +584,8 @@ void Particle::doWindMotion()
(noForceDistance - fullForceDistance)));

// integrate the wind motion into the position
m_pos.x += (Cos( windAngle ) * windForceStrength);
m_pos.y += (Sin( windAngle ) * windForceStrength);
m_pos.x += (WWMath::Cos( windAngle ) * windForceStrength);
m_pos.y += (WWMath::Sin( windAngle ) * windForceStrength);

}

Expand Down Expand Up @@ -3520,7 +3520,7 @@ static Real angleBetween(const Coord2D *vecA, const Coord2D *vecB)
return 0.0f;
}

Real theta = ACos( cosTheta );
Real theta = WWMath::Acos( cosTheta );

if (vecB->x > 0) {
return theta;
Expand Down
12 changes: 6 additions & 6 deletions Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3955,8 +3955,8 @@ Bool PathfindLayer::isPointOnWall(ObjectID *wallPieces, Int numPieces, const Coo
Real major = obj->getGeometryInfo().getMajorRadius();
Real minor = (obj->getGeometryInfo().getGeomType() == GEOMETRY_SPHERE) ? obj->getGeometryInfo().getMajorRadius() : obj->getGeometryInfo().getMinorRadius();

Real c = (Real)Cos(-obj->getOrientation());
Real s = (Real)Sin(-obj->getOrientation());
Real c = (Real)WWMath::CosTrig(-obj->getOrientation());
Real s = (Real)WWMath::SinTrig(-obj->getOrientation());

// convert to a delta relative to rect ctr
Real ptx = pt->x - obj->getPosition()->x;
Expand Down Expand Up @@ -4223,8 +4223,8 @@ void Pathfinder::classifyFence( Object *obj, Bool insert )
Real halfsizeY = PATHFIND_CELL_SIZE_F/10.0f;
Real fenceOffset = obj->getTemplate()->getFenceXOffset();

Real c = (Real)Cos(angle);
Real s = (Real)Sin(angle);
Real c = (Real)WWMath::CosTrig(angle);
Real s = (Real)WWMath::SinTrig(angle);

const Real STEP_SIZE = PATHFIND_CELL_SIZE_F * 0.5f; // in theory, should be PATHFIND_CELL_SIZE_F exactly, but needs to be smaller to avoid aliasing problems
Real ydx = s * STEP_SIZE;
Expand Down Expand Up @@ -4431,8 +4431,8 @@ void Pathfinder::internal_classifyObjectFootprint( Object *obj, Bool insert )
Real halfsizeX = obj->getGeometryInfo().getMajorRadius();
Real halfsizeY = obj->getGeometryInfo().getMinorRadius();

Real c = (Real)Cos(angle);
Real s = (Real)Sin(angle);
Real c = (Real)WWMath::CosTrig(angle);
Real s = (Real)WWMath::SinTrig(angle);

const Real STEP_SIZE = PATHFIND_CELL_SIZE_F * 0.5f; // in theory, should be PATHFIND_CELL_SIZE_F exactly, but needs to be smaller to avoid aliasing problems
Real ydx = s * STEP_SIZE;
Expand Down
24 changes: 12 additions & 12 deletions Core/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,16 +403,16 @@ void W3DRadar::drawSingleBeaconEvent( Int pixelX, Int pixelY, Int width, Int hei

// create a triangle around the event
angle = 0.0f - addAngle;
tri[ 0 ].x = REAL_TO_INT( (DOUBLE_TO_REAL( Cos( angle ) ) * eventSize) + event->radarLoc.x );
tri[ 0 ].y = REAL_TO_INT( (DOUBLE_TO_REAL( Sin( angle ) ) * eventSize) + event->radarLoc.y );
tri[ 0 ].x = REAL_TO_INT( (DOUBLE_TO_REAL( WWMath::Cos( angle ) ) * eventSize) + event->radarLoc.x );
tri[ 0 ].y = REAL_TO_INT( (DOUBLE_TO_REAL( WWMath::Sin( angle ) ) * eventSize) + event->radarLoc.y );

angle = 2.0f * PI / 3.0f - addAngle;
tri[ 1 ].x = REAL_TO_INT( (DOUBLE_TO_REAL( Cos( angle ) ) * eventSize) + event->radarLoc.x );
tri[ 1 ].y = REAL_TO_INT( (DOUBLE_TO_REAL( Sin( angle ) ) * eventSize) + event->radarLoc.y );
tri[ 1 ].x = REAL_TO_INT( (DOUBLE_TO_REAL( WWMath::Cos( angle ) ) * eventSize) + event->radarLoc.x );
tri[ 1 ].y = REAL_TO_INT( (DOUBLE_TO_REAL( WWMath::Sin( angle ) ) * eventSize) + event->radarLoc.y );

angle = -2.0f * PI / 3.0f - addAngle;
tri[ 2 ].x = REAL_TO_INT( (DOUBLE_TO_REAL( Cos( angle ) ) * eventSize) + event->radarLoc.x );
tri[ 2 ].y = REAL_TO_INT( (DOUBLE_TO_REAL( Sin( angle ) ) * eventSize) + event->radarLoc.y );
tri[ 2 ].x = REAL_TO_INT( (DOUBLE_TO_REAL( WWMath::Cos( angle ) ) * eventSize) + event->radarLoc.x );
tri[ 2 ].y = REAL_TO_INT( (DOUBLE_TO_REAL( WWMath::Sin( angle ) ) * eventSize) + event->radarLoc.y );

// translate radar coords to screen coords
radarToPixel( &tri[ 0 ], &tri[ 0 ], pixelX, pixelY, width, height );
Expand Down Expand Up @@ -502,16 +502,16 @@ void W3DRadar::drawSingleGenericEvent( Int pixelX, Int pixelY, Int width, Int he

// create a triangle around the event
angle = 0.0f - addAngle;
tri[ 0 ].x = REAL_TO_INT( (DOUBLE_TO_REAL( Cos( angle ) ) * eventSize) + event->radarLoc.x );
tri[ 0 ].y = REAL_TO_INT( (DOUBLE_TO_REAL( Sin( angle ) ) * eventSize) + event->radarLoc.y );
tri[ 0 ].x = REAL_TO_INT( (DOUBLE_TO_REAL( WWMath::Cos( angle ) ) * eventSize) + event->radarLoc.x );
tri[ 0 ].y = REAL_TO_INT( (DOUBLE_TO_REAL( WWMath::Sin( angle ) ) * eventSize) + event->radarLoc.y );

angle = 2.0f * PI / 3.0f - addAngle;
tri[ 1 ].x = REAL_TO_INT( (DOUBLE_TO_REAL( Cos( angle ) ) * eventSize) + event->radarLoc.x );
tri[ 1 ].y = REAL_TO_INT( (DOUBLE_TO_REAL( Sin( angle ) ) * eventSize) + event->radarLoc.y );
tri[ 1 ].x = REAL_TO_INT( (DOUBLE_TO_REAL( WWMath::Cos( angle ) ) * eventSize) + event->radarLoc.x );
tri[ 1 ].y = REAL_TO_INT( (DOUBLE_TO_REAL( WWMath::Sin( angle ) ) * eventSize) + event->radarLoc.y );

angle = -2.0f * PI / 3.0f - addAngle;
tri[ 2 ].x = REAL_TO_INT( (DOUBLE_TO_REAL( Cos( angle ) ) * eventSize) + event->radarLoc.x );
tri[ 2 ].y = REAL_TO_INT( (DOUBLE_TO_REAL( Sin( angle ) ) * eventSize) + event->radarLoc.y );
tri[ 2 ].x = REAL_TO_INT( (DOUBLE_TO_REAL( WWMath::Cos( angle ) ) * eventSize) + event->radarLoc.x );
tri[ 2 ].y = REAL_TO_INT( (DOUBLE_TO_REAL( WWMath::Sin( angle ) ) * eventSize) + event->radarLoc.y );

// translate radar coords to screen coords
radarToPixel( &tri[ 0 ], &tri[ 0 ], pixelX, pixelY, width, height );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ void W3DRopeDraw::buildSegments()
SegInfo info;

Real axis = GameClientRandomValueReal(0, 2*PI);
info.wobbleAxisX = Cos(axis);
info.wobbleAxisY = Sin(axis);
info.wobbleAxisX = WWMath::Cos(axis);
info.wobbleAxisY = WWMath::Sin(axis);
info.line = NEW Line3DClass( Vector3(pos.x,pos.y,pos.z),
Vector3(pos.x,pos.y,pos.z+eachLen),
m_width * 0.5f, // width
Expand Down Expand Up @@ -186,7 +186,7 @@ void W3DRopeDraw::doDrawModule(const Matrix3D* transformMtx)

if (!m_segments.empty())
{
Real deflection = Sin(m_curWobblePhase) * m_wobbleAmp;
Real deflection = WWMath::Sin(m_curWobblePhase) * m_wobbleAmp;
const Coord3D* pos = getDrawable()->getPosition();
Vector3 start(pos->x, pos->y, pos->z + m_curZOffset);
Real eachLen = m_curLen / m_segments.size();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,10 +351,10 @@ void W3DTreeBuffer::updateSway(const BreezeInfo& info)
{
Int i;
for (i=0; i<NUM_SWAY_ENTRIES; i++) {
Real factor = Cos(i*2.0f*PI/(NUM_SWAY_ENTRIES+1.0f));
Real factor = WWMath::Cos(i*2.0f*PI/(NUM_SWAY_ENTRIES+1.0f));
Real angle = info.m_lean + (info.m_intensity * factor);
Real S = Sin(angle);
Real C = Cos(angle);
Real S = WWMath::Sin(angle);
Real C = WWMath::Cos(angle);
m_swayOffsets[i].X = info.m_directionVec.x * S;
m_swayOffsets[i].Y = info.m_directionVec.y * S;
m_swayOffsets[i].Z = C - 1.0f;
Expand Down
6 changes: 3 additions & 3 deletions Core/Libraries/Include/Lib/BaseType.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#pragma once

#include "Lib/BaseTypeCore.h"
#include "Lib/trig.h"
#include "wwmath.h"

//-----------------------------------------------------------------------------
typedef wchar_t WideChar; ///< multi-byte character representations
Expand Down Expand Up @@ -270,7 +270,7 @@ inline Real Coord2D::toAngle() const
else if (c > 1.0)
c = 1.0;

Real value = (Real)ACos( (Real)c );
Real value = (Real)WWMath::Acos( (Real)c );

// Determine sign by checking Z component of dir cross vector
// Note this is assumes 2D, and is identical to dotting the perpendicular of v with dir
Expand All @@ -295,7 +295,7 @@ inline Real Coord2D::toAngle() const
else if (c > 1.0f)
c = 1.0f;

return y < 0.0f ? -ACos(c) : ACos(c);
return y < 0.0f ? -WWMath::Acos(c) : WWMath::Acos(c);
#endif
}

Expand Down
30 changes: 0 additions & 30 deletions Core/Libraries/Include/Lib/trig.h

This file was deleted.

2 changes: 1 addition & 1 deletion Core/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ set(WW3D2_SRC
ww3dformat.cpp
ww3dformat.h
ww3dids.h
ww3dtrig.h

)

add_library(corei_ww3d2 INTERFACE)
Expand Down
52 changes: 0 additions & 52 deletions Core/Libraries/Source/WWVegas/WW3D2/ww3dtrig.h

This file was deleted.

4 changes: 4 additions & 0 deletions Core/Libraries/Source/WWVegas/WWMath/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,9 @@ target_link_libraries(core_wwmath PRIVATE
core_wwsaveload
)

if (NOT IS_VS6_BUILD)
target_link_libraries(core_wwmath PUBLIC gamemath)
endif()

# @todo Test its impact and see what to do with the legacy functions.
#add_compile_definitions(core_wwmath PUBLIC ALLOW_TEMPORARIES) # Enables legacy math with "temporaries"
1 change: 1 addition & 0 deletions Core/Libraries/Source/WWVegas/WWMath/wwmath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */


#include "always.h"
#include "wwmath.h"
#include "wwhack.h"
#include "lookuptable.h"
Expand Down
Loading