Skip to content

Commit

Permalink
font word wrap fix, added some lua bindings, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
turanszkij committed Feb 27, 2024
1 parent d2842b9 commit 1c49e49
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 69 deletions.
2 changes: 2 additions & 0 deletions Content/Documentation/ScriptingAPI-Documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -1778,3 +1778,5 @@ Path finding operations can be made by using a voxel grid and path queries. The
- GetAgentWidth(int value) : int
- SetAgentHeight(int value) -- Set the navigation height requirement in voxels. This means how many voxels the query will keep away from obstacles vertically.
- GetAgentHeight(int value) : int
- GetWaypointCount() : int -- returns the number of waypoints that were computed in Process()
- GetWaypoint(int index) : Vector returns the waypoint at specified index (direction: start -> goal)
2 changes: 1 addition & 1 deletion Editor/Editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ void EditorComponent::Load()

navtestButton.Create(ICON_NAVIGATION);
navtestButton.SetShadowRadius(2);
navtestButton.SetTooltip("Toggle navigation testing.\nYou can put down START and GOAL waypoints inside voxel grids to test path finding.\nControls:\n----------\nF5: put START to surface\nF6: put GOAL to surface\nF7: put START to air\nF8: put GOAL to air");
navtestButton.SetTooltip("Toggle navigation testing. When enabled, you can visualize path finding results.\nYou can put down START and GOAL waypoints inside voxel grids to test path finding.\nControls:\n----------\nF5 + left click: put START to surface\nF6 + left click: put GOAL to surface\nF7 + left click: put START to air\nF8 + left click: put GOAL to air");
navtestButton.SetLocalizationEnabled(wi::gui::LocalizationEnabled::Tooltip);
navtestButton.OnClick([&](wi::gui::EventArgs args) {
navtest_enabled = !navtest_enabled;
Expand Down
2 changes: 1 addition & 1 deletion WickedEngine/wiFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ namespace wi::font
if (status.last_word_begin > 0 && params.h_wrap >= 0 && status.cursor.position.x >= params.h_wrap - 1)
{
// Word ended and wrap detected, push down last word by one line:
float word_offset = vertexList[status.last_word_begin].pos.x + whitespace_size;
const float word_offset = vertexList[status.last_word_begin].pos.x;
for (size_t i = status.last_word_begin; i < status.quadCount * 4; ++i)
{
vertexList[i].pos.x -= word_offset;
Expand Down
14 changes: 14 additions & 0 deletions WickedEngine/wiPathQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,20 @@ namespace wi
return results[results.size() - 2];
}

size_t PathQuery::get_waypoint_count() const
{
const wi::vector<XMFLOAT3>& results = result_path_goal_to_start_simplified.empty() ? result_path_goal_to_start : result_path_goal_to_start_simplified;
return results.size();
}

XMFLOAT3 PathQuery::get_waypoint(size_t index) const
{
const wi::vector<XMFLOAT3>& results = result_path_goal_to_start_simplified.empty() ? result_path_goal_to_start : result_path_goal_to_start_simplified;
if (results.size() <= index)
return process_startpos;
return results[results.size() - 1 - index]; // return results in direction: start -> goal
}

namespace PathQuery_internal
{
PipelineState pso_curve;
Expand Down
6 changes: 6 additions & 0 deletions WickedEngine/wiPathQuery.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ namespace wi
// Gets the next upcoming waypoint between start and goal that was used in process():
XMFLOAT3 get_next_waypoint() const;

// Gets the number of resulting waypoints
size_t get_waypoint_count() const;

// Gets the result waypoint at specified index (direction: start -> goal)
XMFLOAT3 get_waypoint(size_t index) const;

bool debug_voxels = true;
mutable float debugtimer = 0;
XMFLOAT3 debugvoxelsize = XMFLOAT3(0, 0, 0);
Expand Down
19 changes: 19 additions & 0 deletions WickedEngine/wiPathQuery_BindLua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ namespace wi::lua
lunamethod(PathQuery_BindLua, GetAgentWidth),
lunamethod(PathQuery_BindLua, SetAgentHeight),
lunamethod(PathQuery_BindLua, GetAgentHeight),
lunamethod(PathQuery_BindLua, GetWaypointCount),
lunamethod(PathQuery_BindLua, GetWaypoint),
{ NULL, NULL }
};
Luna<PathQuery_BindLua>::PropertyType PathQuery_BindLua::properties[] = {
Expand Down Expand Up @@ -121,6 +123,23 @@ namespace wi::lua
wi::lua::SSetInt(L, pathquery.agent_width);
return 1;
}
int PathQuery_BindLua::GetWaypointCount(lua_State* L)
{
wi::lua::SSetInt(L, (int)pathquery.get_waypoint_count());
return 1;
}
int PathQuery_BindLua::GetWaypoint(lua_State* L)
{
int argc = wi::lua::SGetArgCount(L);
if (argc < 1)
{
wi::lua::SError(L, "PathQuery::GetWaypoint(int index) not enough arguments!");
return 0;
}
int index = wi::lua::SGetInt(L, 1);
Luna<Vector_BindLua>::push(L, pathquery.get_waypoint(size_t(index)));
return 1;
}

void PathQuery_BindLua::Bind()
{
Expand Down
2 changes: 2 additions & 0 deletions WickedEngine/wiPathQuery_BindLua.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ namespace wi::lua
int GetAgentWidth(lua_State* L);
int SetAgentHeight(lua_State* L);
int GetAgentHeight(lua_State* L);
int GetWaypointCount(lua_State* L);
int GetWaypoint(lua_State* L);

static void Bind();
};
Expand Down
69 changes: 2 additions & 67 deletions WickedEngine/wiVersion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace wi::version
// minor features, major updates, breaking compatibility changes
const int minor = 71;
// minor bug fixes, alterations, refactors, updates
const int revision = 382;
const int revision = 383;

const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);

Expand Down Expand Up @@ -50,72 +50,7 @@ All contributors: https://github.com/turanszkij/WickedEngine/graphs/contributors
Patreon supporters
---------------------------
Nemerle
James Webb
Quifeng Jin
TheGameCreators
Joseph Goldin
Yuri
Sergey K
Yukawa Kanta
Dragon Josh
John
LurkingNinja
Bernardo Del Castillo
Invictus
Scott Hunt
Yazan Altaki
Tuan NV
Robert MacGregor
cybernescence
Alexander Dahlin
blueapples
Delhills
NI NI
Sherief
ktopoet
Justin Macklin
Cédric Fabre
TogetherTeam
Bartosz Boczula
Arne Koenig
Ivan Trajchev
nathants
Fahd Ahmed
Gabriel Jadderson
SAS_Controller
Dominik Madarász
Segfault
Mike amanfo
Dennis Brakhane
rookie
Peter Moore
therealjtgill
Nicolas Embleton
Desuuc
radino1977
Anthony Curtis
manni heck
Matthias Hölzl
Phyffer
Lucas Pinheiro
Tapkaara
gpman
Anthony Python
Gnowos
Klaus
slaughternaut
Paul Brain
Connor Greaves
Alexandr
Lee Bamber
MCAlarm MC2
Titoutan
Willow
Aldo
lokimx
K. Osterman
Nomad
Nemerle, James Webb, Quifeng Jin, TheGameCreators, Joseph Goldin, Yuri, Sergey K, Yukawa Kanta, Dragon Josh, John, LurkingNinja, Bernardo Del Castillo, Invictus, Scott Hunt, Yazan Altaki, Tuan NV, Robert MacGregor, cybernescence, Alexander Dahlin, blueapples, Delhills, NI NI, Sherief, ktopoet, Justin Macklin, Cédric Fabre, TogetherTeam, Bartosz Boczula, Arne Koenig, Ivan Trajchev, nathants, Fahd Ahmed, Gabriel Jadderson, SAS_Controller, Dominik Madarász, Segfault, Mike amanfo, Dennis Brakhane, rookie, Peter Moore, therealjtgill, Nicolas Embleton, Desuuc, radino1977, Anthony Curtis, manni heck, Matthias Hölzl, Phyffer, Lucas Pinheiro, Tapkaara, gpman, Anthony Python, Gnowos, Klaus, slaughternaut, Paul Brain, Connor Greaves, Alexandr, Lee Bamber, MCAlarm MC2, Titoutan, Willow, Aldo, lokimx, K. Osterman, Nomad
)";

return credits;
Expand Down

0 comments on commit 1c49e49

Please sign in to comment.