[Opentnl-cvs] tnl/zap UIEditor.cpp,1.21,1.22 barrier.cpp,1.16,1.17 game.h,1.70,1.71 main.cpp,1.73,1.
Brought to you by:
mark_frohnmayer,
s_alanet
From: Mark F. <mar...@us...> - 2004-10-19 19:44:11
|
Update of /cvsroot/opentnl/tnl/zap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2987/zap Modified Files: UIEditor.cpp barrier.cpp game.h main.cpp point.h Log Message: Fixed bugs with barrier width display in editor Index: UIEditor.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/UIEditor.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** UIEditor.cpp 18 Oct 2004 22:41:02 -0000 1.21 --- UIEditor.cpp 19 Oct 2004 19:43:58 -0000 1.22 *************** *** 42,45 **** --- 42,46 ---- void EditorUserInterface::setEditName(const char *name) { + mGridSize = Game::DefaultGridSize; mGameType[0] = 0; char fileBuffer[256]; *************** *** 59,63 **** mCreatingPoly = false; mCurrentTeam = 0; - mGridSize = Game::DefaultGridSize; strcpy(mEditFileName, name); --- 60,63 ---- *************** *** 169,178 **** mTeams.push_back(t); } - else if(!strcmp(argv[0], "GridSize") && argc == 2) - { - mGridSize = atof(argv[1]); - } else { Vector<const char *> item; for(S32 i = 0; i < argc; i++) --- 169,177 ---- mTeams.push_back(t); } else { + if(!strcmp(argv[0], "GridSize") && argc == 2) + mGridSize = atof(argv[1]); + Vector<const char *> item; for(S32 i = 0; i < argc; i++) *************** *** 310,313 **** --- 309,314 ---- } + extern void constructBarrierPoints(const Vector<Point> &vec, F32 width, Vector<Point> &barrierEnds ); + void EditorUserInterface::renderItem(S32 index) { *************** *** 364,378 **** else if(gGameItemRecs[i.index].isPoly) { if(i.selected) ! glColor3f(1,1,0); else if(i.index == ItemBarrierMaker) ! glColor3f(0,0,1); else if(i.team == -1) ! glColor3f(0.7, 0.7, 0.7); else { Color c = mTeams[i.team].color; ! glColor(c); } if(i.index != ItemBarrierMaker) --- 365,381 ---- else if(gGameItemRecs[i.index].isPoly) { + Color theColor; if(i.selected) ! theColor.set(1,1,0); else if(i.index == ItemBarrierMaker) ! theColor.set(0,0,1); else if(i.team == -1) ! theColor.set(0.7, 0.7, 0.7); else { Color c = mTeams[i.team].color; ! theColor = c; } + glColor(theColor); if(i.index != ItemBarrierMaker) *************** *** 389,418 **** else { glLineWidth(3); renderPoly(i); glLineWidth(1); - Point first = convertLevelToCanvasCoord(i.verts[0]); - for(S32 j = 1; j < i.verts.size(); j++) - { - Point v = convertLevelToCanvasCoord(i.verts[j]); - F32 width = i.width * mCurrentScale / mGridSize; - - Point dir = v - first; - if(dir.len() > 0) - { - dir.normalize(); - Point crs(dir.y, -dir.x); - crs *= width * 0.5; - - glBegin(GL_LINE_LOOP); - glColor3f(0.5, 0.5, 1); - glVertex(first + crs); - glVertex(first - crs); - glVertex(v - crs); - glVertex(v + crs); - glEnd(); - } - first = v; - } } for(S32 j = 0; j < i.verts.size(); j++) --- 392,415 ---- else { + Vector<Point> barPoints; + constructBarrierPoints(i.verts, i.width / mGridSize, barPoints ); + + for(S32 j = 0; j < barPoints.size(); j += 2) + { + Point dir = barPoints[j+1] - barPoints[j]; + Point crossVec(dir.y, -dir.x); + crossVec.normalize(i.width * 0.5 / mGridSize); + glBegin(GL_POLYGON); + glColor3f(0.5, 0.5, 1); + glVertex(convertLevelToCanvasCoord(barPoints[j] + crossVec)); + glVertex(convertLevelToCanvasCoord(barPoints[j] - crossVec)); + glVertex(convertLevelToCanvasCoord(barPoints[j+1] - crossVec)); + glVertex(convertLevelToCanvasCoord(barPoints[j+1] + crossVec)); + glEnd(); + } + glColor(theColor); glLineWidth(3); renderPoly(i); glLineWidth(1); } for(S32 j = 0; j < i.verts.size(); j++) Index: main.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/main.cpp,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** main.cpp 8 Oct 2004 21:26:41 -0000 1.73 --- main.cpp 19 Oct 2004 19:43:58 -0000 1.74 *************** *** 602,605 **** --- 602,606 ---- else if(!stricmp(argv[i], "-window")) { + i--; OptionsMenuUserInterface::fullscreen = false; } Index: barrier.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/barrier.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** barrier.cpp 15 Oct 2004 18:01:15 -0000 1.16 --- barrier.cpp 19 Oct 2004 19:43:58 -0000 1.17 *************** *** 41,59 **** U32 Barrier::mBarrierChangeIndex = 1; ! void constructBarriers(Game *theGame, const Vector<F32> &barrier, F32 width) { ! Vector<Point> vec; ! bool loop; ! ! for(S32 i = 1; i < barrier.size(); i += 2) ! { ! float x = barrier[i-1]; ! float y = barrier[i]; ! vec.push_back(Point(x,y)); ! } ! if(vec.size() <= 1) ! return; ! ! loop = vec[0] == vec[vec.size() - 1]; Vector<Point> edgeVector; --- 41,47 ---- U32 Barrier::mBarrierChangeIndex = 1; ! void constructBarrierPoints(const Vector<Point> &vec, F32 width, Vector<Point> &barrierEnds ) { ! bool loop = vec[0] == vec[vec.size() - 1]; Vector<Point> edgeVector; *************** *** 71,75 **** Point curEdge = edgeVector[i]; double cosTheta = curEdge.dot(lastEdge); ! if(cosTheta >= 0) { --- 59,63 ---- Point curEdge = edgeVector[i]; double cosTheta = curEdge.dot(lastEdge); ! if(cosTheta >= 0) { *************** *** 97,101 **** Point start = vec[i] - edgeVector[i] * extendBack; Point end = vec[i+1] + edgeVector[i] * extendForward; ! Barrier *b = new Barrier(start, end, width); b->addToGame(theGame); } --- 85,111 ---- Point start = vec[i] - edgeVector[i] * extendBack; Point end = vec[i+1] + edgeVector[i] * extendForward; ! barrierEnds.push_back(start); ! barrierEnds.push_back(end); ! } ! } ! ! void constructBarriers(Game *theGame, const Vector<F32> &barrier, F32 width) ! { ! Vector<Point> vec; ! ! for(S32 i = 1; i < barrier.size(); i += 2) ! { ! float x = barrier[i-1]; ! float y = barrier[i]; ! vec.push_back(Point(x,y)); ! } ! if(vec.size() <= 1) ! return; ! ! Vector<Point> barrierEnds; ! constructBarrierPoints(vec, width, barrierEnds); ! for(S32 i = 0; i < barrierEnds.size(); i += 2) ! { ! Barrier *b = new Barrier(barrierEnds[i], barrierEnds[i+1], width); b->addToGame(theGame); } Index: game.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/game.h,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** game.h 8 Oct 2004 21:19:28 -0000 1.70 --- game.h 19 Oct 2004 19:43:58 -0000 1.71 *************** *** 236,240 **** extern void endGame(); ! #define ZAP_GAME_STRING "ZAP 1.4.8" }; --- 236,240 ---- extern void endGame(); ! #define ZAP_GAME_STRING "ZAP 1.4.9" }; Index: point.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/point.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** point.h 1 Oct 2004 00:21:40 -0000 1.10 --- point.h 19 Oct 2004 19:43:58 -0000 1.11 *************** *** 57,61 **** Point &operator=(const Point &pt) { x = pt.x; y = pt.y; return *this; } ! bool operator==(const Point &pt) { return x == pt.x && y == pt.y; } member_type len() const { return (member_type) sqrt(x * x + y * y); } --- 57,61 ---- Point &operator=(const Point &pt) { x = pt.x; y = pt.y; return *this; } ! bool operator==(const Point &pt) const { return x == pt.x && y == pt.y; } member_type len() const { return (member_type) sqrt(x * x + y * y); } |