Added SetVertsFromSplines to AMV. Moved const to the left side. Documentation for all new functions.
This commit is contained in:
+81
-112
@@ -63,9 +63,12 @@ ActorMultiVertex::ActorMultiVertex()
|
||||
|
||||
_EffectMode = EffectMode_Normal;
|
||||
_TextureMode = TextureMode_Modulate;
|
||||
_using_spline= false;
|
||||
_spline.redimension(3);
|
||||
_spline.m_owned_by_actor= true;
|
||||
_splines.resize(num_vert_splines);
|
||||
for(size_t i= 0; i < num_vert_splines; ++i)
|
||||
{
|
||||
_splines[i].redimension(3);
|
||||
_splines[i].m_owned_by_actor= true;
|
||||
}
|
||||
}
|
||||
|
||||
ActorMultiVertex::~ActorMultiVertex()
|
||||
@@ -77,13 +80,12 @@ ActorMultiVertex::ActorMultiVertex( const ActorMultiVertex &cpy ):
|
||||
Actor( cpy )
|
||||
{
|
||||
#define CPY(a) a = cpy.a
|
||||
CPY( _spline );
|
||||
CPY( _using_spline );
|
||||
CPY( AMV_Tweens );
|
||||
CPY( AMV_current );
|
||||
CPY( AMV_start );
|
||||
CPY( _EffectMode );
|
||||
CPY( _TextureMode );
|
||||
CPY( _splines );
|
||||
#undef CPY
|
||||
|
||||
if( cpy._Texture != NULL )
|
||||
@@ -200,71 +202,6 @@ void ActorMultiVertex::SetVertexCoords( int index, float TexCoordX, float TexCoo
|
||||
AMV_DestTweenState().vertices[index].t = RageVector2( TexCoordX, TexCoordY );
|
||||
}
|
||||
|
||||
bool ActorMultiVertex::GetUseSpline()
|
||||
{
|
||||
return _using_spline;
|
||||
}
|
||||
|
||||
void ActorMultiVertex::SetUseSpline(bool use)
|
||||
{
|
||||
_using_spline= use;
|
||||
}
|
||||
|
||||
void ActorMultiVertex::SplineSetPoint(size_t i, float x , float y , float z)
|
||||
{
|
||||
vector<float> v(3);
|
||||
v[0]= x; v[1]= y; v[2]= z;
|
||||
_spline.set_point(i, v);
|
||||
}
|
||||
|
||||
void ActorMultiVertex::SplineResize(size_t s)
|
||||
{
|
||||
_spline.resize(s);
|
||||
}
|
||||
|
||||
size_t ActorMultiVertex::SplineSize()
|
||||
{
|
||||
return _spline.size();
|
||||
}
|
||||
|
||||
void ActorMultiVertex::SplineSolve()
|
||||
{
|
||||
if(_spline.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
_spline.solve();
|
||||
float num_parts= 0.0f;
|
||||
size_t num_verts= GetNumVertices();
|
||||
switch(GetDestDrawMode())
|
||||
{
|
||||
case DrawMode_Quads:
|
||||
break;
|
||||
case DrawMode_QuadStrip:
|
||||
break;
|
||||
case DrawMode_Fan:
|
||||
break;
|
||||
case DrawMode_Strip:
|
||||
break;
|
||||
case DrawMode_Triangles:
|
||||
break;
|
||||
case DrawMode_LineStrip:
|
||||
{
|
||||
float conversion= static_cast<float>(_spline.size()-1) / static_cast<float>(num_verts-1);
|
||||
for(size_t i= 0; i < num_verts; ++i)
|
||||
{
|
||||
float t= i * conversion;
|
||||
vector<float> p;
|
||||
_spline.evaluate(t, p);
|
||||
SetVertexPos(i, p[0], p[1], p[2]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DrawMode_SymmetricQuadStrip:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ActorMultiVertex::DrawPrimitives()
|
||||
{
|
||||
Actor::SetGlobalRenderStates(); // set Actor-specified render states
|
||||
@@ -380,6 +317,61 @@ bool ActorMultiVertex::EarlyAbortDraw() const
|
||||
return false;
|
||||
}
|
||||
|
||||
void ActorMultiVertex::SetVertsFromSplinesInternal(size_t num_splines, size_t offset)
|
||||
{
|
||||
vector<RageSpriteVertex>& verts= AMV_DestTweenState().vertices;
|
||||
size_t first= AMV_DestTweenState().FirstToDraw + offset;
|
||||
size_t num_verts= AMV_DestTweenState().GetSafeNumToDraw(AMV_DestTweenState()._DrawMode, AMV_DestTweenState().NumToDraw);
|
||||
float tper[num_splines]= {0.0f};
|
||||
float num_parts= static_cast<float>(num_verts - offset) /
|
||||
static_cast<float>(num_splines);
|
||||
for(size_t i= 0; i < num_splines; ++i)
|
||||
{
|
||||
tper[i]= _splines[i].get_max_t() / num_parts;
|
||||
}
|
||||
for(size_t v= 0; v < num_verts; ++v)
|
||||
{
|
||||
vector<float> pos;
|
||||
const int spi= v%num_splines;
|
||||
_splines[spi].evaluate(static_cast<float>(v) * tper[spi], pos);
|
||||
verts[v+first].p.x= pos[0];
|
||||
verts[v+first].p.y= pos[1];
|
||||
verts[v+first].p.z= pos[2];
|
||||
}
|
||||
}
|
||||
|
||||
void ActorMultiVertex::SetVertsFromSplines()
|
||||
{
|
||||
if(AMV_DestTweenState().vertices.empty()) { return; }
|
||||
switch(AMV_DestTweenState()._DrawMode)
|
||||
{
|
||||
case DrawMode_Quads:
|
||||
SetVertsFromSplinesInternal(4, 0);
|
||||
break;
|
||||
case DrawMode_QuadStrip:
|
||||
case DrawMode_Strip:
|
||||
SetVertsFromSplinesInternal(2, 0);
|
||||
break;
|
||||
case DrawMode_Fan:
|
||||
// Skip the first vert because it is the center of the fan. -Kyz
|
||||
SetVertsFromSplinesInternal(1, 1);
|
||||
break;
|
||||
case DrawMode_Triangles:
|
||||
case DrawMode_SymmetricQuadStrip:
|
||||
SetVertsFromSplinesInternal(3, 0);
|
||||
break;
|
||||
case DrawMode_LineStrip:
|
||||
SetVertsFromSplinesInternal(1, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CubicSplineN* ActorMultiVertex::GetSpline(size_t i)
|
||||
{
|
||||
ASSERT(i < num_vert_splines);
|
||||
return &(_splines[i]);
|
||||
}
|
||||
|
||||
void ActorMultiVertex::SetCurrentTweenStart()
|
||||
{
|
||||
AMV_start= AMV_current;
|
||||
@@ -709,6 +701,23 @@ public:
|
||||
COMMON_RETURN_SELF;
|
||||
}
|
||||
|
||||
static int GetSpline(T* p, lua_State* L)
|
||||
{
|
||||
size_t i= static_cast<size_t>(IArg(1)-1);
|
||||
if(i >= ActorMultiVertex::num_vert_splines)
|
||||
{
|
||||
luaL_error(L, "Spline index must be greater than 0 and less than or equal to %zu.", ActorMultiVertex::num_vert_splines);
|
||||
}
|
||||
p->GetSpline(i)->PushSelf(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int SetVertsFromSplines(T* p, lua_State* L)
|
||||
{
|
||||
p->SetVertsFromSplines();
|
||||
COMMON_RETURN_SELF;
|
||||
}
|
||||
|
||||
static int SetTexture( T* p, lua_State *L )
|
||||
{
|
||||
RageTexture *Texture = Luna<RageTexture>::check(L, 1);
|
||||
@@ -729,42 +738,6 @@ public:
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
DEFINE_METHOD(GetUseSpline, GetUseSpline());
|
||||
static int SplineSize(T* p, lua_State* L)
|
||||
{
|
||||
lua_pushnumber(L, p->SplineSize());
|
||||
return 1;
|
||||
}
|
||||
static int SetUseSpline(T* p, lua_State* L)
|
||||
{
|
||||
p->SetUseSpline(lua_toboolean(L, 1));
|
||||
COMMON_RETURN_SELF;
|
||||
}
|
||||
static int SplineSetPoint(T* p, lua_State* L)
|
||||
{
|
||||
size_t i= IArg(1)-1;
|
||||
if(i >= p->SplineSize())
|
||||
{
|
||||
luaL_error(L, "Spline point index greater than the number of points.");
|
||||
}
|
||||
p->SplineSetPoint(i, FArg(2), FArg(3), FArg(4));
|
||||
COMMON_RETURN_SELF;
|
||||
}
|
||||
static int SplineResize(T* p, lua_State* L)
|
||||
{
|
||||
int s= IArg(1);
|
||||
if(s < 0)
|
||||
{
|
||||
luaL_error(L, "Negative spline size not allowed.");
|
||||
}
|
||||
p->SplineResize(static_cast<size_t>(s));
|
||||
COMMON_RETURN_SELF;
|
||||
}
|
||||
static int SplineSolve(T* p, lua_State* L)
|
||||
{
|
||||
p->SplineSolve();
|
||||
COMMON_RETURN_SELF;
|
||||
}
|
||||
|
||||
LunaActorMultiVertex()
|
||||
{
|
||||
@@ -786,12 +759,8 @@ public:
|
||||
ADD_METHOD( GetCurrFirstToDraw );
|
||||
ADD_METHOD( GetCurrNumToDraw );
|
||||
|
||||
ADD_METHOD(GetUseSpline);
|
||||
ADD_METHOD(SetUseSpline);
|
||||
ADD_METHOD(SplineSize);
|
||||
ADD_METHOD(SplineResize);
|
||||
ADD_METHOD(SplineSetPoint);
|
||||
ADD_METHOD(SplineSolve);
|
||||
ADD_METHOD( GetSpline );
|
||||
ADD_METHOD( SetVertsFromSplines );
|
||||
|
||||
// Copy from RageTexture
|
||||
ADD_METHOD( SetTexture );
|
||||
|
||||
Reference in New Issue
Block a user