/*
** Command & Conquer Renegade(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see .
*/
/***********************************************************************************************
*** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
***********************************************************************************************
* *
* Project Name : WWMath *
* *
* $Archive:: /Commando/Code/wwmath/cardinalspline.cpp $*
* *
* Author:: Greg Hjelstrom *
* *
* $Modtime:: 9/16/01 4:07p $*
* *
* $Revision:: 6 $*
* *
*---------------------------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include "cardinalspline.h"
#include "wwdebug.h"
#include "persistfactory.h"
#include "wwmathids.h"
#include "wwhack.h"
/*
** Force-Link this module because the linker can't detect that we actually need it...
*/
DECLARE_FORCE_LINK(cardinalspline);
/*
** Save-Load stuff
*/
SimplePersistFactoryClass _CardinalSpline3DFactory;
SimplePersistFactoryClass _CardinalSpline1DFactory;
enum
{
// ID's used by CardinalSpline3D
CARDINAL3D_CHUNK_HERMITE3D = 0x02070957,
CARDINAL3D_CHUNK_TIGHTNESSKEYS,
// ID's used by CardinalSpline1D
CARDINAL1D_CHUNK_HERMITE1D = 0x02070959,
CARDINAL1D_CHUNK_TIGHTNESSKEYS
};
/*
** CardinalSpline3DClass Implementation
*/
int CardinalSpline3DClass::Add_Key(const Vector3 & point,float t)
{
int index = HermiteSpline3DClass::Add_Key(point,t);
float tightness = 0.5f;
Tightness.Insert(index,tightness);
return index;
}
void CardinalSpline3DClass::Remove_Key(int i)
{
Tightness.Delete(i);
HermiteSpline3DClass::Remove_Key(i);
}
void CardinalSpline3DClass::Clear_Keys(void)
{
Tightness.Clear();
HermiteSpline3DClass::Clear_Keys();
}
void CardinalSpline3DClass::Set_Tightness(int i,float tightness)
{
WWASSERT(i >= 0);
WWASSERT(i < Tightness.Count());
Tightness[i] = tightness;
TangentsDirty = true;
}
float CardinalSpline3DClass::Get_Tightness(int i)
{
return Tightness[i];
}
void CardinalSpline3DClass::Update_Tangents(void)
{
if (Keys.Count() < 2) {
for (int i=0; i= 0);
WWASSERT(i < Tightness.Count());
Tightness[i] = tightness;
TangentsDirty = true;
}
float CardinalSpline1DClass::Get_Tightness(int i)
{
return Tightness[i];
}
void CardinalSpline1DClass::Update_Tangents(void)
{
if (Keys.Count() < 2) {
for (int i=0; i