Skip to content

Commit

Permalink
Merge 2 open PRs from upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
ppiastucki committed Mar 23, 2021
1 parent 6f5a6ae commit 236bd5e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 31 deletions.
25 changes: 5 additions & 20 deletions detour/src/main/java/org/recast4j/detour/NavMesh.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,7 @@ recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org
*/
package org.recast4j.detour;

import static org.recast4j.detour.DetourCommon.clamp;
import static org.recast4j.detour.DetourCommon.closestHeightPointTriangle;
import static org.recast4j.detour.DetourCommon.distancePtSegSqr2D;
import static org.recast4j.detour.DetourCommon.nextPow2;
import static org.recast4j.detour.DetourCommon.oppositeTile;
import static org.recast4j.detour.DetourCommon.overlapBounds;
import static org.recast4j.detour.DetourCommon.overlapQuantBounds;
import static org.recast4j.detour.DetourCommon.pointInPolygon;
import static org.recast4j.detour.DetourCommon.sqr;
import static org.recast4j.detour.DetourCommon.vAdd;
import static org.recast4j.detour.DetourCommon.vCopy;
import static org.recast4j.detour.DetourCommon.vLenSqr;
import static org.recast4j.detour.DetourCommon.vLerp;
import static org.recast4j.detour.DetourCommon.vMax;
import static org.recast4j.detour.DetourCommon.vMin;
import static org.recast4j.detour.DetourCommon.vSub;
import static org.recast4j.detour.DetourCommon.*;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -708,8 +693,8 @@ void connectExtLinks(MeshTile tile, MeshTile target, int side) {
tmin = tmax;
tmax = temp;
}
link.bmin = (int) (clamp(tmin, 0.0f, 1.0f) * 255.0f);
link.bmax = (int) (clamp(tmax, 0.0f, 1.0f) * 255.0f);
link.bmin = Math.round(clamp(tmin, 0.0f, 1.0f) * 255.0f);
link.bmax = Math.round(clamp(tmax, 0.0f, 1.0f) * 255.0f);
} else if (dir == 2 || dir == 6) {
float tmin = (neia[k * 2 + 0] - tile.data.verts[va])
/ (tile.data.verts[vb] - tile.data.verts[va]);
Expand All @@ -720,8 +705,8 @@ void connectExtLinks(MeshTile tile, MeshTile target, int side) {
tmin = tmax;
tmax = temp;
}
link.bmin = (int) (clamp(tmin, 0.0f, 1.0f) * 255.0f);
link.bmax = (int) (clamp(tmax, 0.0f, 1.0f) * 255.0f);
link.bmin = Math.round(clamp(tmin, 0.0f, 1.0f) * 255.0f);
link.bmax = Math.round(clamp(tmax, 0.0f, 1.0f) * 255.0f);
}
}
}
Expand Down
10 changes: 2 additions & 8 deletions recast/src/main/java/org/recast4j/recast/RecastContour.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@ recast4j Copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org
*/
package org.recast4j.recast;

import static org.recast4j.recast.RecastConstants.RC_AREA_BORDER;
import static org.recast4j.recast.RecastConstants.RC_BORDER_REG;
import static org.recast4j.recast.RecastConstants.RC_BORDER_VERTEX;
import static org.recast4j.recast.RecastConstants.RC_CONTOUR_REG_MASK;
import static org.recast4j.recast.RecastConstants.RC_CONTOUR_TESS_AREA_EDGES;
import static org.recast4j.recast.RecastConstants.RC_CONTOUR_TESS_WALL_EDGES;
import static org.recast4j.recast.RecastConstants.RC_NOT_CONNECTED;
import static org.recast4j.recast.RecastConstants.*;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -637,7 +631,7 @@ private static void mergeRegionHoles(Context ctx, ContourRegion region) {
index = -1;
for (int j = 0; j < ndiags; j++) {
int pt = diags[j].vert * 4;
boolean intersect = intersectSegCountour(pt, corner, diags[i].vert, outline.nverts, outline.verts,
boolean intersect = intersectSegCountour(pt, corner, diags[j].vert, outline.nverts, outline.verts,
outline.verts, hole.verts);
for (int k = i; k < region.nholes && !intersect; k++)
intersect |= intersectSegCountour(pt, corner, -1, region.holes[k].contour.nverts,
Expand Down
9 changes: 6 additions & 3 deletions recast/src/main/java/org/recast4j/recast/RecastRegion.java
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,6 @@ private static void sortCellsByLevel(int startLevel, CompactHeightfield chf, int
for (int j = 0; j < nbStacks; ++j) {
stacks.get(j).clear();
}
;

// put all cells in the level range into the appropriate stacks
for (int y = 0; y < h; ++y) {
Expand Down Expand Up @@ -490,7 +489,7 @@ static class Region {
floors = new ArrayList<>();
}

};
}

private static void removeAdjacentNeighbours(Region reg) {
// Remove adjacent duplicates.
Expand Down Expand Up @@ -972,7 +971,7 @@ private static int mergeAndFilterLayerRegions(Context ctx, int minRegionArea, in
Region reg = regions[ri];

reg.spanCount++;

reg.areaType = chf.areas[i];
reg.ymin = Math.min(reg.ymin, s.y);
reg.ymax = Math.max(reg.ymax, s.y);
// Collect all region layers.
Expand Down Expand Up @@ -1045,6 +1044,10 @@ private static int mergeAndFilterLayerRegions(Context ctx, int minRegionArea, in
if (regn.id != 0) {
continue;
}
// Skip if different area type, do not connect regions with different area type.
if (reg.areaType != regn.areaType) {
continue;
}
// Skip if the neighbour is overlapping root region.
boolean overlap = false;
for (int k = 0; k < root.floors.size(); k++) {
Expand Down

0 comments on commit 236bd5e

Please sign in to comment.