Pathfinding mesh generation methods, apparatus, electronic devices and storage media

By caching the height field data of the pathfinding model and responding to pathfinding object update commands, a second pathfinding mesh is generated, which solves the problems of high memory consumption and limited generation speed during game runtime, and realizes fast local reconstruction and free movement of virtual objects in the newly constructed area.

CN116077937BActive Publication Date: 2025-11-14NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211569733.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-08
Publication Date
2025-11-14
Estimated Expiration
2042-12-08

AI Technical Summary

Technical Problem

Existing technologies consume a lot of memory and have limited generation speed when dynamically generating pathfinding meshes during game runtime, and cannot increase or decrease walkable areas in real time.

Method used

By caching the height field data of the pathfinding model, responding to the update command of the pathfinding object, determining the covered pathfinding grid, obtaining the intersecting height field data from the cached data, and combining it with the model data of the pathfinding object to generate a second pathfinding grid, thus achieving local reconstruction.

Benefits of technology

It enables rapid local reconstruction of the pathfinding mesh during game runtime, reducing memory pressure and improving generation speed, allowing virtual objects to move freely in newly constructed areas.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116077937B_ABST
    Figure CN116077937B_ABST
Patent Text Reader

Abstract

This disclosure provides a method, apparatus, electronic device, and storage medium for generating a pathfinding mesh. The method includes: responding to an update instruction for a pathfinding object, determining a first pathfinding mesh covered by the pathfinding object; if the pathfinding data corresponding to the first pathfinding mesh hits cached data, obtaining height field data of a pathfinding model intersecting with the first pathfinding mesh from the cached data; obtaining model data of the pathfinding object, and generating a second pathfinding mesh using the model data of the pathfinding object and the height field data corresponding to the pathfinding model intersecting with the first pathfinding mesh, so as to enable virtual objects to pathfind within the pathfinding area of ​​the pathfinding object. According to this disclosure, by reconstructing the pathfinding mesh using the height field data of the cached pathfinding model, the problem of high memory pressure and limited generation speed of dynamically generating pathfinding meshes during game runtime is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and in particular to a pathfinding mesh generation method, a pathfinding mesh generation apparatus, an electronic device, and a computer-readable storage medium. Background Technology

[0002] In games, players can change the game environment by performing actions such as building houses and roads. Recast is a popular offline technique for generating pathfinding meshes, used to generate pathfinding meshes on arbitrary polygon surfaces using scene voxelization. Recast collects vertex information from the game scene, voxels this information to obtain a height field, and then processes it to obtain a pathfinding mesh for pathfinding.

[0003] However, this technology can only add pathfinding obstacles (objects that can be dynamically added or removed from the game and block the character's movement) during gameplay, and cannot add new walkable areas. Therefore, AI (artificial intelligence) that relies on pathfinding for movement cannot enter areas newly created by the player. To dynamically generate pathfinding meshes during gameplay, it would be necessary to obtain all the original vertex information of the game scene, which would put significant pressure on memory and limit the generation speed. Summary of the Invention

[0004] In view of the above problems, embodiments of the present disclosure are proposed to provide a pathfinding mesh generation method and a corresponding pathfinding mesh generation apparatus, an electronic device, and a computer-readable storage medium to overcome or at least partially solve the above problems.

[0005] This disclosure provides a method for generating a pathfinding mesh, the method comprising:

[0006] In response to an update command for a pathfinding object, the first pathfinding grid covered by the pathfinding object is determined; the pathfinding grid intersects with the corresponding pathfinding model; wherein, the pathfinding object is an object that can be dynamically added or removed from the game, used to block the movement of game objects or to provide new walkable areas for game objects; the pathfinding model is a model of one or more game objects in the virtual game scene;

[0007] If the pathfinding data corresponding to the first pathfinding grid hits the cached data, the height field data of the pathfinding model that intersects with the first pathfinding grid is obtained from the hit cached data;

[0008] The model data of the pathfinding object is acquired, and a second pathfinding grid is generated using the model data of the pathfinding object and the height field data corresponding to the pathfinding model that intersects with the first pathfinding grid, so as to enable the virtual object to find its way in the pathfinding area of ​​the pathfinding object; the second pathfinding grid includes the pathfinding area for the pathfinding object.

[0009] This disclosure also discloses a pathfinding mesh generation device, the device comprising:

[0010] A determination module is used to respond to an update command for a pathfinding object and determine the first pathfinding grid covered by the pathfinding object; the pathfinding grid intersects with the corresponding pathfinding model; wherein, the pathfinding object is an object that can be dynamically added or removed from the game and is used to block the movement of game objects or provide new walkable areas for game objects; the pathfinding model is a model of one or more game objects in the virtual game scene;

[0011] The first acquisition module is used to acquire the height field data of the pathfinding model that intersects with the first pathfinding grid from the cached data when the pathfinding data corresponding to the first pathfinding grid hits the cached data.

[0012] The acquisition and generation module is used to acquire the model data of the pathfinding object, and use the model data of the pathfinding object and the height field data corresponding to the pathfinding model intersecting with the first pathfinding grid to generate a second pathfinding grid, so as to enable the virtual object to find its way in the pathfinding area of ​​the pathfinding object; the second pathfinding grid includes the pathfinding area for the pathfinding object.

[0013] This disclosure also discloses an electronic device, including: a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements the pathfinding mesh generation method as described above.

[0014] This disclosure also discloses a computer-readable storage medium storing a computer program that, when executed by a processor, implements the pathfinding mesh generation method described above.

[0015] The embodiments disclosed herein have the following advantages:

[0016] In this embodiment, in response to an update command for a pathfinding object, a first pathfinding grid covered by the pathfinding object can be determined. If the pathfinding data corresponding to the first pathfinding grid hits the cached data, the height field data of the pathfinding model intersecting with the first pathfinding grid can be directly obtained from the cached data. Then, combined with the model data of the pathfinding object, a corresponding second pathfinding grid can be generated, thus constructing a pathfinding region for the pathfinding object. Virtual objects in the game can then pathfind within the newly created pathfinding region. By using the above method to reconstruct the pathfinding grid through the height field data of the cached pathfinding model, local reconstruction of the pathfinding grid can be achieved relatively quickly, solving the problem of high memory pressure and limited generation speed in existing solutions that dynamically generate pathfinding grids during game runtime. Attached Figure Description

[0017] Figure 1 This is a flowchart illustrating the steps of a pathfinding mesh generation method provided in this embodiment.

[0018] Figure 2 This is a flowchart of another pathfinding mesh generation method provided in this embodiment;

[0019] Figure 3 This is a schematic flowchart of a pathfinding mesh generation method provided in an embodiment of this disclosure;

[0020] Figure 4 This is a structural block diagram of a pathfinding mesh generation device provided in an embodiment of this disclosure. Detailed Implementation

[0021] To make the above-mentioned objects, features, and advantages of this disclosure more apparent and understandable, the disclosure will be further described in detail below with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are only some embodiments of this disclosure, and not all embodiments. Based on the embodiments in this disclosure, all other embodiments obtained by those skilled in the art are within the scope of protection of this disclosure.

[0022] Recast is a popular library used to generate pathfinding meshes on arbitrary polygonal surfaces using scene voxelization techniques. Recast collects vertex information from the game scene, voxels this information to obtain a height field, and then processes it to create a pathfinding mesh. When the AI ​​in the game needs to initiate pathfinding, it can query this mesh to obtain connectivity information between the starting and ending points for movement.

[0023] However, existing Recast-based pathfinding mesh generation technology is implemented offline. During game runtime, it can only dynamically provide pathfinding obstacles, but cannot increase or decrease the walkable area based on newly added pathfinding obstacles.

[0024] If it is necessary to dynamically generate pathfinding meshes during game runtime, it is required to obtain all the original vertex information of the game scene, which puts a lot of pressure on memory and limits the generation speed.

[0025] To address this deficiency, local reconstruction of the pathfinding mesh can be achieved relatively quickly by converting the vertex information of the scene into a height field and storing it. The advantage of this reconstruction scheme is its speed, but its disadvantage is that it consumes significantly more memory, reaching 1.5 to 5 times the original amount.

[0026] Based on this, this disclosure relates to solving the problem of high memory consumption caused by dynamically generating pathfinding meshes during game runtime in existing solutions, while also taking into account the reconstruction speed of the pathfinding meshes, so that virtual objects in the game can move in newly constructed game areas.

[0027] In this embodiment, in response to an update command for a pathfinding object, a first pathfinding grid covered by the pathfinding object can be determined. If the pathfinding data corresponding to the first pathfinding grid hits the cached data, the height field data of the pathfinding model intersecting with the first pathfinding grid can be directly obtained from the cached data. Then, combined with the model data of the pathfinding object, a corresponding second pathfinding grid can be generated, thus constructing a pathfinding region for the pathfinding object. Virtual objects in the game can pathfind within the newly created pathfinding region. By using the above method to reconstruct the pathfinding grid through the height field data of the cached pathfinding model, local reconstruction of the pathfinding grid can be achieved relatively quickly, solving the problem of high memory pressure and limited generation speed in existing solutions that dynamically generate pathfinding grids during game runtime.

[0028] Reference Figure 1 The diagram illustrates a flowchart of a pathfinding mesh generation method provided in this embodiment, which may specifically include the following steps:

[0029] Step 101: In response to the update command for the pathfinding object, determine the first pathfinding grid covered by the pathfinding object.

[0030] The pathfinding grid intersects with the corresponding pathfinding model.

[0031] The pathfinding grid generation method provided in this embodiment can reconstruct the pathfinding grid in real time. Specifically, the method can be executed during game operation.

[0032] The pathfinding mesh generation method disclosed herein can be applied to game servers. The games provided in the embodiments of this disclosure can be of various types, such as action games, adventure games, role-playing games, etc.

[0033] During gameplay, players can create new pathfinding objects or delete existing ones within the (virtual) game scene. Pathfinding objects are dynamically added or removed from the game; they can either block the movement of game objects or provide new walkable areas. In games, pathfinding objects typically manifest as various structures, such as houses, bridges, and roads.

[0034] A pathfinding grid can be generated for the game scene. Each cell in the pathfinding grid records the walkable state of the corresponding area, and virtual objects in the game move by querying the pathfinding grid.

[0035] A pathfinding model can be a model of one or more game objects in a virtual game scene, such as a road model, a water body model, or a railing model. The pathfinding model can affect the pathfinding result.

[0036] In this embodiment, for any pathfinding mesh, the pathfinding mesh intersects with the corresponding pathfinding model. Specifically, this can be the intersection of the bounding box of the pathfinding mesh with the corresponding pathfinding model. In this disclosure, a hierarchical bounding box of a virtual game scene can be constructed. The hierarchical bounding box contains bounding boxes at different levels that surround the scene model; that is, it can also be the intersection of the bounding box of the pathfinding mesh with the bounding box of the corresponding pathfinding model.

[0037] In response to an update command for a pathfinding object, the first pathfinding grid covered by the pathfinding object can be determined from all pathfinding grids. The update command for the pathfinding object can be a creation command or a deletion command for the pathfinding object. In this embodiment, the pathfinding grid covered by the pathfinding object is referred to as the first pathfinding grid, which may include one or more pathfinding grids.

[0038] Step 102: If the pathfinding data corresponding to the first pathfinding grid hits the cached data, obtain the height field data of the pathfinding model that intersects with the first pathfinding grid from the hit cached data.

[0039] A cache hit means the data to be retrieved is stored in the cache, meaning it can be retrieved directly from the cache. A cache miss means the desired data cannot be retrieved directly from the cache and requires a database query or other operations.

[0040] In this embodiment, it is necessary to obtain the pathfinding data corresponding to the first pathfinding grid. This pathfinding data may include the height field data of the pathfinding model intersecting with the first pathfinding grid. If the pathfinding data corresponding to the first pathfinding grid hits cached data, the height field data of the pathfinding model intersecting with the first pathfinding grid can be directly obtained from the cached data. That is, some of the pathfinding data corresponding to the pathfinding grids is pre-cached in memory.

[0041] Step 103: Obtain the model data of the pathfinding object, and use the model data of the pathfinding object and the height field data corresponding to the pathfinding model intersecting with the first pathfinding grid to generate a second pathfinding grid, so as to enable the virtual object to find its way in the pathfinding area of ​​the pathfinding object.

[0042] The second pathfinding grid includes the pathfinding region for the object being pathfinded. This pathfinding region includes both walkable and non-walkable areas.

[0043] In this embodiment, model data of the pathfinding object to be updated can be obtained, and then the model data of the pathfinding object, along with the height field data corresponding to the pathfinding model intersecting with the first pathfinding mesh, can be used to generate a corresponding second pathfinding mesh. This dynamic generation of the second pathfinding mesh is performed during game execution. The pathfinding area of ​​the pathfinding object is constructed in the generated second pathfinding mesh, and the walkable state of the pathfinding area is recorded.

[0044] In summary, in this embodiment, in response to an update command for a pathfinding object, the first pathfinding grid covered by the pathfinding object can be determined. If the pathfinding data corresponding to the first pathfinding grid hits the cached data, the height field data of the pathfinding model intersecting with the first pathfinding grid can be directly obtained from the cached data. Then, combined with the model data of the pathfinding object, the corresponding second pathfinding grid can be generated, thus constructing a pathfinding region for the pathfinding object. Virtual objects in the game can then pathfind within the newly created pathfinding region. By using the above method to reconstruct the pathfinding grid through the height field data of the cached pathfinding model, local reconstruction of the pathfinding grid can be achieved relatively quickly, solving the problem of high memory pressure and limited generation speed in existing solutions that dynamically generate pathfinding grids during game runtime.

[0045] Reference Figure 2 The diagram illustrates a flowchart of another pathfinding mesh generation method provided in this embodiment. The pathfinding mesh corresponding to the game scene is generated offline and stores pathfinding data corresponding to the mesh. Specifically, it may include the following steps:

[0046] Step 201: When the game server starts, preload the preset index information and obtain the corresponding cached data to store in shared memory.

[0047] The index information is used to find the pathfinding data corresponding to each pathfinding grid in the game scene. The index information can be stored path information.

[0048] In this embodiment, a pathfinding mesh corresponding to the game scene is generated offline, and the corresponding pathfinding data is stored. The pathfinding data may include Recast-based pathfinding mesh data and model data of the pathfinding models intersecting with the pathfinding mesh. The data structure of the model data can be as follows:

[0049] struct TileObjectInfo{

[0050] string path;

[0051] matrix transform;

[0052] uint8 area;

[0053] }

[0054] Here, `path` is the storage path of the pathfinding model, used to obtain the model data corresponding to the pathfinding model from shared memory, such as the vertex data of the pathfinding model; `transform` is the world space matrix of the pathfinding model, representing the coordinates, rotation, and scaling of the pathfinding model in the game scene; `area` is the pathfinding region type of the pathfinding model. When `area` is 0, it indicates a model participating in voxelization. Typically, road surfaces are set to `area = 0`. When `area > 0`, it indicates a model that needs to generate a `ConvexVolume`, which can mark the convex hull region of the model as water, a traversable railing, or an area that can be dynamically switched to determine whether it is accessible. The meaning of `ConvexVolume`: Used to mark the type of pathfinding region, such as whether it is walkable, and stored in the form of the corresponding model's convex hull. A large number of dynamically refreshed objects in the game that need to participate in pathfinding will generate `ConvexVolume`s.

[0055] In one optional embodiment of this disclosure, the stored model data may contain only vertex data. To avoid impacting the real-time reconstruction speed of the pathfinding mesh during game operation, the model data may not be stored in the aforementioned data structure format; instead, only vertex data may be stored. For example, the bounding box of a road model in a game may cover a large number of pathfinding meshes. If the model data corresponding to each road model is stored in the manner described above for each pathfinding mesh, it will affect the reconstruction performance of the pathfinding mesh. Therefore, only the vertex data of the road models intersecting with the pathfinding mesh can be stored. The pathfinding region in the pathfinding mesh is generated from the vertex data within the pathfinding mesh.

[0056] In this embodiment, preset index information can be preloaded when the game server starts. This index information can be used to find the pathfinding data corresponding to the pathfinding grid. The loaded index information is cached in shared memory, so that the cached data in the shared memory includes the pathfinding data corresponding to the pathfinding grid. It can be understood that this disclosure loads model data through shared memory. When the game runs, this model data can be shared by multiple game processes and used in the game's physics and pathfinding systems. This disclosure only needs to store the index information used to find model data, and the model data can be obtained during game runtime, which can significantly reduce memory overhead.

[0057] In one optional embodiment of this disclosure, the pathfinding data includes model data of the pathfinding model intersecting with the pathfinding grid. Step 201 involves preloading preset index information and obtaining corresponding cached data stored in shared memory. Specifically, this may include the following sub-steps:

[0058] Sub-step S11: Preload the preset index information, and obtain the model data of the pathfinding model that intersects with the pathfinding grid through the preset index information.

[0059] Sub-step S12: Using the model data of the pathfinding model intersecting the pathfinding grid, generate the height field data and / or convex hull data of the pathfinding model intersecting the pathfinding grid.

[0060] Sub-step S13 involves compressing the height field data and / or convex hull data of the pathfinding model that intersects with the pathfinding mesh and storing it as cache data in shared memory.

[0061] The height field is an array of linked lists, each list consisting of a series of voxel grids with the same x and z coordinates. After voxelization, only pathfinder-friendly height field information is generated, while non-pathfinder parts are discarded. By voxelizing the vertex data of the pathfinding model in a virtual game scene, the corresponding height field data of that pathfinding model can be obtained.

[0062] In the gaming field, convex hulls can be used as bounding boxes for collision detection. A two-dimensional polygon is called a polygon, and its convex hull is called a convex polygon. A three-dimensional polyhedron is called a polyhedron, and its convex hull is called a convex polyhedron. In this embodiment, the convex polyhedron data enclosing the pathfinding model, i.e., the convex hull data corresponding to the pathfinding model, can be obtained based on the model data of the pathfinding model.

[0063] In this embodiment of the disclosure, after preloading the preset index information, the model data of the pathfinding model intersecting with the pathfinding grid can be obtained through the preset index information. Then, the model data is used to generate the height field data and / or convex hull data of the pathfinding model intersecting with the pathfinding grid. The height field data and / or convex hull data of the pathfinding model intersecting with the pathfinding grid can be compressed and cached in the shared memory.

[0064] In the subsequent dynamic reconstruction of the pathfinding mesh, in order to avoid excessive performance consumption in the real-time generation of height field data and convex hull data, some of the required height field data and / or convex hull data can be pre-generated and cached.

[0065] Furthermore, since the generated height field data and convex hull data are large in volume, they cannot all be stored in the form of height field and convex hull. Therefore, LRU Cache (the LRU Cache caching mechanism is a caching mechanism implemented using the LRU algorithm, which stands for Least Recently Used algorithm) can be used to compress and cache these two data.

[0066] Cache some height field data and / or convex hull data in advance during the game server startup phase to avoid excessive performance consumption during the subsequent real-time reconstruction of the pathfinding mesh, thereby further improving the reconstruction speed of the pathfinding mesh.

[0067] In an optional embodiment of this disclosure, sub-step S11 involves preloading the preset index information and obtaining model data of the pathfinding model intersecting the pathfinding grid through the preset index information. Specifically, this may include the following sub-steps:

[0068] Identify hotspot areas for the game scene and determine the pathfinding grid corresponding to the hotspot areas; obtain model data of pathfinding models that intersect with the pathfinding grid using the preset index information.

[0069] In practice, the corresponding height field data and convex hull data can be generated and cached only for model data in hotspot areas.

[0070] In one example, hotspot areas can be game scene regions that require frequent pathfinding mesh reconstruction, as determined by statistics. The game scene can be divided into multiple regions, and the frequency of pathfinding mesh reconstruction in each region can be statistically analyzed. Regions with high frequency of reconstruction are then identified as hotspot areas.

[0071] In another example, a hotspot region can be a game scene area where the pathfinding mesh reconstruction speed exceeds a set reconstruction speed threshold. If the pathfinding mesh reconstruction speed of a certain game scene area is greater than the preset reconstruction speed threshold, then that game scene area can be identified as a hotspot region.

[0072] Step 202: In response to the update command for the pathfinding object, determine the first pathfinding grid covered by the pathfinding object.

[0073] The pathfinding mesh intersects with the corresponding pathfinding model. Update commands can be either creation or deletion commands.

[0074] During game operation, in response to a creation or deletion command for a pathfinding object, the first pathfinding grid covered by the pathfinding object can be determined from all pathfinding grids. In this embodiment of the disclosure, the pathfinding grid covered by the pathfinding object is referred to as the first pathfinding grid, which may include one or more pathfinding grids. Determining the first pathfinding grid covered by the pathfinding object can specifically involve calculating the pathfinding grids covered by the bounding box of the pathfinding object.

[0075] Step 203: If the pathfinding data corresponding to the first pathfinding grid hits the cached data, obtain the height field data of the pathfinding model that intersects with the first pathfinding grid from the hit cached data.

[0076] In this embodiment of the disclosure, when the pathfinding data corresponding to the first pathfinding grid hits the cached data, the height field data of the pathfinding model intersecting with the first pathfinding grid can be directly obtained from the hit cached data.

[0077] For any pathfinding grid in the first pathfinding grid, if the cache is hit, the height field data of the pathfinding model intersecting with that pathfinding grid can be decompressed and obtained.

[0078] Step 204: Obtain the model data of the pathfinding object, and use the model data of the pathfinding object and the height field data corresponding to the pathfinding model intersecting with the first pathfinding grid to generate a second pathfinding grid, so as to enable the virtual object to find its way in the pathfinding area of ​​the pathfinding object.

[0079] The second pathfinding grid includes the pathfinding region for the object being pathfinded. The virtual object can be an artificial intelligence object.

[0080] In practical implementation, for pathfinding objects dynamically placed by the player, it is necessary to obtain their corresponding model data. Model data that can dynamically generate pathfinding meshes can be divided into the following two types:

[0081] One type is a model pre-made by artists. Similar to offline recorded models, the corresponding model data (such as coordinates and storage path) can be cached in shared memory in advance. When needed, the corresponding model data, such as vertex data, can be retrieved from shared memory.

[0082] Another type is dynamically generated models by the game program, such as roads and bridges built by the player. For these models, their corresponding vertex data can be directly passed in. If these models also generate physical collisions, they can also be cached in shared memory for sharing.

[0083] In this embodiment of the disclosure, the model data of the pathfinding object and the height field data corresponding to the pathfinding model intersecting with the first pathfinding grid can be used to generate the corresponding second pathfinding grid.

[0084] Since convex hull data can also be cached, the model data of the pathfinding object and the convex hull data corresponding to the pathfinding model intersecting with the first pathfinding grid can be used to generate the corresponding second pathfinding grid, thereby updating the pathfinding region in the original first pathfinding grid and enabling the artificial intelligence object to find its way in the pathfinding region of the pathfinding object.

[0085] In an optional embodiment of this disclosure, step 204 uses the model data of the pathfinding object and the height field data corresponding to the pathfinding model intersecting with the first pathfinding grid to generate a second pathfinding grid, which may specifically include the following sub-steps:

[0086] Sub-step S21: The pathfinding object is voxelized using the model data of the pathfinding object to obtain the height field data of the pathfinding object.

[0087] Sub-step S22: Merge the height field data of the pathfinding object and the height field data of the pathfinding model that intersects with the first pathfinding grid to perform local reconstruction of the pathfinding grid and generate the corresponding second pathfinding grid in real time.

[0088] In this embodiment of the disclosure, the pathfinding object can be voxelized to obtain the corresponding height field data for the pathfinding object, and then the height field data corresponding to the pathfinding model intersecting with the first pathfinding grid can be merged to perform real-time dynamic local reconstruction of the pathfinding grid.

[0089] In practice, after the merging operation, unwalkable areas can be removed, a solid height field can be calculated, and then the processed data can be fed into Recast to construct a second pathfinding mesh.

[0090] In one optional embodiment of this disclosure, after generating the corresponding second pathfinding mesh in real time in sub-step S22, the following steps may also be performed:

[0091] The first pathfinding grid is replaced with the second pathfinding grid, and the second pathfinding grid is connected with the surrounding pathfinding grids that have not been replaced to generate a complete new pathfinding grid for the game scene.

[0092] In this embodiment of the disclosure, a second pathfinding grid can be used to replace the first pathfinding grid, and then the second pathfinding grid can be connected with the surrounding pathfinding grids that have not been replaced to generate a complete new pathfinding grid for the game scene.

[0093] Specifically, assuming the first pathfinding grid is A, the surrounding pathfinding grids connected to the first pathfinding grid A include B, C, D and E. The newly generated second pathfinding grid is A1. That is, in this step, the first pathfinding grid A can be replaced by the second pathfinding grid A1. The second pathfinding grid A1 is then connected to the surrounding pathfinding grids B, C, D and E to generate a complete pathfinding map.

[0094] A scene is divided into many grids based on the width and height of the grid. Each grid can generate its own pathfinding map before connecting to the surrounding grids. This method avoids the need to regenerate the entire scene's pathfinding map after modifying the pathfinding area; only local updates are required. This makes dynamic pathfinding reconstruction real-time and usable in games.

[0095] In practice, the newly generated second pathfinding grid can replace the original first pathfinding grid, and the index information of the first pathfinding grid can be reused. If the index information changes, the pathfinding obstacles that may be affected can be calculated and updated, the corresponding pathfinding grid can be generated, and a complete new pathfinding grid can be generated after a series of processes.

[0096] Furthermore, when multiple pathfinding objects are placed on a pathfinding grid—for example, a player placing multiple floor tiles / stairs blocks in an area, creating multiple pathfinding obstacles simultaneously—the pathfinding grid will be rebuilt multiple times. To address this, the duplicate pathfinding grid rebuilding operations can be merged during asynchronous frame-by-frame pathfinding grid updates. Additionally, pathfinding grid rebuilds caused by dynamically added or removed pathfinding objects, and pathfinding grid rebuilds caused by dynamically added or removed pathfinding obstacles, can be performed in a combined manner. This significantly reduces the number of pathfinding grid rebuilds.

[0097] In an optional embodiment of this disclosure, if the pathfinding data corresponding to the first pathfinding grid does not hit the cached data, the following steps may also be performed:

[0098] If the pathfinding data corresponding to the first pathfinding grid does not hit the cached data, the model data of the pathfinding model intersecting with the first pathfinding grid is obtained from the game's physical storage system; the model data of the pathfinding model intersecting with the first pathfinding grid is used to generate the height field data and / or convex hull data of the pathfinding model intersecting with the first pathfinding grid; the height field data and / or convex hull data of the pathfinding model intersecting with the first pathfinding grid are compressed and added to the shared memory as the cached data.

[0099] In this embodiment of the disclosure, if the pathfinding data corresponding to the first pathfinding grid does not hit the cached data, the model data of the pathfinding model intersecting with the first pathfinding grid can be obtained from the game's physical storage system. The model data is used to generate the corresponding height field data and / or convex hull data, which are then compressed and cached in shared memory.

[0100] Reference Figure 3 The diagram shown is a flowchart illustrating a pathfinding mesh generation method provided in this embodiment of the present disclosure. The specific process includes:

[0101] 1. During game operation, when adding or removing pathfinding objects in the game scene, the pathfinding grid of the game scene covered by the bounding box of the pathfinding object can be calculated, and preparations can be made to reconstruct the covered pathfinding grid.

[0102] 2. Determine whether the pathfinding data corresponding to the covered pathfinding grid has been pre-cached in shared memory;

[0103] 3. If it has been cached in shared memory, the corresponding pathfinding data can be obtained directly from the shared memory, as well as the height field data and convex hull data of the pathfinding model that intersects with the covered pathfinding mesh.

[0104] 4. If not cached in shared memory, the pathfinding data corresponding to the covered pathfinding mesh can be requested from the game's physical storage system, such as vertex data. Then, the corresponding height field data and convex hull data can be generated using the vertex data. The height field data and convex hull data can be compressed and cached in shared memory to update the cache.

[0105] 5. Voxelize the pathfinding object to obtain its corresponding height field data. Then, merge the height field data of the pathfinding object with the height field data of the pathfinding model that intersects with the covered pathfinding mesh. After that, the pathfinding mesh can be locally reconstructed according to the original process of generating the pathfinding mesh using Recast. If it is necessary to add or delete pathfinding obstacles in the covered pathfinding mesh, the pathfinding obstacles in the pathfinding mesh also need to be updated. After the update is completed, a new pathfinding mesh can be obtained, and then the entire pathfinding map can be updated.

[0106] In summary, in this embodiment, in response to an update command for a pathfinding object, the first pathfinding grid covered by the pathfinding object can be determined. If the pathfinding data corresponding to the first pathfinding grid hits the cached data, the height field data of the pathfinding model intersecting with the first pathfinding grid can be directly obtained from the cached data. Then, combined with the model data of the pathfinding object, the corresponding second pathfinding grid can be generated, thus constructing a pathfinding region for the pathfinding object. Virtual objects in the game can then pathfind within the newly created pathfinding region. By using the above method to reconstruct the pathfinding grid through the height field data of the cached pathfinding model, local reconstruction of the pathfinding grid can be achieved relatively quickly, solving the problem of high memory pressure and limited generation speed in existing solutions that dynamically generate pathfinding grids during game runtime.

[0107] This disclosure extends the implementation of Recast by sharing vertex data of the model and caching the height field between server processes to achieve pathfinding mesh reconstruction. In this disclosure, by storing the pathfinding model's resources in shared memory, the model data can be shared within the game process and used by both the game's physics and pathfinding systems. With an existing physics system, this solution introduces the index information recording the model data storage path and the height field data of hotspot areas into shared memory, reducing the memory performance overhead of real-time pathfinding reconstruction during game execution. This allows for faster dynamic reconstruction of the pathfinding mesh with less memory overhead. This disclosure addresses the issue of high memory consumption in existing solutions while maintaining reconstruction speed, enabling AI in the game to move freely within newly constructed game areas.

[0108] It should be noted that, for the sake of simplicity, the method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments of this disclosure are not limited to the described order of actions, because according to the embodiments of this disclosure, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also understand that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of this disclosure.

[0109] Reference Figure 4 The diagram shows a structural block diagram of a pathfinding mesh generation device provided in an embodiment of this disclosure, which may specifically include the following modules:

[0110] The determination module 401 is used to respond to the update command for the pathfinding object and determine the first pathfinding grid covered by the pathfinding object; the pathfinding grid intersects with the corresponding pathfinding model; wherein, the pathfinding object is an object that can be dynamically added or removed from the game and is used to block the movement of game objects or provide new walkable areas for game objects; the pathfinding model is a model of one or more game objects in the virtual game scene;

[0111] The first acquisition module 402 is used to acquire the height field data of the pathfinding model that intersects with the first pathfinding grid from the cached data when the pathfinding data corresponding to the first pathfinding grid hits the cached data.

[0112] The acquisition and generation module 403 is used to acquire the model data of the pathfinding object, and use the model data of the pathfinding object and the height field data corresponding to the pathfinding model intersecting with the first pathfinding grid to generate a second pathfinding grid, so as to enable the virtual object to find a path in the pathfinding area of ​​the pathfinding object; the second pathfinding grid includes the pathfinding area for the pathfinding object.

[0113] In this embodiment of the disclosure, the pathfinding grid corresponding to the game scene is generated offline and stores pathfinding data corresponding to the pathfinding grid. The device further includes:

[0114] The preloading module is used to preload preset index information when the game server starts, and obtain the corresponding cached data to be stored in shared memory; the index information is used to find the pathfinding data corresponding to each pathfinding grid in the game scene.

[0115] In this embodiment of the disclosure, the pathfinding data includes model data of the pathfinding model intersecting with the pathfinding grid, and the preloading module includes:

[0116] The preloading and acquisition submodule is used to preload the preset index information and acquire the model data of the pathfinding model that intersects with the pathfinding grid through the preset index information.

[0117] A generation submodule is used to generate height field data and / or convex hull data of the pathfinding model that intersects with the pathfinding grid, using model data of the pathfinding model that intersects with the pathfinding grid.

[0118] The compression and caching submodule is used to compress the height field data and / or convex hull data of the pathfinding model that intersects with the pathfinding mesh and store them as cache data in shared memory.

[0119] In this embodiment of the disclosure, the preloading and acquisition submodule includes:

[0120] A determining unit is used to determine hotspot areas for the game scene and to determine the pathfinding grid corresponding to the hotspot areas;

[0121] The acquisition unit is used to acquire model data of the pathfinding model that intersects with the pathfinding grid through the preset index information.

[0122] In this embodiment of the disclosure, the acquisition and generation module includes:

[0123] The voxelization submodule is used to voxelize the pathfinding object using the model data of the pathfinding object, so as to obtain the height field data of the pathfinding object.

[0124] The merge generation submodule is used to merge the height field data of the pathfinding object and the height field data corresponding to the pathfinding model that intersects with the first pathfinding grid to perform local reconstruction of the pathfinding grid and generate the corresponding second pathfinding grid in real time.

[0125] In this embodiment of the disclosure, the apparatus further includes:

[0126] The replacement and generation module is used to replace the first pathfinding grid with the second pathfinding grid, and connect the second pathfinding grid with the surrounding pathfinding grids that have not been replaced, to generate a complete new pathfinding grid for the game scene.

[0127] In this embodiment of the disclosure, the apparatus further includes:

[0128] The second acquisition module is used to acquire model data of the pathfinding model that intersects with the first pathfinding grid from the game's physical storage system when the pathfinding data corresponding to the first pathfinding grid does not hit the cached data.

[0129] The generation module is used to generate height field data and / or convex hull data of the pathfinding model that intersects with the first pathfinding grid using model data of the pathfinding model that intersects with the first pathfinding grid.

[0130] The compression and caching module is used to compress the height field data and / or convex hull data of the pathfinding model that intersects with the first pathfinding mesh and add it to the shared memory as cache data.

[0131] In summary, in this embodiment, in response to an update command for a pathfinding object, the first pathfinding grid covered by the pathfinding object can be determined. If the pathfinding data corresponding to the first pathfinding grid hits the cached data, the height field data of the pathfinding model intersecting with the first pathfinding grid can be directly obtained from the cached data. Then, combined with the model data of the pathfinding object, the corresponding second pathfinding grid can be generated, thus constructing a pathfinding region for the pathfinding object. Virtual objects in the game can then pathfind within the newly created pathfinding region. By using the above method to reconstruct the pathfinding grid through the height field data of the cached pathfinding model, local reconstruction of the pathfinding grid can be achieved relatively quickly, solving the problem of high memory pressure and limited generation speed in existing solutions that dynamically generate pathfinding grids during game runtime.

[0132] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.

[0133] This disclosure also provides an electronic device, including: a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, it implements the various processes of the above-described pathfinding mesh generation method embodiments and achieves the same technical effects. To avoid repetition, it will not be described again here.

[0134] This disclosure also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the various processes of the above-described pathfinding mesh generation method embodiments and achieves the same technical effects. To avoid repetition, it will not be described again here.

[0135] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.

[0136] Those skilled in the art will understand that embodiments of this disclosure can be provided as methods, apparatus, or computer program products. Therefore, embodiments of this disclosure can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, embodiments of this disclosure can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0137] This disclosure describes embodiments of methods, terminal devices (systems), and computer program products according to embodiments of this disclosure with reference to flowchart illustrations and / or block diagrams. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0138] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0139] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal equipment, causing a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0140] While preferred embodiments of the present disclosure have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the present disclosure.

[0141] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.

[0142] The foregoing has provided a detailed description of a pathfinding mesh generation method, a pathfinding mesh generation device, an electronic device, and a computer-readable storage medium provided by this disclosure. Specific examples have been used to illustrate the principles and implementation methods of this disclosure. The descriptions of the above embodiments are only for the purpose of helping to understand the method and its core ideas. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this disclosure. Therefore, the content of this specification should not be construed as a limitation of this disclosure.

Claims

1. A method for generating a pathfinding mesh, characterized in that, The pathfinding grid corresponding to the game scene is generated offline and stores pathfinding data corresponding to the pathfinding grid. The method includes: When the game server starts, it preloads preset index information and obtains corresponding cached data in shared memory; the index information is used to find the pathfinding data corresponding to each pathfinding grid in the game scene, and the index information stores path information. In response to an update command for a pathfinding object, the first pathfinding grid covered by the pathfinding object is determined; the pathfinding grid intersects with the corresponding pathfinding model; wherein, the pathfinding object is an object that can be dynamically added or removed from the game, used to block the movement of game objects or to provide new walkable areas for game objects; the pathfinding model is a model of one or more game objects in the virtual game scene; If the pathfinding data corresponding to the first pathfinding grid hits the cached data, the height field data of the pathfinding model that intersects with the first pathfinding grid is obtained from the hit cached data. The hit cached data refers to the cache storing the data to be obtained. The cached data includes pathfinding data corresponding to a portion of the pathfinding grid. The model data of the pathfinding object is obtained, and the pathfinding object is voxelized using the model data to obtain the height field data of the pathfinding object. The height field data of the pathfinding object and the height field data of the pathfinding model that intersects with the first pathfinding grid are merged to perform local reconstruction of the pathfinding grid, and a corresponding second pathfinding grid is generated in real time to enable the virtual object to find its way in the pathfinding area of ​​the pathfinding object; the second pathfinding grid includes the pathfinding area for the pathfinding object.

2. The method according to claim 1, characterized in that, The pathfinding data includes model data of pathfinding models intersecting with the pathfinding grid. The preloading of preset index information and the acquisition of corresponding cached data stored in shared memory include: The preset index information is preloaded, and the model data of the pathfinding model intersecting with the pathfinding grid is obtained through the preset index information; The height field data and / or convex hull data of the pathfinding model intersecting the pathfinding grid are generated using the model data of the pathfinding model intersecting the pathfinding grid. The height field data and / or convex hull data of the pathfinding model intersecting with the pathfinding mesh are compressed and stored as cache data in shared memory.

3. The method according to claim 2, characterized in that, The step of preloading the preset index information and obtaining model data of the pathfinding model intersecting with the pathfinding grid through the preset index information includes: Identify hotspot areas for the game scene and determine the pathfinding grid corresponding to the hotspot areas; The model data of the pathfinding model intersecting with the pathfinding grid is obtained through the preset index information.

4. The method according to claim 1, characterized in that, After generating the corresponding second pathfinding grid in real time, the method further includes: The first pathfinding grid is replaced with the second pathfinding grid, and the second pathfinding grid is connected with the surrounding pathfinding grids that have not been replaced to generate a complete new pathfinding grid for the game scene.

5. The method according to claim 1, characterized in that, The method further includes: If the pathfinding data corresponding to the first pathfinding grid does not hit the cached data, the model data of the pathfinding model that intersects with the first pathfinding grid is obtained from the game's physical storage system. The height field data and / or convex hull data of the pathfinding model intersecting with the first pathfinding grid are generated using the model data of the pathfinding model intersecting with the first pathfinding grid. The height field data and / or convex hull data of the pathfinding model intersecting with the first pathfinding mesh are compressed and added to the shared memory as cache data.

6. A pathfinding grid generation device, characterized in that, The pathfinding grid corresponding to the game scene is generated offline and stores pathfinding data corresponding to the pathfinding grid. The device includes: The preloading module is used to preload preset index information when the game server starts, and obtain the corresponding cached data to be stored in shared memory; the index information is used to find the pathfinding data corresponding to each pathfinding grid in the game scene, and the index information is stored path information; A determination module is used to respond to an update command for a pathfinding object and determine the first pathfinding grid covered by the pathfinding object; the pathfinding grid intersects with the corresponding pathfinding model; wherein, the pathfinding object is an object that can be dynamically added or removed from the game and is used to block the movement of game objects or provide new walkable areas for game objects; the pathfinding model is a model of one or more game objects in the virtual game scene; The first acquisition module is used to acquire the height field data of the pathfinding model that intersects with the first pathfinding grid from the cached data when the pathfinding data corresponding to the first pathfinding grid hits the cached data. The cached data refers to the cache storing the data to be acquired. The cached data includes pathfinding data corresponding to a portion of the pathfinding grid. The acquisition and generation module is used to acquire the model data of the pathfinding object, and use the model data of the pathfinding object and the height field data corresponding to the pathfinding model intersecting with the first pathfinding grid to generate a second pathfinding grid, so as to enable the virtual object to find its way in the pathfinding area of ​​the pathfinding object; the second pathfinding grid includes the pathfinding area for the pathfinding object. The acquisition and generation module includes: The voxelization submodule is used to voxelize the pathfinding object using the model data of the pathfinding object, so as to obtain the height field data of the pathfinding object. The merge generation submodule is used to merge the height field data of the pathfinding object and the height field data corresponding to the pathfinding model that intersects with the first pathfinding grid to perform local reconstruction of the pathfinding grid and generate the corresponding second pathfinding grid in real time.

7. An electronic device, characterized in that, include: A processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements the pathfinding mesh generation method as described in any one of claims 1-5.

8. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, which, when executed by a processor, implements the pathfinding mesh generation method as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Path-finding navigation method and device capable of dynamic modification for super-large map

    CN111013146A

  • Multi-thread updating method of path-finding grid

    CN112295225A