virtual void process(struct dtNavMeshCreateParams* params, navAreaMask* areaMasks) { // Update poly flags from areas. /*for (int i = 0; i < params->polyCount; ++i) { if (polyAreas[i] == DT_TILECACHE_WALKABLE_AREA) polyAreas[i] = SAMPLE_POLYAREA_GROUND; if (polyAreas[i] == SAMPLE_POLYAREA_GROUND || polyAreas[i] == SAMPLE_POLYAREA_GRASS || polyAreas[i] == SAMPLE_POLYAREA_ROAD) { polyFlags[i] = AREAFLAGS_WALK; } else if (polyAreas[i] == SAMPLE_POLYAREA_WATER) { polyFlags[i] = AREAFLAGS_SWIM; } else if (polyAreas[i] == SAMPLE_POLYAREA_DOOR) { polyFlags[i] = AREAFLAGS_WALK | AREAFLAGS_DOOR; } }*/ // Pass in off-mesh connections. if (m_geom) { params->offMeshConVerts = m_geom->getOffMeshConnectionVerts(); params->offMeshConRad = m_geom->getOffMeshConnectionRads(); params->offMeshConDir = m_geom->getOffMeshConnectionDirs(); params->offMeshConAreaFlags = m_geom->getOffMeshConnectionAreaMask(); params->offMeshConUserID = m_geom->getOffMeshConnectionId(); params->offMeshConCount = m_geom->getOffMeshConnectionCount(); } }
void OffMeshConnectionTool::handleClick(const float* /*s*/, const float* p, bool shift) { if (!m_sample) return; InputGeom* geom = m_sample->getInputGeom(); if (!geom) return; if (shift) { // Delete // Find nearest link end-point float nearestDist = FLT_MAX; int nearestIndex = -1; const float* verts = geom->getOffMeshConnectionVerts(); for (int i = 0; i < geom->getOffMeshConnectionCount()*2; ++i) { const float* v = &verts[i*3]; float d = rcVdistSqr(p, v); if (d < nearestDist) { nearestDist = d; nearestIndex = i/2; // Each link has two vertices. } } // If end point close enough, delete it. if (nearestIndex != -1 && sqrtf(nearestDist) < m_sample->getAgentRadius()) { geom->deleteOffMeshConnection(nearestIndex); } } else { // Create if (!m_hitPosSet) { rcVcopy(m_hitPos, p); m_hitPosSet = true; } else { const unsigned char area = SAMPLE_POLYAREA_JUMP; const unsigned short flags = SAMPLE_POLYFLAGS_JUMP; geom->addOffMeshConnection(m_hitPos, p, m_sample->getAgentRadius(), m_bidir ? 1 : 0, area, flags); m_hitPosSet = false; float* v = new float[6]; rcVcopy(&v[0], m_hitPos); rcVcopy(&v[3], p); printf("572 29,29 (%.3f %.3f %.3f) (%.3f %.3f %.3f) 5.0f", v[0],v[1], v[2],v[3],v[4],v[5]); } } }