Skip to content
Permalink
Browse files

Make clearUnwalkableTriangles public (closes #51) (#52)

  • Loading branch information...
ppiastucki committed Mar 14, 2019
1 parent fb1c4cc commit cbeaf92ad1b40f23c1b47d5c102f658bcfcac857
@@ -90,7 +90,7 @@ static void calcTriNormal(float[] verts, int v0, int v1, int v2, float[] norm) {
/// See the #rcConfig documentation for more information on the configuration parameters.
///
/// @see rcHeightfield, rcClearUnwalkableTriangles, rcRasterizeTriangles
void clearUnwalkableTriangles(Context ctx, float walkableSlopeAngle, float[] verts, int nv, int[] tris, int nt,
public static void clearUnwalkableTriangles(Context ctx, float walkableSlopeAngle, float[] verts, int nv, int[] tris, int nt,
int[] areas) {
float walkableThr = (float) Math.cos(walkableSlopeAngle / 180.0f * Math.PI);

@@ -0,0 +1,37 @@
package org.recast4j.recast;

import static org.junit.Assert.assertEquals;
import static org.recast4j.recast.RecastConstants.RC_NULL_AREA;

import org.junit.Test;

public class RecastTest {

@Test
public void textClearUnwalkableTriangles() {
float walkableSlopeAngle = 45;
float verts[] = { 0, 0, 0, 1, 0, 0, 0, 0, -1 };
int nv = 3;
int walkable_tri[] = { 0, 1, 2 };
int unwalkable_tri[] = { 0, 2, 1 };
int nt = 1;

Context ctx = new Context();
{
int areas[] = { 42 };
Recast.clearUnwalkableTriangles(ctx, walkableSlopeAngle, verts, nv, unwalkable_tri, nt, areas);
assertEquals("Sets area ID of unwalkable triangle to RC_NULL_AREA", RC_NULL_AREA, areas[0]);
}
{
int areas[] = { 42 };
Recast.clearUnwalkableTriangles(ctx, walkableSlopeAngle, verts, nv, walkable_tri, nt, areas);
assertEquals("Does not modify walkable triangle aread ID's", 42, areas[0]);
}
{
int areas[] = { 42 };
walkableSlopeAngle = 0;
Recast.clearUnwalkableTriangles(ctx, walkableSlopeAngle, verts, nv, walkable_tri, nt, areas);
assertEquals("Slopes equal to the max slope are considered unwalkable.", RC_NULL_AREA, areas[0]);
}
}
}

0 comments on commit cbeaf92

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.