-
Notifications
You must be signed in to change notification settings - Fork 12
Adding pathfinding using SDF example #10
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
base: main
Are you sure you want to change the base?
Conversation
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.
Please add a copy of the premake5.lua file to the folder so that it will build with the other examples.
pathfinding_sdf/pathfinding_sdf.c
Outdated
int pathRatStartX = 5; | ||
int pathRatStartY = 25; | ||
int pathRatEndX = 75; | ||
int pathRatEndY = 25; | ||
PathfindingNode *mapRat = (PathfindingNode *)MemAlloc(gridWidth * gridHeight * sizeof(PathfindingNode)); | ||
PathfindingNode *pathRat = (PathfindingNode *)MemAlloc(gridWidth * gridHeight * sizeof(PathfindingNode) * 4); | ||
int pathRatLength = 0; | ||
int ratWallFactor = 2; | ||
|
||
// cat setup | ||
int pathCatStartX = 5; | ||
int pathCatStartY = 25; | ||
int pathCatEndX = 75; | ||
int pathCatEndY = 25; |
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.
This is a lot of arguments, many that are just X and Y variants.
Can we use vector2 or some other structure to clean this up?
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.
True. I can create a dedicated struct for each entity. It would be nice if raylib had a Vector2Int... I wanted to keep it integer based (not sure if worth it).
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.
Everything infernally uses floats, so is there any real benefit to keeping it ints? If you need to you can just call floor on the floats.
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.
True. It was a decision based on gut feeling. I would keep it for now. I moved the data into structs so I hope it's more organized now.
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.
The main function is a bit huge, It would be best to break that up into functions with descriptive names.
3b4e978
to
9280336
Compare
I reworked it quite a bit and it's now more data oriented. I hope it's also more readable (or at least not less readable). |
|
||
typedef struct Agent | ||
{ | ||
int startX, startY; |
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.
I would like to use floats when possible.
|
||
} | ||
|
||
void Agent_findPath(Agent *agent, int enableJumping) |
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.
this function is huge, can it be broken up more? maybe in places where you have comments, that should be a sub function for readability?
I fear that most people will not be able to follow this code.
No description provided.