add pathfinding.set_jump_height
This commit is contained in:
parent
ac1623f86c
commit
174a3c6871
@ -5,12 +5,16 @@ local started
|
|||||||
local tsf = entity.transform
|
local tsf = entity.transform
|
||||||
|
|
||||||
agent = pathfinding.create_agent()
|
agent = pathfinding.create_agent()
|
||||||
pathfinding.set_max_visited(agent, 100000)
|
pathfinding.set_max_visited(agent, 1e5)
|
||||||
|
|
||||||
function set_target(new_target)
|
function set_target(new_target)
|
||||||
target = new_target
|
target = new_target
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function set_jump_height(height)
|
||||||
|
pathfinding.set_jump_height(agent, height)
|
||||||
|
end
|
||||||
|
|
||||||
function get_target()
|
function get_target()
|
||||||
return target
|
return target
|
||||||
end
|
end
|
||||||
|
|||||||
@ -91,6 +91,13 @@ static int l_set_max_visited_blocks(lua::State* L) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int l_set_jump_height(lua::State* L) {
|
||||||
|
if (auto agent = get_agent(L)) {
|
||||||
|
agent->jumpHeight = lua::tointeger(L, 2);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
const luaL_Reg pathfindinglib[] = {
|
const luaL_Reg pathfindinglib[] = {
|
||||||
{"create_agent", lua::wrap<l_create_agent>},
|
{"create_agent", lua::wrap<l_create_agent>},
|
||||||
{"remove_agent", lua::wrap<l_remove_agent>},
|
{"remove_agent", lua::wrap<l_remove_agent>},
|
||||||
@ -100,5 +107,6 @@ const luaL_Reg pathfindinglib[] = {
|
|||||||
{"make_route_async", lua::wrap<l_make_route_async>},
|
{"make_route_async", lua::wrap<l_make_route_async>},
|
||||||
{"pull_route", lua::wrap<l_pull_route>},
|
{"pull_route", lua::wrap<l_pull_route>},
|
||||||
{"set_max_visited", lua::wrap<l_set_max_visited_blocks>},
|
{"set_max_visited", lua::wrap<l_set_max_visited_blocks>},
|
||||||
|
{"set_jump_height", lua::wrap<l_set_jump_height>},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -156,7 +156,7 @@ Route Pathfinding::perform(Agent& agent, int maxVisited) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_obstacle_at(chunks, pos.x, pos.y + agent.height / 2, pos.z)) {
|
if (is_obstacle_at(chunks, pos.x, pos.y + agent.jumpHeight, pos.z)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!check_passability(agent, chunks, node, offset, i >= 4)) {
|
if (!check_passability(agent, chunks, node, offset, i >= 4)) {
|
||||||
|
|||||||
@ -2,14 +2,13 @@
|
|||||||
|
|
||||||
#define GLM_ENABLE_EXPERIMENTAL
|
#define GLM_ENABLE_EXPERIMENTAL
|
||||||
#include <glm/gtx/hash.hpp>
|
#include <glm/gtx/hash.hpp>
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <memory>
|
|
||||||
#include <queue>
|
|
||||||
#include <glm/vec2.hpp>
|
#include <glm/vec2.hpp>
|
||||||
#include <glm/vec3.hpp>
|
#include <glm/vec3.hpp>
|
||||||
|
#include <memory>
|
||||||
|
#include <queue>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
class Level;
|
class Level;
|
||||||
class GlobalChunks;
|
class GlobalChunks;
|
||||||
@ -50,6 +49,7 @@ namespace voxels {
|
|||||||
bool enabled = false;
|
bool enabled = false;
|
||||||
bool mayBeIncomplete = true;
|
bool mayBeIncomplete = true;
|
||||||
int height = 2;
|
int height = 2;
|
||||||
|
int jumpHeight = 1;
|
||||||
int maxVisitedBlocks = 1e3;
|
int maxVisitedBlocks = 1e3;
|
||||||
glm::ivec3 start;
|
glm::ivec3 start;
|
||||||
glm::ivec3 target;
|
glm::ivec3 target;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user