afx path 3d membervar cleanup

This commit is contained in:
Azaezel 2018-03-29 03:40:24 -05:00
parent 7064b41506
commit 1164ffb590
2 changed files with 66 additions and 66 deletions

View file

@ -29,7 +29,7 @@
#include "afx/util/afxPath3D.h"
afxPath3D::afxPath3D() : start_time(0), num_points(0), loop_type(LOOP_CONSTANT)
afxPath3D::afxPath3D() : mStart_time(0), mNum_points(0), mLoop_type(LOOP_CONSTANT)
{
}
@ -39,88 +39,88 @@ afxPath3D::~afxPath3D()
void afxPath3D::sortAll()
{
curve.sort();
curve_parameters.sort();
mCurve.sort();
mCurve_parameters.sort();
}
void afxPath3D::setStartTime( F32 time )
{
start_time = time;
mStart_time = time;
}
void afxPath3D::setLoopType( U32 loop_type )
{
this->loop_type = loop_type;
mLoop_type = loop_type;
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
F32 afxPath3D::getEndTime()
{
return end_time;
return mEnd_time;
}
int afxPath3D::getNumPoints()
{
return num_points;
return mNum_points;
}
Point3F afxPath3D::getPointPosition( int index )
{
if (index < 0 || index >= num_points)
if (index < 0 || index >= mNum_points)
return Point3F(0.0f, 0.0f, 0.0f);
return curve.getPoint(index);
return mCurve.getPoint(index);
}
F32 afxPath3D::getPointTime( int index )
{
if (index < 0 || index >= num_points)
if (index < 0 || index >= mNum_points)
return 0.0f;
return curve_parameters.getKeyTime(index);
return mCurve_parameters.getKeyTime(index);
}
F32 afxPath3D::getPointParameter( int index )
{
if (index < 0 || index >= num_points)
if (index < 0 || index >= mNum_points)
return 0.0f;
return curve_parameters.getKeyValue(index);
return mCurve_parameters.getKeyValue(index);
}
Point2F afxPath3D::getParameterSegment( F32 time )
{
return curve_parameters.getSegment(time);
return mCurve_parameters.getSegment(time);
}
void afxPath3D::setPointPosition( int index, Point3F &p )
{
if (index < 0 || index >= num_points)
if (index < 0 || index >= mNum_points)
return;
curve.setPoint(index, p);
mCurve.setPoint(index, p);
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
F32 afxPath3D::calcCurveTime( F32 time )
{
if( time <= start_time )
if( time <= mStart_time )
return 0.0f;
if( time <= end_time )
return time-start_time;
if( time <= mEnd_time )
return time-mStart_time;
switch( loop_type )
switch( mLoop_type )
{
case LOOP_CYCLE :
{
return mFmod( time-start_time, end_time-start_time );
return mFmod( time-mStart_time, mEnd_time-mStart_time );
}
case LOOP_OSCILLATE :
{
F32 t1 = time-start_time;
F32 t2 = end_time-start_time;
F32 t1 = time- mStart_time;
F32 t2 = mEnd_time - mStart_time;
if( (int)(t1/t2) % 2 ) // odd segment
return t2 - mFmod( t1, t2 );
@ -129,26 +129,26 @@ F32 afxPath3D::calcCurveTime( F32 time )
}
case LOOP_CONSTANT :
default:
return end_time;
return mEnd_time;
}
}
Point3F afxPath3D::evaluateAtTime( F32 time )
{
F32 ctime = calcCurveTime( time );
F32 param = curve_parameters.evaluate( ctime );
return curve.evaluate(param);
F32 param = mCurve_parameters.evaluate( ctime );
return mCurve.evaluate(param);
}
Point3F afxPath3D::evaluateAtTime(F32 t0, F32 t1)
{
F32 ctime = calcCurveTime(t0);
F32 param = curve_parameters.evaluate( ctime );
Point3F p0 = curve.evaluate(param);
F32 param = mCurve_parameters.evaluate( ctime );
Point3F p0 = mCurve.evaluate(param);
ctime = calcCurveTime(t1);
param = curve_parameters.evaluate( ctime );
Point3F p1 = curve.evaluate(param);
param = mCurve_parameters.evaluate( ctime );
Point3F p1 = mCurve.evaluate(param);
return p1-p0;
}
@ -156,21 +156,21 @@ Point3F afxPath3D::evaluateAtTime(F32 t0, F32 t1)
Point3F afxPath3D::evaluateTangentAtTime( F32 time )
{
F32 ctime = calcCurveTime( time );
F32 param = curve_parameters.evaluate( ctime );
return curve.evaluateTangent(param);
F32 param = mCurve_parameters.evaluate( ctime );
return mCurve.evaluateTangent(param);
}
Point3F afxPath3D::evaluateTangentAtPoint( int index )
{
F32 param = curve_parameters.getKeyValue(index);
return curve.evaluateTangent(param);
F32 param = mCurve_parameters.getKeyValue(index);
return mCurve.evaluateTangent(param);
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
void afxPath3D::buildPath( int num_points, Point3F curve_points[], F32 start_time, F32 end_time )
{
this->num_points = num_points;
mNum_points = num_points;
// Add points to path
F32 param_inc = 1.0f / (F32)(num_points - 1);
@ -179,10 +179,10 @@ void afxPath3D::buildPath( int num_points, Point3F curve_points[], F32 start_tim
{
if( i == num_points-1 )
param = 1.0f;
curve.addPoint( param, curve_points[i] );
mCurve.addPoint( param, curve_points[i] );
}
curve.computeTangents();
mCurve.computeTangents();
initPathParametersNEW( curve_points, start_time, end_time );
@ -191,7 +191,7 @@ void afxPath3D::buildPath( int num_points, Point3F curve_points[], F32 start_tim
void afxPath3D::buildPath( int num_points, Point3F curve_points[], F32 speed )
{
this->num_points = num_points;
mNum_points = num_points;
// Add points to path
F32 param_inc = 1.0f / (F32)(num_points - 1);
@ -200,7 +200,7 @@ void afxPath3D::buildPath( int num_points, Point3F curve_points[], F32 speed )
{
if( i == num_points-1 )
param = 1.0f;
curve.addPoint( param, curve_points[i] );
mCurve.addPoint( param, curve_points[i] );
}
initPathParameters( curve_points, speed );
@ -211,7 +211,7 @@ void afxPath3D::buildPath( int num_points, Point3F curve_points[], F32 speed )
void afxPath3D::buildPath( int num_points, Point3F curve_points[],
F32 point_times[], F32 time_offset, F32 time_factor )
{
this->num_points = num_points;
mNum_points = num_points;
// Add points to path
F32 param_inc = 1.0f / (F32)(num_points - 1);
@ -220,20 +220,20 @@ void afxPath3D::buildPath( int num_points, Point3F curve_points[],
{
if( i == num_points-1 )
param = 1.0f;
curve.addPoint( param, curve_points[i] );
mCurve.addPoint( param, curve_points[i] );
curve_parameters.addKey( (point_times[i]+time_offset)*time_factor, param );
mCurve_parameters.addKey( (point_times[i]+time_offset)*time_factor, param );
}
// Set end time
end_time = (point_times[num_points-1]+time_offset)*time_factor;
mEnd_time = (point_times[num_points-1]+time_offset)*time_factor;
sortAll();
}
void afxPath3D::buildPath( int num_points, Point3F curve_points[], Point2F curve_params[] )
{
this->num_points = num_points;
mNum_points = num_points;
// Add points to path
F32 param_inc = 1.0f / (F32)(num_points - 1);
@ -242,22 +242,22 @@ void afxPath3D::buildPath( int num_points, Point3F curve_points[], Point2F curve
{
if( i == num_points-1 )
param = 1.0f;
curve.addPoint( param, curve_points[i] );
mCurve.addPoint( param, curve_points[i] );
}
//
for (int i = 0; i < num_points; i++)
curve_parameters.addKey( curve_params[i] );
mCurve_parameters.addKey( curve_params[i] );
// Set end time
end_time = curve_params[num_points - 1].x;
mEnd_time = curve_params[num_points - 1].x;
sortAll();
}
void afxPath3D::reBuildPath()
{
curve.computeTangents();
mCurve.computeTangents();
sortAll();
}
@ -265,7 +265,7 @@ void afxPath3D::initPathParameters( Point3F curve_points[], F32 speed )
{
// Compute the time for each point dependent on the speed of the character and the
// distance it must travel (approximately!)
int num_segments = num_points - 1;
int num_segments = mNum_points - 1;
F32 *point_distances = new F32[num_segments];
for( int i = 0; i < num_segments; i++ )
{
@ -283,14 +283,14 @@ void afxPath3D::initPathParameters( Point3F curve_points[], F32 speed )
last_time = times[i];
}
curve_parameters.addKey( 0, 0.0f );//start_time, 0.0f );
F32 param_inc = 1.0f / (F32)(num_points - 1);
mCurve_parameters.addKey( 0, 0.0f );//start_time, 0.0f );
F32 param_inc = 1.0f / (F32)(mNum_points - 1);
F32 param = 0.0f + param_inc;
for( int i = 0; i < num_segments; i++, param += param_inc )
curve_parameters.addKey( times[i], param );
mCurve_parameters.addKey( times[i], param );
// Set end time
end_time = times[num_segments-1];
mEnd_time = times[num_segments-1];
if (point_distances)
delete [] point_distances;
@ -300,7 +300,7 @@ void afxPath3D::initPathParameters( Point3F curve_points[], F32 speed )
void afxPath3D::initPathParametersNEW( Point3F curve_points[], F32 start_time, F32 end_time )
{
int num_segments = num_points - 1;
int num_segments = mNum_points - 1;
F32 *point_distances = new F32[num_segments];
F32 total_distance = 0.0f;
for( int i = 0; i < num_segments; i++ )
@ -315,19 +315,19 @@ void afxPath3D::initPathParametersNEW( Point3F curve_points[], F32 start_time, F
F32 duration = end_time - start_time;
F32 time = 0.0f; //start_time;
curve_parameters.addKey( time, 0.0f );
F32 param_inc = 1.0f / (F32)(num_points - 1);
mCurve_parameters.addKey( time, 0.0f );
F32 param_inc = 1.0f / (F32)(mNum_points - 1);
F32 param = 0.0f + param_inc;
for( int i=0; i < num_segments; i++, param += param_inc )
{
time += (point_distances[i]/total_distance) * duration;
curve_parameters.addKey( time, param );
mCurve_parameters.addKey( time, param );
}
// Set end time ????
//end_time = time;
this->start_time = start_time;
this->end_time = end_time;
mStart_time = start_time;
mEnd_time = end_time;
if (point_distances)
delete [] point_distances;
@ -336,7 +336,7 @@ void afxPath3D::initPathParametersNEW( Point3F curve_points[], F32 start_time, F
void afxPath3D::print()
{
// curve.print();
curve_parameters.print();
mCurve_parameters.print();
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//