All-
So for those that have marked roads differently (I'm manually running the route + recording positions), how have you done this? I'm attempting to do it between rcMarkWalkableTriangles and rcRasterizeTriangles and I'm thinking that might not be the best place.
Basically if any vertice of the triangle touches the road, I mark the entire triangle as "ROAD". I'm pretty certain I shouldn't do this, and my tests after doing this don't show it preferring roads over ground (1 vs 5 weight).
My implementation:
Code:
rcMarkWalkableTriangles(_ctx, m_cfg.walkableSlopeAngle, verts, nverts, tris, ntris, m_triareas);
NSArray *AllRoads = [[MeshDataController sharedInstance] roadsForContinent:530];
// 44,12 continent: 530
if ( [AllRoads count] > 0 ){
for (int i = 0; i < ntris; ++i)
{
const int* tri = &tris[i*3];
// vertices that make up the triangle!
glm::vec3 v1 = glm::vec3(verts[tri[0]*3+0], verts[tri[0]*3+1], verts[tri[0]*3+2]);
glm::vec3 v2 = glm::vec3(verts[tri[1]*3+0], verts[tri[1]*3+1], verts[tri[1]*3+2]);
glm::vec3 v3 = glm::vec3(verts[tri[2]*3+0], verts[tri[2]*3+1], verts[tri[2]*3+2]);
// ADT In Game
// centerX = -1 * pg.Y
// centerY = pg.Z
// centerZ = -1 * pg.X;
for ( NSArray *road in AllRoads )
{
// Single mob scan
for ( int j = 0; j < [road count] - 1; j = j + 2 )
{
ObjectPosition *p1 = [road objectAtIndex:j];
ObjectPosition *p2 = [road objectAtIndex:j+1];
glm::vec3 Point1 = glm::vec3(p1.xPositionADT, p1.yPositionADT, p1.zPositionADT);
glm::vec3 Point2 = glm::vec3(p2.xPositionADT, p2.yPositionADT, p2.zPositionADT);
GfxMath::LineSegment2f LS(Point1, Point2);
float distance = 1.0f;
if ( LS.distance(v1) < distance || LS.distance(v2) < distance || LS.distance(v3) < distance )
{
m_triareas[i] = SAMPLE_POLYAREA_ROAD;
}
}
}
}
}
rcRasterizeTriangles(_ctx, verts, nverts, tris, m_triareas, ntris, *m_solid, m_cfg.walkableClimb);
Anyone have any ideas on how else I should do this?
Thanks!
~ Tanaris