-
-
Notifications
You must be signed in to change notification settings - Fork 641
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
Pathfinder optimization #1925
Pathfinder optimization #1925
Conversation
I think the |
But the cPath constructor performs the "initializer step" and checks the starting position and ending positions, it needs interactions with the world. Regarding propagating via parameters: It's technically possible, but we'll needlessly pass that parameter everywhere, I find that a bit dirty, don't you think? |
regarding getting rid of the chunk in the constructor: |
Awaiting comments / merge. |
Is it legal to do it the other way around?: only passing the chunk via the constructor and using that chunk till the path calculation ends? |
This isn't exactly what you asked for, but I feel it's cleaner. Tell me what you think. |
No, that won't work. If the chunk gets unloaded between the constructor call and the path finish, this will fail horribly. You need to pass a valid chunk in each step. I didn't see the initialization step in the constructor, that makes it necessary to pass the chunk there as well. It isn't actually necessary to get rid of the "old" chunk when moving to a neighbor. The only time you have to consider your chunks invalid is when you exit out of the Tick function - at that moment every |
Got it. Is it ok to keep the chunk as a member function? |
Rebased. |
I guess so. Perhaps add a comment to its declaration, say that it's valid only within the |
Awaiting comments / Rebase and merge. |
I'd like to fix the swimming / fence issue by editing Issolid, I'm going to include it in this PR because otherwise a merge conflict will occur. To avoid confusion I'll rebase and name the commit "Issolid rewritten" or something like that. |
If you change the IsSolid function you might break other code that uses it. |
No, it's my PathFinder's Issolid, a different function. |
Fixed fence issue, swimming for later, awaiting comments / rebase and merge |
I think for the fence, you need also check for E_BLOCK_FENCE_GATE. |
Nether brick, spruce, birch, jungle, dark_oak, acacia. |
@Jan64 that doesn't matter, we don't need to check the data value of the fence. Only the block type itself. |
@Seadragon91 , you are right. |
Fencegate added. |
m_Chunk->GetBlockTypeMeta(RelX, a_Location.y, RelZ, BlockType, BlockMeta); | ||
if ((BlockType == E_BLOCK_FENCE) || (BlockType == E_BLOCK_FENCE_GATE)) | ||
{ | ||
GetCell(a_Location+Vector3d(0, 1, 0))->m_IsSolid = true; // Mobs will always think that the fence is 2 blocks high and therefore won't jump over. |
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.
spaces
@Seadragon91 Different kinds of fences are defined as different blocks, they don't only differ in data values. |
@Jan64 Looks like you're right, BlockID.h has lots of fences. I really don't want to mix pull requests so let's leave this at the current imperfect state, I'll need to take a different approach in dealing with fences anyways. |
Any non-fence related comments? I'm not pushing the issue aside, I just don't want to invest time on something I'm going to rewrite anyways. |
I personally would reset |
How about |
Not worth it. It took me a whole minute to understand what that assert is doing (that it's setting, not comparing, the m_Chunk), so it's not good for code clarity. Just put the assignment there, it's not worth micro-optimizing this much. |
Got some equavilant which is clearer? |
Perhaps there should be a Macro DoInDebugModeonly or something like that. |
Ok to squash? |
Fix the parentheses and squash. |
Squashed and fixed extra |
Note that my Github username has been changed from WiseOldMan95 to SafwatHalaby. |
Got rid of DoWithChunk, an order of magnitude less locks.