migrate Vertex2f to Vector2

This commit is contained in:
Huabing.Xu 2014-04-02 15:25:37 +08:00
parent 56aa50617c
commit 2e315fb215
12 changed files with 125 additions and 124 deletions

View File

@ -454,9 +454,9 @@ CC_DEPRECATED_ATTRIBUTE static inline bool ccc4FEqual(Color4F a, Color4F b)
return a.r == b.r && a.g == b.g && a.b == b.b && a.a == b.a;
}
CC_DEPRECATED_ATTRIBUTE static inline Vertex2F vertex2(const float x, const float y)
CC_DEPRECATED_ATTRIBUTE static inline Vector2 vertex2(const float x, const float y)
{
Vertex2F c(x, y);
Vector2 c(x, y);
return c;
}
@ -775,7 +775,8 @@ CC_DEPRECATED_ATTRIBUTE typedef Rect CCRect;
CC_DEPRECATED_ATTRIBUTE typedef Color3B ccColor3B;
CC_DEPRECATED_ATTRIBUTE typedef Color4F ccColor4F;
CC_DEPRECATED_ATTRIBUTE typedef Color4B ccColor4B;
CC_DEPRECATED_ATTRIBUTE typedef Vertex2F ccVertex2F;
CC_DEPRECATED_ATTRIBUTE typedef Vector2 ccVertex2F;
CC_DEPRECATED_ATTRIBUTE typedef Vector2 Vertex2F;
CC_DEPRECATED_ATTRIBUTE typedef Vector3 ccVertex3F;
CC_DEPRECATED_ATTRIBUTE typedef Vector3 Vertex3F;
CC_DEPRECATED_ATTRIBUTE typedef Tex2F ccTex2F;

View File

@ -34,67 +34,67 @@
NS_CC_BEGIN
// Vertex2F == CGPoint in 32-bits, but not in 64-bits (OS X)
// Vector2 == CGPoint in 32-bits, but not in 64-bits (OS X)
// that's why the "v2f" functions are needed
static Vertex2F v2fzero(0.0f,0.0f);
static Vector2 v2fzero(0.0f,0.0f);
static inline Vertex2F v2f(float x, float y)
static inline Vector2 v2f(float x, float y)
{
Vertex2F ret(x, y);
Vector2 ret(x, y);
return ret;
}
static inline Vertex2F v2fadd(const Vertex2F &v0, const Vertex2F &v1)
static inline Vector2 v2fadd(const Vector2 &v0, const Vector2 &v1)
{
return v2f(v0.x+v1.x, v0.y+v1.y);
}
static inline Vertex2F v2fsub(const Vertex2F &v0, const Vertex2F &v1)
static inline Vector2 v2fsub(const Vector2 &v0, const Vector2 &v1)
{
return v2f(v0.x-v1.x, v0.y-v1.y);
}
static inline Vertex2F v2fmult(const Vertex2F &v, float s)
static inline Vector2 v2fmult(const Vector2 &v, float s)
{
return v2f(v.x * s, v.y * s);
}
static inline Vertex2F v2fperp(const Vertex2F &p0)
static inline Vector2 v2fperp(const Vector2 &p0)
{
return v2f(-p0.y, p0.x);
}
static inline Vertex2F v2fneg(const Vertex2F &p0)
static inline Vector2 v2fneg(const Vector2 &p0)
{
return v2f(-p0.x, - p0.y);
}
static inline float v2fdot(const Vertex2F &p0, const Vertex2F &p1)
static inline float v2fdot(const Vector2 &p0, const Vector2 &p1)
{
return p0.x * p1.x + p0.y * p1.y;
}
static inline Vertex2F v2fforangle(float _a_)
static inline Vector2 v2fforangle(float _a_)
{
return v2f(cosf(_a_), sinf(_a_));
}
static inline Vertex2F v2fnormalize(const Vertex2F &p)
static inline Vector2 v2fnormalize(const Vector2 &p)
{
Point r = Point(p.x, p.y).normalize();
return v2f(r.x, r.y);
}
static inline Vertex2F __v2f(const Point &v)
static inline Vector2 __v2f(const Point &v)
{
//#ifdef __LP64__
return v2f(v.x, v.y);
// #else
// return * ((Vertex2F*) &v);
// return * ((Vector2*) &v);
// #endif
}
static inline Tex2F __t(const Vertex2F &v)
static inline Tex2F __t(const Vector2 &v)
{
return *(Tex2F*)&v;
}
@ -256,10 +256,10 @@ void DrawNode::drawDot(const Point &pos, float radius, const Color4F &color)
unsigned int vertex_count = 2*3;
ensureCapacity(vertex_count);
V2F_C4B_T2F a = {Vertex2F(pos.x - radius, pos.y - radius), Color4B(color), Tex2F(-1.0, -1.0) };
V2F_C4B_T2F b = {Vertex2F(pos.x - radius, pos.y + radius), Color4B(color), Tex2F(-1.0, 1.0) };
V2F_C4B_T2F c = {Vertex2F(pos.x + radius, pos.y + radius), Color4B(color), Tex2F( 1.0, 1.0) };
V2F_C4B_T2F d = {Vertex2F(pos.x + radius, pos.y - radius), Color4B(color), Tex2F( 1.0, -1.0) };
V2F_C4B_T2F a = {Vector2(pos.x - radius, pos.y - radius), Color4B(color), Tex2F(-1.0, -1.0) };
V2F_C4B_T2F b = {Vector2(pos.x - radius, pos.y + radius), Color4B(color), Tex2F(-1.0, 1.0) };
V2F_C4B_T2F c = {Vector2(pos.x + radius, pos.y + radius), Color4B(color), Tex2F( 1.0, 1.0) };
V2F_C4B_T2F d = {Vector2(pos.x + radius, pos.y - radius), Color4B(color), Tex2F( 1.0, -1.0) };
V2F_C4B_T2F_Triangle *triangles = (V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount);
V2F_C4B_T2F_Triangle triangle0 = {a, b, c};
@ -277,23 +277,23 @@ void DrawNode::drawSegment(const Point &from, const Point &to, float radius, con
unsigned int vertex_count = 6*3;
ensureCapacity(vertex_count);
Vertex2F a = __v2f(from);
Vertex2F b = __v2f(to);
Vector2 a = __v2f(from);
Vector2 b = __v2f(to);
Vertex2F n = v2fnormalize(v2fperp(v2fsub(b, a)));
Vertex2F t = v2fperp(n);
Vector2 n = v2fnormalize(v2fperp(v2fsub(b, a)));
Vector2 t = v2fperp(n);
Vertex2F nw = v2fmult(n, radius);
Vertex2F tw = v2fmult(t, radius);
Vertex2F v0 = v2fsub(b, v2fadd(nw, tw));
Vertex2F v1 = v2fadd(b, v2fsub(nw, tw));
Vertex2F v2 = v2fsub(b, nw);
Vertex2F v3 = v2fadd(b, nw);
Vertex2F v4 = v2fsub(a, nw);
Vertex2F v5 = v2fadd(a, nw);
Vertex2F v6 = v2fsub(a, v2fsub(nw, tw));
Vertex2F v7 = v2fadd(a, v2fadd(nw, tw));
Vector2 nw = v2fmult(n, radius);
Vector2 tw = v2fmult(t, radius);
Vector2 v0 = v2fsub(b, v2fadd(nw, tw));
Vector2 v1 = v2fadd(b, v2fsub(nw, tw));
Vector2 v2 = v2fsub(b, nw);
Vector2 v3 = v2fadd(b, nw);
Vector2 v4 = v2fsub(a, nw);
Vector2 v5 = v2fadd(a, nw);
Vector2 v6 = v2fsub(a, v2fsub(nw, tw));
Vector2 v7 = v2fadd(a, v2fadd(nw, tw));
V2F_C4B_T2F_Triangle *triangles = (V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount);
@ -349,20 +349,20 @@ void DrawNode::drawPolygon(Point *verts, int count, const Color4F &fillColor, fl
{
CCASSERT(count >= 0, "invalid count value");
struct ExtrudeVerts {Vertex2F offset, n;};
struct ExtrudeVerts {Vector2 offset, n;};
struct ExtrudeVerts* extrude = (struct ExtrudeVerts*)malloc(sizeof(struct ExtrudeVerts)*count);
memset(extrude, 0, sizeof(struct ExtrudeVerts)*count);
for (int i = 0; i < count; i++)
{
Vertex2F v0 = __v2f(verts[(i-1+count)%count]);
Vertex2F v1 = __v2f(verts[i]);
Vertex2F v2 = __v2f(verts[(i+1)%count]);
Vector2 v0 = __v2f(verts[(i-1+count)%count]);
Vector2 v1 = __v2f(verts[i]);
Vector2 v2 = __v2f(verts[(i+1)%count]);
Vertex2F n1 = v2fnormalize(v2fperp(v2fsub(v1, v0)));
Vertex2F n2 = v2fnormalize(v2fperp(v2fsub(v2, v1)));
Vector2 n1 = v2fnormalize(v2fperp(v2fsub(v1, v0)));
Vector2 n2 = v2fnormalize(v2fperp(v2fsub(v2, v1)));
Vertex2F offset = v2fmult(v2fadd(n1, n2), 1.0/(v2fdot(n1, n2) + 1.0));
Vector2 offset = v2fmult(v2fadd(n1, n2), 1.0/(v2fdot(n1, n2) + 1.0));
struct ExtrudeVerts tmp = {offset, n2};
extrude[i] = tmp;
}
@ -379,9 +379,9 @@ void DrawNode::drawPolygon(Point *verts, int count, const Color4F &fillColor, fl
float inset = (outline == false ? 0.5 : 0.0);
for (int i = 0; i < count-2; i++)
{
Vertex2F v0 = v2fsub(__v2f(verts[0 ]), v2fmult(extrude[0 ].offset, inset));
Vertex2F v1 = v2fsub(__v2f(verts[i+1]), v2fmult(extrude[i+1].offset, inset));
Vertex2F v2 = v2fsub(__v2f(verts[i+2]), v2fmult(extrude[i+2].offset, inset));
Vector2 v0 = v2fsub(__v2f(verts[0 ]), v2fmult(extrude[0 ].offset, inset));
Vector2 v1 = v2fsub(__v2f(verts[i+1]), v2fmult(extrude[i+1].offset, inset));
Vector2 v2 = v2fsub(__v2f(verts[i+2]), v2fmult(extrude[i+2].offset, inset));
V2F_C4B_T2F_Triangle tmp = {
{v0, Color4B(fillColor), __t(v2fzero)},
@ -395,20 +395,20 @@ void DrawNode::drawPolygon(Point *verts, int count, const Color4F &fillColor, fl
for(int i = 0; i < count; i++)
{
int j = (i+1)%count;
Vertex2F v0 = __v2f(verts[i]);
Vertex2F v1 = __v2f(verts[j]);
Vector2 v0 = __v2f(verts[i]);
Vector2 v1 = __v2f(verts[j]);
Vertex2F n0 = extrude[i].n;
Vector2 n0 = extrude[i].n;
Vertex2F offset0 = extrude[i].offset;
Vertex2F offset1 = extrude[j].offset;
Vector2 offset0 = extrude[i].offset;
Vector2 offset1 = extrude[j].offset;
if(outline)
{
Vertex2F inner0 = v2fsub(v0, v2fmult(offset0, borderWidth));
Vertex2F inner1 = v2fsub(v1, v2fmult(offset1, borderWidth));
Vertex2F outer0 = v2fadd(v0, v2fmult(offset0, borderWidth));
Vertex2F outer1 = v2fadd(v1, v2fmult(offset1, borderWidth));
Vector2 inner0 = v2fsub(v0, v2fmult(offset0, borderWidth));
Vector2 inner1 = v2fsub(v1, v2fmult(offset1, borderWidth));
Vector2 outer0 = v2fadd(v0, v2fmult(offset0, borderWidth));
Vector2 outer1 = v2fadd(v1, v2fmult(offset1, borderWidth));
V2F_C4B_T2F_Triangle tmp1 = {
{inner0, Color4B(borderColor), __t(v2fneg(n0))},
@ -425,10 +425,10 @@ void DrawNode::drawPolygon(Point *verts, int count, const Color4F &fillColor, fl
*cursor++ = tmp2;
}
else {
Vertex2F inner0 = v2fsub(v0, v2fmult(offset0, 0.5));
Vertex2F inner1 = v2fsub(v1, v2fmult(offset1, 0.5));
Vertex2F outer0 = v2fadd(v0, v2fmult(offset0, 0.5));
Vertex2F outer1 = v2fadd(v1, v2fmult(offset1, 0.5));
Vector2 inner0 = v2fsub(v0, v2fmult(offset0, 0.5));
Vector2 inner1 = v2fsub(v1, v2fmult(offset1, 0.5));
Vector2 outer0 = v2fadd(v0, v2fmult(offset0, 0.5));
Vector2 outer1 = v2fadd(v1, v2fmult(offset1, 0.5));
V2F_C4B_T2F_Triangle tmp1 = {
{inner0, Color4B(fillColor), __t(v2fzero)},
@ -459,9 +459,9 @@ void DrawNode::drawTriangle(const Point &p1, const Point &p2, const Point &p3, c
ensureCapacity(vertex_count);
Color4B col = Color4B(color);
V2F_C4B_T2F a = {Vertex2F(p1.x, p1.y), col, Tex2F(0.0, 0.0) };
V2F_C4B_T2F b = {Vertex2F(p2.x, p2.y), col, Tex2F(0.0, 0.0) };
V2F_C4B_T2F c = {Vertex2F(p3.x, p3.y), col, Tex2F(0.0, 0.0) };
V2F_C4B_T2F a = {Vector2(p1.x, p1.y), col, Tex2F(0.0, 0.0) };
V2F_C4B_T2F b = {Vector2(p2.x, p2.y), col, Tex2F(0.0, 0.0) };
V2F_C4B_T2F c = {Vector2(p3.x, p3.y), col, Tex2F(0.0, 0.0) };
V2F_C4B_T2F_Triangle *triangles = (V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount);
V2F_C4B_T2F_Triangle triangle = {a, b, c};
@ -478,16 +478,16 @@ void DrawNode::drawCubicBezier(const Point& from, const Point& control1, const P
Tex2F texCoord = Tex2F(0.0, 0.0);
Color4B col = Color4B(color);
Vertex2F vertex;
Vertex2F firstVertex = Vertex2F(from.x, from.y);
Vertex2F lastVertex = Vertex2F(to.x, to.y);
Vector2 vertex;
Vector2 firstVertex = Vector2(from.x, from.y);
Vector2 lastVertex = Vector2(to.x, to.y);
float t = 0;
for(unsigned int i = segments + 1; i > 0; i--)
{
float x = powf(1 - t, 3) * from.x + 3.0f * powf(1 - t, 2) * t * control1.x + 3.0f * (1 - t) * t * t * control2.x + t * t * t * to.x;
float y = powf(1 - t, 3) * from.y + 3.0f * powf(1 - t, 2) * t * control1.y + 3.0f * (1 - t) * t * t * control2.y + t * t * t * to.y;
vertex = Vertex2F(x, y);
vertex = Vector2(x, y);
V2F_C4B_T2F a = {firstVertex, col, texCoord };
V2F_C4B_T2F b = {lastVertex, col, texCoord };
@ -509,16 +509,16 @@ void DrawNode::drawQuadraticBezier(const Point& from, const Point& control, cons
Tex2F texCoord = Tex2F(0.0, 0.0);
Color4B col = Color4B(color);
Vertex2F vertex;
Vertex2F firstVertex = Vertex2F(from.x, from.y);
Vertex2F lastVertex = Vertex2F(to.x, to.y);
Vector2 vertex;
Vector2 firstVertex = Vector2(from.x, from.y);
Vector2 lastVertex = Vector2(to.x, to.y);
float t = 0;
for(unsigned int i = segments + 1; i > 0; i--)
{
float x = powf(1 - t, 2) * from.x + 2.0f * (1 - t) * t * control.x + t * t * to.x;
float y = powf(1 - t, 2) * from.y + 2.0f * (1 - t) * t * control.y + t * t * to.y;
vertex = Vertex2F(x, y);
vertex = Vector2(x, y);
V2F_C4B_T2F a = {firstVertex, col, texCoord };
V2F_C4B_T2F b = {lastVertex, col, texCoord };

View File

@ -127,7 +127,7 @@ void drawPoint( const Point& point )
{
lazy_init();
Vertex2F p;
Vector2 p;
p.x = point.x;
p.y = point.y;
@ -161,10 +161,10 @@ void drawPoints( const Point *points, unsigned int numberOfPoints )
s_shader->setUniformLocationWith1f(s_pointSizeLocation, s_pointSize);
// XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed
Vertex2F* newPoints = new Vertex2F[numberOfPoints];
Vector2* newPoints = new Vector2[numberOfPoints];
// iPhone and 32-bit machines optimization
if( sizeof(Point) == sizeof(Vertex2F) )
if( sizeof(Point) == sizeof(Vector2) )
{
#ifdef EMSCRIPTEN
setGLBufferData((void*) points, numberOfPoints * sizeof(Point));
@ -183,7 +183,7 @@ void drawPoints( const Point *points, unsigned int numberOfPoints )
#ifdef EMSCRIPTEN
// Suspect Emscripten won't be emitting 64-bit code for a while yet,
// but want to make sure this continues to work even if they do.
setGLBufferData(newPoints, numberOfPoints * sizeof(Vertex2F));
setGLBufferData(newPoints, numberOfPoints * sizeof(Vector2));
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, newPoints);
@ -202,9 +202,9 @@ void drawLine( const Point& origin, const Point& destination )
{
lazy_init();
Vertex2F vertices[2] = {
Vertex2F(origin.x, origin.y),
Vertex2F(destination.x, destination.y)
Vector2 vertices[2] = {
Vector2(origin.x, origin.y),
Vector2(destination.x, destination.y)
};
s_shader->use();
@ -254,7 +254,7 @@ void drawPoly( const Point *poli, unsigned int numberOfPoints, bool closePolygon
GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION );
// iPhone and 32-bit machines optimization
if( sizeof(Point) == sizeof(Vertex2F) )
if( sizeof(Point) == sizeof(Vector2) )
{
#ifdef EMSCRIPTEN
setGLBufferData((void*) poli, numberOfPoints * sizeof(Point));
@ -272,13 +272,13 @@ void drawPoly( const Point *poli, unsigned int numberOfPoints, bool closePolygon
{
// Mac on 64-bit
// XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed
Vertex2F* newPoli = new Vertex2F[numberOfPoints];
Vector2* newPoli = new Vector2[numberOfPoints];
for( unsigned int i=0; i<numberOfPoints;i++) {
newPoli[i].x = poli[i].x;
newPoli[i].y = poli[i].y;
}
#ifdef EMSCRIPTEN
setGLBufferData(newPoli, numberOfPoints * sizeof(Vertex2F));
setGLBufferData(newPoli, numberOfPoints * sizeof(Vector2));
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, newPoli);
@ -306,10 +306,10 @@ void drawSolidPoly( const Point *poli, unsigned int numberOfPoints, Color4F colo
GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION );
// XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed
Vertex2F* newPoli = new Vertex2F[numberOfPoints];
Vector2* newPoli = new Vector2[numberOfPoints];
// iPhone and 32-bit machines optimization
if( sizeof(Point) == sizeof(Vertex2F) )
if( sizeof(Point) == sizeof(Vector2) )
{
#ifdef EMSCRIPTEN
setGLBufferData((void*) poli, numberOfPoints * sizeof(Point));
@ -323,10 +323,10 @@ void drawSolidPoly( const Point *poli, unsigned int numberOfPoints, Color4F colo
// Mac on 64-bit
for( unsigned int i=0; i<numberOfPoints;i++)
{
newPoli[i] = Vertex2F( poli[i].x, poli[i].y );
newPoli[i] = Vector2( poli[i].x, poli[i].y );
}
#ifdef EMSCRIPTEN
setGLBufferData(newPoli, numberOfPoints * sizeof(Vertex2F));
setGLBufferData(newPoli, numberOfPoints * sizeof(Vector2));
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, newPoli);
@ -438,7 +438,7 @@ void drawQuadBezier(const Point& origin, const Point& control, const Point& dest
{
lazy_init();
Vertex2F* vertices = new Vertex2F[segments + 1];
Vector2* vertices = new Vector2[segments + 1];
float t = 0.0f;
for(unsigned int i = 0; i < segments; i++)
@ -457,7 +457,7 @@ void drawQuadBezier(const Point& origin, const Point& control, const Point& dest
GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION );
#ifdef EMSCRIPTEN
setGLBufferData(vertices, (segments + 1) * sizeof(Vertex2F));
setGLBufferData(vertices, (segments + 1) * sizeof(Vector2));
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
@ -477,7 +477,7 @@ void drawCardinalSpline( PointArray *config, float tension, unsigned int segmen
{
lazy_init();
Vertex2F* vertices = new Vertex2F[segments + 1];
Vector2* vertices = new Vector2[segments + 1];
ssize_t p;
float lt;
@ -514,7 +514,7 @@ void drawCardinalSpline( PointArray *config, float tension, unsigned int segmen
GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION );
#ifdef EMSCRIPTEN
setGLBufferData(vertices, (segments + 1) * sizeof(Vertex2F));
setGLBufferData(vertices, (segments + 1) * sizeof(Vector2));
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
@ -529,7 +529,7 @@ void drawCubicBezier(const Point& origin, const Point& control1, const Point& co
{
lazy_init();
Vertex2F* vertices = new Vertex2F[segments + 1];
Vector2* vertices = new Vector2[segments + 1];
float t = 0;
for(unsigned int i = 0; i < segments; i++)
@ -548,7 +548,7 @@ void drawCubicBezier(const Point& origin, const Point& control1, const Point& co
GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION );
#ifdef EMSCRIPTEN
setGLBufferData(vertices, (segments + 1) * sizeof(Vertex2F));
setGLBufferData(vertices, (segments + 1) * sizeof(Vector2));
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);

View File

@ -334,7 +334,7 @@ void Grid3D::blit(void)
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, 0);
// texCoords
setGLBufferData(_texCoordinates, numOfPoints * sizeof(Vertex2F), 1);
setGLBufferData(_texCoordinates, numOfPoints * sizeof(Vector2), 1);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, 0);
setGLIndexData(_indices, n * 12, 0);
@ -367,7 +367,7 @@ void Grid3D::calculateVertexPoints(void)
_vertices = malloc(numOfPoints * sizeof(Vector3));
_originalVertices = malloc(numOfPoints * sizeof(Vector3));
_texCoordinates = malloc(numOfPoints * sizeof(Vertex2F));
_texCoordinates = malloc(numOfPoints * sizeof(Vector2));
_indices = (GLushort*)malloc(_gridSize.width * _gridSize.height * sizeof(GLushort) * 6);
GLfloat *vertArray = (GLfloat*)_vertices;
@ -549,7 +549,7 @@ void TiledGrid3D::blit(void)
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, 0);
// texCoords
setGLBufferData(_texCoordinates, (numQuads*4*sizeof(Vertex2F)), 1);
setGLBufferData(_texCoordinates, (numQuads*4*sizeof(Vector2)), 1);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, 0);
setGLIndexData(_indices, n * 12, 0);
@ -582,7 +582,7 @@ void TiledGrid3D::calculateVertexPoints(void)
_vertices = malloc(numQuads*4*sizeof(Vector3));
_originalVertices = malloc(numQuads*4*sizeof(Vector3));
_texCoordinates = malloc(numQuads*4*sizeof(Vertex2F));
_texCoordinates = malloc(numQuads*4*sizeof(Vector2));
_indices = (GLushort*)malloc(numQuads*6*sizeof(GLushort));
GLfloat *vertArray = (GLfloat*)_vertices;

View File

@ -301,7 +301,7 @@ protected:
virtual void updateColor() override;
BlendFunc _blendFunc;
Vertex2F _squareVertices[4];
Vector2 _squareVertices[4];
Color4F _squareColors[4];
CustomCommand _customCommand;
Vector3 _noMVPVertices[4];

View File

@ -120,7 +120,7 @@ bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Co
_pointState = (float *)malloc(sizeof(float) * _maxPoints);
_pointVertexes = (Point*)malloc(sizeof(Point) * _maxPoints);
_vertices = (Vertex2F*)malloc(sizeof(Vertex2F) * _maxPoints * 2);
_vertices = (Vector2*)malloc(sizeof(Vector2) * _maxPoints * 2);
_texCoords = (Tex2F*)malloc(sizeof(Tex2F) * _maxPoints * 2);
_colorPointer = (GLubyte*)malloc(sizeof(GLubyte) * _maxPoints * 2 * 4);
@ -385,7 +385,7 @@ void MotionStreak::onDraw(const kmMat4 &transform, bool transformUpdated)
#ifdef EMSCRIPTEN
// Size calculations from ::initWithFade
setGLBufferData(_vertices, (sizeof(Vertex2F) * _maxPoints * 2), 0);
setGLBufferData(_vertices, (sizeof(Vector2) * _maxPoints * 2), 0);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
setGLBufferData(_texCoords, (sizeof(Tex2F) * _maxPoints * 2), 1);

View File

@ -143,7 +143,7 @@ protected:
float* _pointState;
// Opengl
Vertex2F* _vertices;
Vector2* _vertices;
GLubyte* _colorPointer;
Tex2F* _texCoords;

View File

@ -173,9 +173,9 @@ Tex2F ProgressTimer::textureCoordFromAlphaPoint(Point alpha)
return Tex2F(min.x * (1.f - alpha.x) + max.x * alpha.x, min.y * (1.f - alpha.y) + max.y * alpha.y);
}
Vertex2F ProgressTimer::vertexFromAlphaPoint(Point alpha)
Vector2 ProgressTimer::vertexFromAlphaPoint(Point alpha)
{
Vertex2F ret(0.0f, 0.0f);
Vector2 ret(0.0f, 0.0f);
if (!_sprite) {
return ret;
}
@ -519,7 +519,7 @@ void ProgressTimer::onDraw(const kmMat4 &transform, bool transformUpdated)
int offset = 0;
glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid*)offset);
offset += sizeof(Vertex2F);
offset += sizeof(Vector2);
glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid*)offset);
offset += sizeof(Color4B);

View File

@ -136,7 +136,7 @@ protected:
void onDraw(const kmMat4 &transform, bool transformUpdated);
Tex2F textureCoordFromAlphaPoint(Point alpha);
Vertex2F vertexFromAlphaPoint(Point alpha);
Vector2 vertexFromAlphaPoint(Point alpha);
void updateProgress(void);
void updateBar(void);
void updateRadial(void);

View File

@ -29,7 +29,7 @@
NS_CC_BEGIN
void ccVertexLineToPolygon(Point *points, float stroke, Vertex2F *vertices, unsigned int offset, unsigned int nuPoints)
void ccVertexLineToPolygon(Point *points, float stroke, Vector2 *vertices, unsigned int offset, unsigned int nuPoints)
{
nuPoints += offset;
if(nuPoints<=1) return;
@ -69,8 +69,8 @@ void ccVertexLineToPolygon(Point *points, float stroke, Vertex2F *vertices, unsi
}
perpVector = perpVector * stroke;
vertices[idx] = Vertex2F(p1.x+perpVector.x, p1.y+perpVector.y);
vertices[idx+1] = Vertex2F(p1.x-perpVector.x, p1.y-perpVector.y);
vertices[idx] = Vector2(p1.x+perpVector.x, p1.y+perpVector.y);
vertices[idx+1] = Vector2(p1.x-perpVector.x, p1.y-perpVector.y);
}
@ -81,10 +81,10 @@ void ccVertexLineToPolygon(Point *points, float stroke, Vertex2F *vertices, unsi
idx = i*2;
const unsigned int idx1 = idx+2;
Vertex2F p1 = vertices[idx];
Vertex2F p2 = vertices[idx+1];
Vertex2F p3 = vertices[idx1];
Vertex2F p4 = vertices[idx1+1];
Vector2 p1 = vertices[idx];
Vector2 p2 = vertices[idx+1];
Vector2 p3 = vertices[idx1];
Vector2 p4 = vertices[idx1+1];
float s;
//BOOL fixVertex = !ccpLineIntersect(Point(p1.x, p1.y), Point(p4.x, p4.y), Point(p2.x, p2.y), Point(p3.x, p3.y), &s, &t);

View File

@ -38,7 +38,7 @@ NS_CC_BEGIN
/** @file CCVertex.h */
/** converts a line to a polygon */
void CC_DLL ccVertexLineToPolygon(Point *points, float stroke, Vertex2F *vertices, unsigned int offset, unsigned int nuPoints);
void CC_DLL ccVertexLineToPolygon(Point *points, float stroke, Vector2 *vertices, unsigned int offset, unsigned int nuPoints);
/** returns whether or not the line intersects */
bool CC_DLL ccVertexLineIntersect(float Ax, float Ay,

View File

@ -152,15 +152,15 @@ struct Color4F
/** A vertex composed of 2 floats: x, y
@since v3.0
*/
struct Vertex2F
{
Vertex2F(float _x, float _y) :x(_x), y(_y) {}
// struct Vertex2F
// {
// Vertex2F(float _x, float _y) :x(_x), y(_y) {}
Vertex2F(): x(0.f), y(0.f) {}
// Vertex2F(): x(0.f), y(0.f) {}
GLfloat x;
GLfloat y;
};
// GLfloat x;
// GLfloat y;
// };
/** A vertex composed of 2 floats: x, y
@ -197,7 +197,7 @@ struct Tex2F {
//! Point Sprite component
struct PointSprite
{
Vertex2F pos; // 8 bytes
Vector2 pos; // 8 bytes
Color4B color; // 4 bytes
GLfloat size; // 4 bytes
};
@ -205,10 +205,10 @@ struct PointSprite
//! A 2D Quad. 4 * 2 floats
struct Quad2
{
Vertex2F tl;
Vertex2F tr;
Vertex2F bl;
Vertex2F br;
Vector2 tl;
Vector2 tr;
Vector2 bl;
Vector2 br;
};
@ -224,7 +224,7 @@ struct Quad3 {
struct V2F_C4B_T2F
{
//! vertices (2F)
Vertex2F vertices;
Vector2 vertices;
//! colors (4B)
Color4B colors;
//! tex coords (2F)
@ -235,7 +235,7 @@ struct V2F_C4B_T2F
struct V2F_C4F_T2F
{
//! vertices (2F)
Vertex2F vertices;
Vector2 vertices;
//! colors (4F)
Color4F colors;
//! tex coords (2F)