-
Notifications
You must be signed in to change notification settings - Fork 1.7k
PolyToCol applied in RecastDemo #254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Implement custom functions to be called when an assertion fails.
if (imguiCheck("Road", m_areaType == SAMPLE_POLYAREA_ROAD)) | ||
m_areaType = SAMPLE_POLYAREA_ROAD; | ||
// if (imguiCheck("Ground", m_areaType == SAMPLE_POLYAREA_GROUND)) | ||
// m_areaType = SAMPLE_POLYAREA_GROUND; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these commented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As noted above
updated the imguiCheck for convex volumes so that all SamplePolyAreas values are covered, except GROUND, which corresponds to zero, i.e. the default area value. Maybe adding GROUND could be useful too. To be discussed.
More precisely, the SAMPLE_POLYAREA_GROUND
area flag value is zero. Creating a convex volume with SAMPLE_POLYAREA_GROUND
area actually makes holes in the built mesh, which is not coherent with the label "Ground".
The fact that default walkable area end with SAMPLE_POLYAREA_GROUND
can be considered as a misleading trick in the sample. Default walkable area is defined by RC_WALKABLE_AREA
with value 63, whereas RC_NULL_AREA
equals 0 and is considered as making holes in the mesh.
The trick allows to reuse the zero value in areas. It appears in the build process in specific sample code
if (m_pmesh->areas[i] == RC_WALKABLE_AREA) m_pmesh->areas[i] = SAMPLE_POLYAREA_GROUND;
which is misleading in my opinion. It induces confusion between SAMPLE_POLYAREA_GROUND
and RC_NULL_AREA
.
I would rather give a new non-zero value to SAMPLE_POLYAREA_GROUND
, and expose the zero-value area convex volume as "Null" or "Not walkable" or "Hole"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes you are right about the holes.
The reasoning for this is that area types change meaning in the build process.
Until regions are built there is a special flag to indicate holes - this flag is RC_NULL_AREA
which as you point out coincides with SAMPLE_POLYAREA_GROUND
.
After regions have been built this flag is no longer meaningful, and Recast can support the entire range of areas (64 different areas). The remapping is handled here.
The original source of the RC_WALKABLE_AREA
flag is rcMarkWalkableTriangles
.
This function is used in the sample.
So several options for you:
- Leave it alone for now and uncomment it again. It can be fixed in a future PR.
- Resolve it by remapping
SAMPLE_POLYAREA_GROUND
toRC_WALKABLE_AREA
during convex poly marking
The ideal solution (which should happen separately from these changes) is something like:
RC_WALKABLE_AREA
is not meaningful to the build process in any way, it is simply a flag with value 63. rcMarkWalkableTriangles
should be changed to accept the flag to use for marking the walkable triangles instead of always using flag 63. After this change all the SAMPLE_POLYAREA
values should have 1 added to them (or implicitly add 1 during rasterization and subtract 1 in the poly mesh), and SAMPLE_POLYAREA_GROUND
should be passed to rcMarkWalkableTriangles
.
I don't expect you to submit a PR for this last bit. If you don't I will probably do it some time in the future when I have time, but please do either 1 or 2.
Anyway thanks for the work!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, done with 1.
I think the area change would be good to take asap, so if you could make a PR with that separately it would be good. That said, I like how these changes make the colors meaningful. Can you please rebase your commits in addition to fixing my comment? |
I must admit that I'm fairly new with Git, and struggling with GitHub client for Windows. Sorry for those lamentations, but I can't figure how to make a new separate PR : / |
I am not familiar with the GitHub client for Windows unfortunately. With the CLI it would look something like:
After this you should be able to create a pull request from the GitHub home page. One way to resolve your problem with your current master is something like this (I am sure there are better ways):
After that you should be able to create a new PR for this issue that comes from the new branch instead of your master. Then you will need to reset your master to be in sync with us:
The
|
An arguably easier way to rebase your changes (provided everything's up to date) is to rebase and force-push.
That will automatically update this PR with your changes rebased. In the future it's probably easier to work in separate branches like @jackpoz suggests. |
Give Graham's suggestion a go (it's useful to get acquainted with the git command line :) ) - but if you struggle, it's possible for one of us to grab your fork, rebase and push it ourselves, keeping your name in the commits - let us know :) |
very nice suggestion, but wrong ja* nick tagged :) |
I merged the AreaToCol stuff |
RecastDemo/Include/Sample.h
Outdated
class SampleDebugDraw : public DebugDrawGL | ||
{ | ||
public: | ||
virtual unsigned int polyToCol(const struct dtPoly* poly); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has to be areaToCol
now.
RecastDemo/Source/Sample.cpp
Outdated
} | ||
} | ||
|
||
unsigned int SampleDebugDraw::polyToCol(const struct dtPoly* poly) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also needs update
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course !
My bad, too much used to rely on the override keyword.
Should be ok now.
Thanks! |
I have noticed that the default color has changed significantly. I am not sure if this was intentional, but for now I have changed it back in #256 to retain the old look (by default). |
While the code is hot, I implemented a specific polyToCol in RecastDemo to make it illustrated in the library codebase itself.
Main changes :
sampleAreaToCol
which computes a color from the specific demo area flags. Chosen color constants may be reviewed to fit correctly with the rest of the debug drawn elements.SampleDebugDraw
which inherits fromDebugDrawGL
and implementspolyToCol
by simply callingsampleAreaToCol
SampleDebugDraw m_dd
as attribute ofSample
and used it anywhere aDebugDrawGL
was created on stackduDebugDraw
should be enoughsampleAreaToCol
in drawing of convex volumes so that their color match the area they setimguiCheck
for convex volumes so that allSamplePolyAreas
values are covered, except GROUND, which corresponds to zero, i.e. the default area value. Maybe adding GROUND could be useful too. To be discussed.Note
I noticed that TileCachePolyMesh and TileCacheLayerAreas (maybe others I missed) are also drawn with a color determined from area. I'm wondering whether changing the custom color from
polyToCol(const dtPoly* poly)
toareaToCol(unsigned int area)
would be a good idea. On one hand it could apply to more elements (at least TileCachePolyMesh, TileCacheLayerAreas and sample convex volumes) with no user extra code, but on the other hand it gives some limitations in the case of polygons (restriction to areas, not flags or any other info).What do you think about that ?