09-09-2014, 06:44 AM
(This post was last modified: 09-09-2014, 06:55 AM by SamJBarney.)
Heh. I'm currently working on the mob rebuild right now. I don't have the code around anymore (It got lost awhile back), but I needed to rewrite the entire thing from scratch anyways to get as much performance out of it as I can. Oh, and it was A* pathfinding.
The reason for the performance drop was that I was recalculating the entire path when the target moved to another block. It worked fine when the target was within 7 blocks, but above that there was too much lag.
I was going to get around that by just storing the node at the end of each path section, and then when recalculation was needed, recalculate from the second node from the end of the path.
Another reason pathfinding was taking awhile was because of the stl containers that I was using. The dynamic allocation of memory was slowing things down. Xoft, I believe, suggested that I use static allocation of a 16x16x16 area and use a std::vector instead to increase performance.
I hadn't been taking bounding boxes into account, but I was using their height to determine if they could get to a block. I hadn't worked out stairs and half slabs yet.
Once I get the Component Rewrite done, I will be transforming the AI into a task-based AI, and I could use some help planning/implementing it, if you're interested.
The reason for the performance drop was that I was recalculating the entire path when the target moved to another block. It worked fine when the target was within 7 blocks, but above that there was too much lag.
I was going to get around that by just storing the node at the end of each path section, and then when recalculation was needed, recalculate from the second node from the end of the path.
Another reason pathfinding was taking awhile was because of the stl containers that I was using. The dynamic allocation of memory was slowing things down. Xoft, I believe, suggested that I use static allocation of a 16x16x16 area and use a std::vector instead to increase performance.
I hadn't been taking bounding boxes into account, but I was using their height to determine if they could get to a block. I hadn't worked out stairs and half slabs yet.
Once I get the Component Rewrite done, I will be transforming the AI into a task-based AI, and I could use some help planning/implementing it, if you're interested.