Skip to content

Commit

Permalink
AvoidBehavior should not consider Vertices as nearby entities
Browse files Browse the repository at this point in the history
  • Loading branch information
oguzeroglu committed Aug 8, 2020
1 parent 444b573 commit 6fe9573
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions js/steering/behavior/AvoidBehavior.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { SteeringBehavior } from "./SteeringBehavior";
import { Box } from "../../core/Box";
import { Vector3D } from "../../core/Vector3D";
import { Vertex } from "../../core/Vertex";
import { VectorPool } from "../../core/VectorPool";
import { logger } from "../../debug/Logger";

Expand Down Expand Up @@ -34,6 +35,11 @@ AvoidBehavior.prototype.findMostThreateningObstacle = function(steerable){
box.expandByPoint(steerable.box.max);

steerable.executeForEachCloseEntity(function(entity){

if (entity instanceof Vertex){
return;
}

if (box.intersectsBox(entity.box)){
if (!mostThreatening){
mostThreatening = entity;
Expand Down
7 changes: 7 additions & 0 deletions test/steering/behavior/AvoidBehaviorTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ describe("AvoidBehavior", function(){
var avoidBehavior = new Kompute.AvoidBehavior({ maxSeeAhead: 50000, maxAvoidForce: 100 });

expect(avoidBehavior.findMostThreateningObstacle(steerable)).to.eql(null);

var graph = new Kompute.Graph();
graph.addVertex(new Kompute.Vector3D(0, 0, 0));

world.insertGraph(graph);

expect(avoidBehavior.findMostThreateningObstacle(steerable)).to.eql(null);
});

it("should find most mostThreatening if not going towards the obstacle [hits obstacle by size]", function(){
Expand Down

0 comments on commit 6fe9573

Please sign in to comment.