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
6 changes: 3 additions & 3 deletions trinity/Curves/Tr2CurveEulerRotationExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ float Random( float a, float b )
{
return ( ( b - a ) * 0.41f ) + a;
}
return ( ( b - a ) * ( (float)rand() / RAND_MAX ) ) + a;
return ( ( b - a ) * ( (float)rand() / float( RAND_MAX ) ) ) + a;
}

// --------------------------------------------------------------------------------
Expand Down Expand Up @@ -86,7 +86,7 @@ Tr2CurveEulerRotationExpression::Tr2CurveEulerRotationExpression( IRoot* lockobj
PARENTLOCK( m_inputs ),
m_currentValue( 0, 0, 0, 1 ),
m_timeScale( 1 ),
m_randomConstant( float( rand() ) / RAND_MAX )
m_randomConstant( float( rand() ) / float( RAND_MAX ) )
{
}

Expand Down Expand Up @@ -297,7 +297,7 @@ Quaternion* Tr2CurveEulerRotationExpression::GetValueDoubleDotAt( Quaternion* in
// --------------------------------------------------------------------------------
void Tr2CurveEulerRotationExpression::ResetRandomConstant()
{
m_randomConstant = float( rand() ) / RAND_MAX;
m_randomConstant = float( rand() ) / float( RAND_MAX );
}

// --------------------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions trinity/Curves/Tr2CurveScalarExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ float Random( float a, float b )
{
return ( ( b - a ) * 0.41f ) + a;
}
return ( ( b - a ) * ( (float)rand() / RAND_MAX ) ) + a;
return ( ( b - a ) * ( (float)rand() / float( RAND_MAX ) ) ) + a;
}

// --------------------------------------------------------------------------------
Expand Down Expand Up @@ -89,7 +89,7 @@ Tr2CurveScalarExpression::Tr2CurveScalarExpression( IRoot* lockobj ) :
PARENTLOCK( m_inputs ),
m_currentValue( 0 ),
m_timeScale( 1 ),
m_randomConstant( float( rand() ) / RAND_MAX )
m_randomConstant( float( rand() ) / float( RAND_MAX ) )
{
}

Expand Down Expand Up @@ -236,7 +236,7 @@ float Tr2CurveScalarExpression::GetRandomConstant() const
// --------------------------------------------------------------------------------
void Tr2CurveScalarExpression::ResetRandomConstant()
{
m_randomConstant = float( rand() ) / RAND_MAX;
m_randomConstant = float( rand() ) / float( RAND_MAX );
}

// --------------------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions trinity/Curves/Tr2CurveVector3Expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ float Random( float a, float b )
{
return ( ( b - a ) * 0.41f ) + a;
}
return ( ( b - a ) * ( (float)rand() / RAND_MAX ) ) + a;
return ( ( b - a ) * ( (float)rand() / float( RAND_MAX ) ) ) + a;
}

// --------------------------------------------------------------------------------
Expand Down Expand Up @@ -85,7 +85,7 @@ Tr2CurveVector3Expression::Tr2CurveVector3Expression( IRoot* lockobj ) :
PARENTLOCK( m_inputs ),
m_currentValue( 0, 0, 0 ),
m_timeScale( 1 ),
m_randomConstant( float( rand() ) / RAND_MAX )
m_randomConstant( float( rand() ) / float( RAND_MAX ) )
{
}

Expand Down Expand Up @@ -349,7 +349,7 @@ Vector3d* Tr2CurveVector3Expression::InterpolatedPosition( Vector3d* out, Be::Ti
// --------------------------------------------------------------------------------
void Tr2CurveVector3Expression::ResetRandomConstant()
{
m_randomConstant = float( rand() ) / RAND_MAX;
m_randomConstant = float( rand() ) / float( RAND_MAX );
}

// --------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion trinity/Curves/Tr2ScalarExprKeyCurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static float perlin_wrap_simple( float x )
// --------------------------------------------------------------------------------------
static float frandom( float a, float b )
{
return ( ( b - a ) * ( (float)rand() / RAND_MAX ) ) + a;
return ( ( b - a ) * ( (float)rand() / float( RAND_MAX ) ) ) + a;
}

namespace
Expand Down
4 changes: 2 additions & 2 deletions trinity/Eve/Renderable/Stretch/EveStretch2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ EveStretch2::EveStretch2( IRoot* lockObj ) :
m_destinationTransform( IdentityMatrix() ),
m_vb( BlueSharedString( "EveStretch2VB" ), &GetEveStretch2Quads )
{
m_effectData[0] = Vector4( 0, 0, 0, float( rand() ) / RAND_MAX );
m_effectData[0] = Vector4( 0, 0, 0, float( rand() ) / float( RAND_MAX ) );
m_effectData[0] = Vector4( 1, 0, 0, 0 );
}

Expand Down Expand Up @@ -136,7 +136,7 @@ float EveStretch2::GetCurveDuration()

void EveStretch2::StartFiring( float delay )
{
m_effectData[0].w = float( rand() ) / RAND_MAX;
m_effectData[0].w = float( rand() ) / float( RAND_MAX );
if( m_start )
{
m_start->PlayFrom( -delay );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ std::vector<Vector3> ProcessLifetime::CalculateBehavior( std::vector<DroneAgent>

float ProcessLifetime::GetRandomOffset( float cylWidth ) const
{
return static_cast<float>( RAND_MAX / ( 2 * ( cylWidth * m_wanderAmount ) ) );
return static_cast<float>( float( RAND_MAX ) / ( 2 * ( cylWidth * m_wanderAmount ) ) );
}

bool ProcessLifetime::ProcessTunnel( DroneAgent& agent, SplineTunnel& tunnel, int& pointID, float boundingSphere )
Expand Down Expand Up @@ -402,7 +402,7 @@ void ProcessLifetime::FindASpawnPoint( DroneAgent& agent, ProcessLifetimeData* d
Vector3 point = ( *tunnel )->splinePoints[0].pos;
for( int i = 0; i < 3; i++ )
{
point[i] += -( *tunnel )->pointOfNoReturnSize + static_cast<float>( rand() ) / ( static_cast<float>( RAND_MAX / ( 2 * ( *tunnel )->pointOfNoReturnSize ) ) );
point[i] += -( *tunnel )->pointOfNoReturnSize + static_cast<float>( rand() ) / ( static_cast<float>( float( RAND_MAX ) / ( 2 * ( *tunnel )->pointOfNoReturnSize ) ) );
}
potentialPoints.push_back( point );
potentialRotations.push_back( ( *tunnel )->splinePoints[0].rot );
Expand Down
4 changes: 2 additions & 2 deletions trinity/Eve/SpaceObject/Children/EveChildParticleSphere.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ void EveChildParticleSphere::ApplyConstraint( const Vector3& previousReferencePo
void EveChildParticleSphere::FillParticleData( float** particle, const Vector3& previousReferencePosition, const Vector3& velocityDirection )
{
auto randf = []() {
return float( rand() ) / RAND_MAX;
return float( rand() ) / float( RAND_MAX );
};

if( m_positionElement.m_bufferType != Tr2ParticleElementData::COUNT )
Expand Down Expand Up @@ -410,7 +410,7 @@ void EveChildParticleSphere::AddParticles( const Vector3& previousReferencePosit
}

auto randf = []() {
return float( rand() ) / RAND_MAX;
return float( rand() ) / float( RAND_MAX );
};

float* particle[Tr2ParticleElementData::COUNT];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ float RandomHash( const EveSmartLightAttributeModifierExpressionBucket* bucket,

float Random( float a, float b )
{
return ( ( b - a ) * ( (float)rand() / RAND_MAX ) ) + a;
return ( ( b - a ) * ( (float)rand() / float( RAND_MAX ) ) ) + a;
}

float Input( const EveSmartLightAttributeModifierExpressionBucket* bucket, float index )
Expand Down Expand Up @@ -84,7 +84,7 @@ CcpParser::Constant s_constants[] = {

EveSmartLightAttributeModifierExpressionBucket::EveSmartLightAttributeModifierExpressionBucket( IRoot* lockobj ) :
PARENTLOCK( m_inputs ),
m_randomConstant( float( rand() ) / RAND_MAX )
m_randomConstant( float( rand() ) / float( RAND_MAX ) )
{
m_name = "ExpressionBucket";
m_expression = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void EveDistributionSpawnerTriggerSnake::UpdateSyncronous( const EveUpdateContex
m_currentTravelTime = 0.f;
m_travelProgress = 0.f;
m_numDestinationsReached++;
m_travelDurationToNextPoint = Lerp( m_minTimeBetweenTriggers, m_maxTimeBetweenTriggers, (float)rand() / RAND_MAX );
m_travelDurationToNextPoint = Lerp( m_minTimeBetweenTriggers, m_maxTimeBetweenTriggers, (float)rand() / float( RAND_MAX ) );

Vector3 searchPoint = Lerp( m_lastTarget, m_targetPoint, 1.3f ); // overshoot to reduce u-turns
int32_t closetsPlace = owner.GetClosestFreePlacement( searchPoint );
Expand Down
10 changes: 5 additions & 5 deletions trinity/Eve/Volume/EveEllipsoidVolume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,18 @@ void EveEllipsoidVolume::GeneratePointsInVolume( std::vector<Vector3>& points, s

for( size_t i = 0; i < howManyToAdd; i++ )
{
float a = TRI_2PI * ( float( rand() ) / RAND_MAX );
float z = ( float( rand() ) / RAND_MAX ) * 2.f - 1.f;
float a = TRI_2PI * ( float( rand() ) / float( RAND_MAX ) );
float z = ( float( rand() ) / float( RAND_MAX ) ) * 2.f - 1.f;
Vector3 angle( sqrt( 1.f - z * z ) * cos( a ), sqrt( 1.f - z * z ) * sin( a ), z );
angle = Normalize( angle );

if( ( float( rand() ) / RAND_MAX ) > sizeDifference )
if( ( float( rand() ) / float( RAND_MAX ) ) > sizeDifference )
{
position = angle * ( m_innerShape + ( m_shape - m_innerShape ) * pow( (float)rand() / RAND_MAX, 0.75f * fallOffFactor ) );
position = angle * ( m_innerShape + ( m_shape - m_innerShape ) * pow( (float)rand() / float( RAND_MAX ), 0.75f * fallOffFactor ) );
}
else
{
position = angle * ( m_innerShape * pow( (float)rand() / RAND_MAX, 1.f / 3.f ) );
position = angle * ( m_innerShape * pow( (float)rand() / float( RAND_MAX ), 1.f / 3.f ) );
}

points.push_back( position );
Expand Down
16 changes: 8 additions & 8 deletions trinity/Eve/Volume/EveSphereVolume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ void EveSphereVolume::GeneratePointsInVolume( std::vector<Vector3>& points, size
{
for( size_t i = 0; i < howManyToAdd; i++ )
{
float dist = m_innerSphere.radius + circleDiffRange * pow( (float)rand() / RAND_MAX, 1.f / 3.f );
float dist = m_innerSphere.radius + circleDiffRange * pow( (float)rand() / float( RAND_MAX ), 1.f / 3.f );

float a = TRI_2PI * ( float( rand() ) / RAND_MAX );
float z = ( float( rand() ) / RAND_MAX ) * 2.f - 1.f;
float a = TRI_2PI * ( float( rand() ) / float( RAND_MAX ) );
float z = ( float( rand() ) / float( RAND_MAX ) ) * 2.f - 1.f;
Vector3 angle( sqrt( 1.f - z * z ) * cos( a ), sqrt( 1.f - z * z ) * sin( a ), z );

position = angle * dist;
Expand All @@ -80,19 +80,19 @@ void EveSphereVolume::GeneratePointsInVolume( std::vector<Vector3>& points, size

for( size_t i = 0; i < howManyToAdd; i++ )
{
if( (float)rand() / RAND_MAX < sizeDifference )
if( (float)rand() / float( RAND_MAX ) < sizeDifference )
{
// inner volume
dist = m_innerSphere.radius * pow( (float)rand() / RAND_MAX, 1.f / 3.f );
dist = m_innerSphere.radius * pow( (float)rand() / float( RAND_MAX ), 1.f / 3.f );
}
else
{
// outer volume
dist = m_innerSphere.radius + circleDiffRange * pow( (float)rand() / RAND_MAX, fallOffFactor );
dist = m_innerSphere.radius + circleDiffRange * pow( (float)rand() / float( RAND_MAX ), fallOffFactor );
}

float a = TRI_2PI * ( float( rand() ) / RAND_MAX );
float z = ( float( rand() ) / RAND_MAX ) * 2.f - 1.f;
float a = TRI_2PI * ( float( rand() ) / float( RAND_MAX ) );
float z = ( float( rand() ) / float( RAND_MAX ) ) * 2.f - 1.f;
Vector3 angle( sqrt( 1.f - z * z ) * cos( a ), sqrt( 1.f - z * z ) * sin( a ), z );

position = angle * dist;
Expand Down