Route searching method and device in virtual scene, computer device and storage medium

By voxelizing the 3D virtual scene and generating continuous voxel information, the problem of low efficiency in aerial pathfinding was solved, and efficient path construction was achieved.

CN116139488BActive Publication Date: 2026-06-12UBTECH ROBOTICS CORP LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
UBTECH ROBOTICS CORP LTD
Filing Date
2022-12-30
Publication Date
2026-06-12

AI Technical Summary

Technical Problem

In a 3D game space, aerial pathfinding requires consideration of various data such as terrain height and aerial obstacles, resulting in low efficiency and high cost of existing pathfinding algorithms, making it difficult to meet the needs of games.

Method used

By voxelizing the 3D virtual scene model, free voxel grids without obstacles are identified, and continuous voxel information is generated from continuous free voxel grids in a preset direction. This information and the A* algorithm are used to determine the target path.

🎯Benefits of technology

It improves the efficiency of aerial pathfinding, avoids the inefficiency and high cost caused by a large amount of obstacle information, and achieves efficient path construction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116139488B_ABST
    Figure CN116139488B_ABST
Patent Text Reader

Abstract

The application discloses a path searching method and device in a virtual scene, computer equipment and a storage medium, relates to the path construction field, and the method comprises the steps of obtaining a three-dimensional virtual scene model; voxelizing the scene model and the object model respectively to obtain a first voxel grid corresponding to the scene model and a second voxel grid corresponding to the object model; determining the coordinates of each first voxel grid and the coordinates of each second voxel grid; taking the first voxel grid which does not coincide with the coordinates of the second voxel grid as an idle voxel grid; determining the idle voxel grids which are continuous in a preset direction in all idle voxel grids to obtain voxel continuous information; and determining a target path based on the voxel continuous information and the start coordinates and end coordinates in the path searching request when the path searching request is received. Thus, the application is based on the voxel continuous information, so that the path construction can be completed based on the region without obstacles and continuously walkable in the virtual space when searching for a path.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of path construction, and more particularly to a pathfinding method, device, computer equipment, and storage medium in a virtual scene. Background Technology

[0002] In a 3D game space, aerial pathfinding needs to consider data such as terrain height and aerial obstacles simultaneously, thus requiring a large amount of pathfinding reference data. However, with a large amount of pathfinding reference data, blindly using various pathfinding algorithms to construct paths is inefficient and costly, making it difficult to meet the requirements of current game settings. Summary of the Invention

[0003] In view of this, the present invention provides a pathfinding method, apparatus, computer device and storage medium in a virtual scene, to improve the current situation where aerial pathfinding is inefficient and costly.

[0004] In a first aspect, embodiments of the present invention provide a pathfinding method in a virtual scene, comprising:

[0005] Obtain a three-dimensional virtual scene model, wherein the three-dimensional virtual scene model includes a scene model and an object model;

[0006] The scene model and the object model are voxelized respectively to obtain multiple first voxel grids corresponding to the scene model 0 and multiple second voxel grids corresponding to the object model;

[0007] Determine the coordinates of each first voxel grid and the coordinates of each second voxel grid;

[0008] All first voxel cells whose coordinates do not coincide with the coordinates of the second voxel cell are designated as free voxel cells;

[0009] Identify the consecutive free voxel cells in a preset direction among all free voxel cells to obtain more than 5 voxel continuity information, wherein the preset direction is one of the three-dimensional directions representing three-dimensional space, and the voxel continuity information includes the coordinates of consecutive free voxel cells.

[0010] In response to a pathfinding request, a target path is determined based on the continuous information of the multiple voxels and the starting and ending coordinates in the pathfinding request.

[0011] Optionally, in one feasible embodiment of the present invention, the step of responding to a pathfinding request and determining a target path based on the plurality of voxel continuity information and the start and end coordinates in the pathfinding request includes:

[0012] In response to the pathfinding request, the target path is determined based on the A* algorithm, the continuous information of the multiple voxels, and the starting and ending coordinates in the pathfinding request.

[0013] Optionally, in one feasible embodiment of the present invention, the three-dimensional virtual scene model is located in a preset space, the preset space includes multiple sub-space regions of the same size, and the voxel continuity information also includes the length corresponding to continuous free voxel grids;

[0014] The process of determining consecutive empty voxel lattices in a preset direction among all empty voxel lattices yields multiple voxel continuity information, including:

[0015] Based on the coordinates of the free voxel grids, determine the number of consecutive free voxel grids in a preset direction in each subspace region and the coordinates of the starting free voxel grid of the consecutive free voxel grids;

[0016] Based on the coordinates of the initial free voxel grid in each subspace region and the number of consecutive free voxel grids containing the initial free voxel grid, voxel continuity information for each subspace region is generated.

[0017] Optionally, in one feasible embodiment of the present invention, the method further includes:

[0018] Write the continuous voxel information of each of the spatial regions into a preset file;

[0019] In response to the loading request corresponding to the 3D virtual scene model, the preset file is loaded.

[0020] Optionally, in one feasible embodiment of the present invention, each of the subspace regions is a space composed of a preset Y-axis length and an XY plane.

[0021] Secondly, embodiments of the present invention provide a pathfinding device in a virtual scene, comprising:

[0022] An acquisition module is used to acquire a three-dimensional virtual scene model, wherein the three-dimensional virtual scene model includes a scene model and an object model;

[0023] A voxelization module is used to voxelize the scene model and the object model respectively, to obtain multiple first voxel grids corresponding to the scene model and multiple second voxel grids corresponding to the object model;

[0024] A coordinate determination module is used to determine the coordinates of each first voxel grid and the coordinates of each second voxel grid;

[0025] The idle determination module is used to identify all first voxel lattices whose coordinates do not coincide with the coordinates of the second voxel lattice as idle voxel lattices.

[0026] The information acquisition module is used to determine the continuous free voxel grids in a preset direction among all free voxel grids, and obtain multiple voxel continuity information, wherein the preset direction is one of the three-dimensional directions representing three-dimensional space, and the voxel continuity information includes the coordinates of the continuous free voxel grids.

[0027] The pathfinding module is used to respond to pathfinding requests and determine the target path based on the continuous information of the multiple voxels and the starting and ending coordinates in the pathfinding request.

[0028] Optionally, in one feasible embodiment of the present invention, the pathfinding module is further configured to respond to a pathfinding request and determine the target path based on the A* algorithm, the multiple voxel continuity information, and the start and end coordinates in the pathfinding request.

[0029] Thirdly, embodiments of the present invention provide a computer device, including a memory and a processor, wherein the memory stores a computer program, and the computer program executes a pathfinding method in any of the virtual scenes described in the first aspect when it is run on the processor.

[0030] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing a computer program, which, when run on a processor, executes a pathfinding method in any of the virtual scenes described in the first aspect.

[0031] The pathfinding method in a virtual scene provided by this invention firstly acquires a three-dimensional virtual scene model; then, the scene model and object model in the three-dimensional virtual scene model are voxelized to obtain multiple first voxel grids corresponding to the scene model and multiple second voxel grids corresponding to the object model; subsequently, the coordinates of each first voxel grid and the coordinates of each second voxel grid are determined; then, all first voxel grids whose coordinates do not coincide with the coordinates of the second voxel grids are designated as free voxel grids, thereby determining the space corresponding to each voxel grid without obstacles; next, the consecutive free voxel grids in a preset direction among all free voxel grids are determined to obtain multiple voxel continuity information, that is, to determine the space that is without obstacles and continuously walkable; finally, when a pathfinding request is received, the target path is determined based on the multiple voxel continuity information and the starting and ending coordinates in the pathfinding request. Based on this, the present invention uses pre-constructed continuous voxel information to enable pathfinding to construct a path from the starting point to the destination based on a continuous feasible / walkable area in the virtual space without obstacles. This avoids the situation where conventional aerial pathfinding mechanisms have low pathfinding efficiency and high cost due to a large amount of obstacle information, thus improving the efficiency of aerial pathfinding. Attached Figure Description

[0032] To more clearly illustrate the technical solution of the present invention, the accompanying drawings used in the embodiments will be briefly described below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope of protection of the present invention. In the various drawings, similar components are numbered similarly.

[0033] Figure 1 A flowchart illustrating the first pathfinding method in a virtual scene provided by an embodiment of the present invention is shown;

[0034] Figure 2 A flowchart illustrating a second pathfinding method in a virtual scene provided by an embodiment of the present invention is shown;

[0035] Figure 3 A flowchart illustrating the third virtual scene pathfinding method provided in this embodiment of the invention is shown.

[0036] Figure 4 A schematic diagram of the structure of the pathfinding device in a virtual scene provided in an embodiment of the present invention is shown. Detailed Implementation

[0037] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.

[0038] The components of the embodiments of the invention described and illustrated herein can typically be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.

[0039] In the following, the terms “comprising,” “having,” and their cognates, which may be used in various embodiments of the invention, are intended only to indicate a particular feature, number, step, operation, element, component, or combination thereof, and should not be construed as excluding, firstly, the presence of one or more other features, numbers, steps, operations, elements, components, or combinations thereof, or adding the possibility of one or more features, numbers, steps, operations, elements, components, or combinations thereof.

[0040] Furthermore, the terms "first," "second," and "third" are used only to distinguish descriptions and should not be interpreted as indicating or implying relative importance.

[0041] Unless otherwise specified, all terms used herein (including technical and scientific terms) shall have the same meaning as commonly understood by one of ordinary skill in the art to which the various embodiments of the invention pertain. Terms (such as those defined in commonly used dictionaries) shall be interpreted as having the same meaning as in their contextual meaning in the relevant technical field and shall not be interpreted as having an idealized or overly formal meaning, unless clearly defined in the various embodiments of the invention.

[0042] Example 1

[0043] Reference Figure 1 The diagram illustrates a flowchart of a first pathfinding method in a virtual scene provided by an embodiment of the present invention. The pathfinding method in a virtual scene provided by the present invention includes:

[0044] Step S110: Obtain a three-dimensional virtual scene model, wherein the three-dimensional virtual scene model includes a scene model and an object model.

[0045] It is understood that the three-dimensional virtual scene model in the embodiments of the present invention can be understood as a game scene.

[0046] It is also understood that the three-dimensional virtual scene model in the embodiments of the present invention is actually divided into two parts: one part refers to the scene and the other part refers to the objects in the scene. That is, the three-dimensional virtual scene model includes two parts: the scene model and the object model.

[0047] It's easy to understand that a scene model can be understood as an area in the game, while an object model represents various objects in that area, such as trees, mountains, rivers, and wild animals.

[0048] Another point to consider is that when game characters move around an area, they usually need to avoid the aforementioned objects such as trees, mountains, rivers, and wild animals to reach their destination. In other words, the aforementioned objects are usually regarded as obstacles to be avoided.

[0049] Step S120: Voxelize the scene model and the object model respectively to obtain multiple first voxel grids corresponding to the scene model and multiple second voxel grids corresponding to the object model.

[0050] That is, in this embodiment of the invention, the aforementioned scene model and object model are voxelized to convert them into corresponding voxel grids, namely the first voxel grid and the second voxel grid.

[0051] Optionally, in one feasible embodiment of the present invention, the aforementioned first voxel lattice and second voxel lattice can both refer to a 1m*1m*1m cube.

[0052] It is understood that the specific methods / tools / software used to complete the voxelization of scene models and object models are optional and can be set according to the actual situation. This embodiment of the invention does not limit this.

[0053] Step S130: Determine the coordinates of each first voxel grid and the coordinates of each second voxel grid.

[0054] It should be clarified that the coordinates of the first voxel lattice and the coordinates of the second voxel lattice determined in the embodiments of the present invention belong to the same coordinate system.

[0055] It is understandable that, since the 3D virtual scene model and the scene model refer to two models with the same spatial size, the coordinates of the first voxel grid corresponding to the scene model can be directly determined using the coordinate system corresponding to the 3D virtual scene model.

[0056] It is also understandable that, for the second voxel grid corresponding to the object model, since the object model is usually constructed / created separately and then loaded into the scene model, in other words, the coordinate system of the coordinates of each voxel grid obtained by voxelizing the object model is inconsistent with the coordinate system corresponding to the 3D virtual scene model. Therefore, after voxelizing each object model to obtain the voxel grid and its coordinates, it is necessary to multiply these coordinates with the coordinate transformation matrix corresponding to the 3D virtual scene model. Finally, the coordinates of the second voxel grid are in the same coordinate system as the coordinates of the first voxel grid.

[0057] Step S140: All first voxel grids whose coordinates do not coincide with the coordinates of the second voxel grid are designated as free voxel grids.

[0058] In other words, this embodiment of the invention determines the overlap between the first voxel grid and the second voxel grid based on the coordinates of each voxel grid. It is easy to understand that the space corresponding to the first voxel grid can be regarded as having no objects, while if the coordinates of the first voxel grid and the second voxel grid overlap, it indicates that the space corresponding to the first voxel grid contains the object corresponding to the second voxel grid.

[0059] Furthermore, after determining the overlap of each voxel grid in this embodiment of the invention, the first voxel grid that does not overlap with the second voxel grid is designated as an empty voxel grid. It is easy to understand that in this embodiment of the invention, the space corresponding to the empty voxel grid does not contain any objects, that is, there are no obstacles.

[0060] Optionally, in one feasible approach, this embodiment of the invention distinguishes between free and non-free voxel cells based on the identifier value of each voxel cell. Specifically, in this feasible approach, the identifier value of each first voxel cell is defaulted to 0, indicating that there are no obstacles in the space corresponding to the voxel cell. When the coordinates of the first voxel cell coincide with the coordinates of the second voxel cell, the identifier value of the first voxel cell is updated to 1, indicating that there are obstacles in the space corresponding to the voxel cell. Therefore, this embodiment of the invention utilizes all voxels with an identifier value of 0 to perform subsequent steps.

[0061] Step S150: Determine the consecutive empty voxel grids in a preset direction among all the empty voxel grids to obtain multiple voxel continuity information, wherein the preset direction is one of the three-dimensional directions representing three-dimensional space, and the voxel continuity information includes the coordinates of the consecutive empty voxel grids.

[0062] Understandably, if multiple empty voxel grids are connected sequentially, i.e., continuous, the game character can move directly within the space corresponding to these multiple empty voxel grids. Furthermore, if, during pathfinding, the voxel grid containing the starting point and the voxel grid containing the ending point are continuous in a preset direction, the path from the starting point to the ending point can be determined directly based on the continuity of the empty voxel grids.

[0063] It can also be understood that the preset direction in the embodiments of the present invention is one of the X-axis direction, Z-axis direction and Y-axis direction.

[0064] In one instance, the positive direction of the X-axis in the game scene is from west to east, the positive direction of the Z-axis is from south to north, and the positive direction of the Y-axis is opposite to the direction of gravity. In this instance, the aforementioned preset direction is the Y-axis direction. Therefore, in this feasible mode, the embodiment of the present invention will determine the voxel continuity of each XZ plane on an XZ plane basis.

[0065] It should also be noted that the embodiments of the present invention will generate corresponding voxel continuity information based on continuous free voxel grids in a preset direction. It is understood that because the embodiments of the present invention generate voxel continuity information based on voxel continuity in a preset direction, the corresponding voxel continuity information may be inconsistent for voxel grids at different positions. Therefore, multiple voxel continuity information will be obtained when executing step S150. For example, taking the aforementioned XZ plane as a unit to determine voxel continuity, some voxels in the XZ plane corresponding to Y=0 are continuous with some voxels in the XZ plane corresponding to Y=1, while other pixels in the XZ plane corresponding to Y=1 are continuous with pixels in the XZ plane corresponding to Y=3. Thus, it can be seen that there are multiple voxel continuity cases in this example, and therefore multiple voxel continuity information.

[0066] It should also be noted that the voxel continuity information in the embodiments of the present invention is used to describe continuous voxels in a preset direction. Therefore, the voxel continuity information includes the coordinates of continuous voxels. Furthermore, since the embodiments of the present invention generate voxel continuity information based on the continuity of voxels in a preset direction, in a preferred embodiment of the present invention, the corresponding voxel continuity information is generated using the coordinates of the first voxel among a plurality of continuous voxels and the number / length of voxels corresponding to this "plurality of continuous voxels". Moreover, based on the coordinates of the first voxel, the number / length of continuous voxels, and the fact that the continuous voxels are continuous in a preset direction, different types of voxel continuity can be accurately described. Therefore, in a feasible embodiment of the present invention, a voxel continuity information consists of 7 bytes, of which 2 bytes are occupied by any dimension coordinate in the three-dimensional coordinate system, and 1 byte is occupied by the length / number of continuous voxels.

[0067] Step S160: In response to the pathfinding request, determine the target path based on the multiple voxel continuity information and the start and end coordinates in the pathfinding request.

[0068] That is, based on the voxel continuity information output in the aforementioned step S150, and the starting point information (i.e., starting coordinates) and ending point information (i.e. ending point coordinates) carried in the pathfinding request, the embodiment of the present invention will construct the path for the game character to travel from the starting point to the ending point.

[0069] It is easy to understand that, because the embodiments of the present invention generate / construct the corresponding prior knowledge (i.e., voxel continuous information) in advance before pathfinding, the computer device will directly use the voxel continuous information that has been determined in the voxel continuous information to know the walkable path / area during the pathfinding process, so that there is no need to execute obstacle avoidance or related logic.

[0070] Based on this, the embodiments of the present invention, based on pre-constructed continuous voxel information, enable pathfinding to construct a path from the starting point to the destination based on a continuous feasible / walkable area in the virtual space without obstacles. This avoids the situation where conventional aerial pathfinding mechanisms suffer from low pathfinding efficiency and high cost due to a large amount of obstacle information, thus improving the efficiency of aerial pathfinding.

[0071] Optionally, in one feasible embodiment of the present invention, please refer to the following: Figure 2 The diagram illustrates a second pathfinding method in a virtual scene provided by an embodiment of the present invention. In this feasible mode, step S160 specifically includes:

[0072] S161, responding to the pathfinding request, determine the target path based on the A* algorithm, the continuous information of the multiple voxels, and the starting and ending coordinates in the pathfinding request.

[0073] That is, the embodiments of the present invention will construct the target path from the starting coordinates to the ending coordinates based on the A* algorithm.

[0074] It is understandable that the execution of the A* algorithm requires loading obstacle information in the scene. However, with the provision of continuous voxel information in this embodiment of the invention, the execution of the A* algorithm can directly construct a path based on unobstructed and continuous voxel grids, thereby effectively improving the execution efficiency of the A* algorithm.

[0075] Furthermore, it is understood that using the A* algorithm to perform pathfinding in the embodiments of the present invention is only one feasible method, and other algorithms may be used to complete pathfinding in the embodiments of the present invention.

[0076] Optionally, in one feasible embodiment of the present invention, please refer to the following: Figure 3 The diagram illustrates a flowchart of a third virtual scene pathfinding method provided by an embodiment of the present invention. In this feasible mode, the three-dimensional virtual scene model is located in a preset space, the preset space includes multiple subspace regions of the same size, and the voxel continuity information also includes the length corresponding to continuous free voxel grids.

[0077] Therefore, in this optional approach, step S150 specifically includes:

[0078] S151, based on the coordinates of the free voxel grids, determine the number of consecutive free voxel grids in a preset direction in each subspace region and the coordinates of the starting free voxel grid of the consecutive free voxel grids;

[0079] S152, based on the coordinates of the starting free voxel grid in each subspace region and the number of consecutive free voxel grids containing the starting free voxel grid, voxel continuity information for each subspace region is generated.

[0080] That is, in this feasible approach, the embodiments of the present invention pre-divide the preset space where the 3D virtual scene model is located into multiple sub-space regions of the same size, and then determine the voxel continuity information in each sub-space region. In one feasible approach, each sub-space region is a space composed of a preset Y-axis length and an XY plane.

[0081] Furthermore, an example is given using a subspace region as an example, defined by a preset Y-axis length and the XY plane. For the voxel lattice in this embodiment, each voxel lattice can be correspondingly assigned to a spatial region. Exemplarily, assuming the aforementioned Y-axis length is 100, the space formed by the XY planes corresponding to 0 to 100 on the Y-axis is the first subspace region, and the space formed by the XY planes corresponding to 101 to 200 on the Y-axis is the second subspace region. Then, when the Y-axis coordinate of a voxel lattice is between 0 and 100, it belongs to the first subspace region; and when the Y-axis coordinate of a voxel lattice is between 101 and 200, it belongs to the second subspace region.

[0082] Optionally, in one feasible embodiment of the present invention, a corresponding region number is generated for each subspace region, and the region numbers of different subspace regions are different.

[0083] It should be noted that after dividing the complete space into multiple subspace regions, the embodiments of the present invention will determine the continuous voxel information in the subspace region based on the overlap of voxel lattices in each subspace region.

[0084] It should also be noted that the voxel continuity information in this feasible method will include the coordinates of the first voxel in the "multiple consecutive voxels" and the number / length of the "multiple consecutive voxels". Therefore, this voxel continuity information consists of 7 bytes, of which 2 bytes are occupied by any dimension coordinate in the three-dimensional coordinate system, and 1 byte is occupied by the length / number of consecutive voxels.

[0085] Therefore, the embodiments of the present invention will complete continuous voxel detection based on subspace regions, thereby avoiding the situation where high resource consumption would occur if continuous voxel detection were performed directly on the entire space.

[0086] Optionally, in one feasible embodiment of the present invention, the method further includes:

[0087] Write the continuous voxel information of each of the subspace regions into a preset file;

[0088] In response to the loading request corresponding to the 3D virtual scene model, the preset file is loaded.

[0089] That is, in this embodiment of the invention, the voxel continuous information of each spatial region is written into a preset file, and then, when the pathfinding request is triggered, the target path is constructed based on the loaded preset file.

[0090] It is understandable that the method of writing the voxel continuity information of the subspace region to a preset file is customizable based on actual conditions. For example, in one feasible method provided by this embodiment, because the space size of each subspace region is relatively large, storing it in a single file may result in slow read / write speeds. Therefore, it is stored in the form of multiple header files and offsets. In another feasible method, the space size of the virtual scene model is relatively small, so it is stored in a single file. This file contains each voxel continuity information itself and the corresponding identifier.

[0091] Meanwhile, the embodiments of the present invention also set the loading trigger of the preset file to be triggered by the loading request corresponding to the three-dimensional virtual scene model. That is, when the three-dimensional virtual scene model needs to be loaded, the aforementioned preset file is loaded simultaneously, so that the pathfinding process can be seamlessly connected after the three-dimensional virtual scene model is loaded.

[0092] Example 2

[0093] Corresponding to the pathfinding method in a virtual scene provided in Embodiment 1 of the present invention, Embodiment 2 of the present invention also provides a pathfinding device in a virtual scene, referring to... Figure 4 The diagram illustrates the structure of a pathfinding device in a virtual scene provided in an embodiment of the present invention. The pathfinding device 200 in the virtual scene provided in this embodiment of the present invention includes:

[0094] The acquisition module 210 is used to acquire a three-dimensional virtual scene model, wherein the three-dimensional virtual scene model includes a scene model and an object model;

[0095] The voxelization module 220 is used to voxelize the scene model and the object model respectively to obtain a plurality of first voxel grids corresponding to the scene model and a plurality of second voxel grids corresponding to the object model.

[0096] The coordinate determination module 230 is used to determine the coordinates of each first voxel grid and the coordinates of each second voxel grid;

[0097] The idle determination module 240 is used to identify all first voxel grids whose coordinates do not coincide with the coordinates of the second voxel grid as idle voxel grids.

[0098] The information acquisition module 250 is used to determine the continuous free voxel grids in a preset direction among all free voxel grids, and obtain multiple voxel continuity information, wherein the preset direction is one of the three-dimensional directions representing three-dimensional space, and the voxel continuity information includes the coordinates of the continuous free voxel grids.

[0099] The pathfinding module 260 is used to respond to a pathfinding request and determine the target path based on the multiple voxel continuity information and the start and end coordinates in the pathfinding request.

[0100] Optionally, in one feasible embodiment of the present invention, the pathfinding module is further configured to respond to a pathfinding request and determine the target path based on the A* algorithm, the multiple voxel continuity information, and the start and end coordinates in the pathfinding request.

[0101] Optionally, in one feasible embodiment of the present invention, the three-dimensional virtual scene model is located in a preset space, the preset space includes multiple sub-space regions of the same size, and the voxel continuity information also includes the length corresponding to continuous free voxel grids;

[0102] The information obtaining module includes:

[0103] The starting coordinate determination submodule is used to determine, based on the coordinates of the free voxel grids, the number of consecutive free voxel grids in a preset direction in each subspace region and the coordinates of the starting free voxel grid of the consecutive free voxel grids;

[0104] The information generation submodule is used to generate voxel continuity information for each subspace region based on the coordinates of the starting free voxel cell in each subspace region and the number of consecutive free voxel cells containing the starting free voxel cell.

[0105] Optionally, in one feasible embodiment of the present invention, the method further includes:

[0106] The writing module is used to write the voxel continuity information of each of the spatial regions to a preset file;

[0107] The loading module is used to load the preset file in response to the loading request corresponding to the three-dimensional virtual scene model.

[0108] Optionally, in one feasible embodiment of the present invention, each of the subspace regions is a space composed of a preset Y-axis length and an XY plane.

[0109] The virtual scene pathfinding device 200 provided in this application embodiment can realize each process of the pathfinding method in the virtual scene corresponding to Embodiment 1, and can achieve the same technical effect. To avoid repetition, it will not be described again here.

[0110] This invention also provides a computer device, including a memory and a processor. The memory stores a computer program, and the computer program executes the pathfinding method in the virtual scene as described in Embodiment 1 when it runs on the processor.

[0111] This invention also provides a computer-readable storage medium storing a computer program, which, when run on a processor, executes the pathfinding method in a virtual scene as described in Embodiment 1.

[0112] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative; for example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that, as an alternative implementation, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and combinations of blocks in the block diagram and / or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

[0113] In addition, the functional modules or units in the various embodiments of the present invention can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.

[0114] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a smartphone, personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0115] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention.

Claims

1. A pathfinding method in a virtual scene, characterized in that, include: Obtain a three-dimensional virtual scene model, wherein the three-dimensional virtual scene model includes a scene model and an object model; The scene model and the object model are voxelized respectively to obtain multiple first voxel grids corresponding to the scene model and multiple second voxel grids corresponding to the object model; Determine the coordinates of each first voxel grid and the coordinates of each second voxel grid; All first voxel grids whose coordinates do not coincide with the coordinates of the second voxel grid are designated as free voxel grids, and there are no objects in the space corresponding to the free voxel grids; Identify consecutive empty voxel lattices in a preset direction among all empty voxel lattices to obtain multiple voxel continuity information, wherein the preset direction is one of the three-dimensional directions representing three-dimensional space; In response to a pathfinding request, a target path is determined based on the continuous information of the multiple voxels and the starting and ending coordinates in the pathfinding request. The three-dimensional virtual scene model is located in a preset space, which includes multiple sub-space regions of the same size. Determining consecutive empty voxel grids in a preset direction among all empty voxel grids to obtain multiple voxel continuity information includes: Based on the coordinates of the free voxel grids, determine the number of consecutive free voxel grids in a preset direction in each subspace region and the coordinates of the starting free voxel grid of the consecutive free voxel grids; Based on the coordinates of the starting free voxel grid in each subspace region and the number of consecutive free voxel grids containing the starting free voxel grid, voxel continuity information for each subspace region is generated.

2. The pathfinding method in a virtual scene according to claim 1, characterized in that, The response to the pathfinding request, based on the multiple voxel continuity information and the start and end coordinates in the pathfinding request, determines the target path, including: In response to the pathfinding request, the target path is determined based on the A* algorithm, the continuous information of the multiple voxels, and the starting and ending coordinates in the pathfinding request.

3. The pathfinding method in a virtual scene according to claim 1, characterized in that, Also includes: Write the continuous voxel information of each subspace region to a preset file; In response to the loading request corresponding to the 3D virtual scene model, the preset file is loaded.

4. The pathfinding method in a virtual scene according to claim 1, characterized in that, Each of the subspace regions is a space formed by a preset Y-axis length and the XY plane.

5. A pathfinding device in a virtual scene, characterized in that, include: An acquisition module is used to acquire a three-dimensional virtual scene model, wherein the three-dimensional virtual scene model includes a scene model and an object model; A voxelization module is used to voxelize the scene model and the object model respectively, to obtain multiple first voxel grids corresponding to the scene model and multiple second voxel grids corresponding to the object model; A coordinate determination module is used to determine the coordinates of each first voxel grid and the coordinates of each second voxel grid; The idle determination module is used to identify all first voxel grids whose coordinates do not coincide with the coordinates of the second voxel grid as idle voxel grids, and there are no objects in the space corresponding to the idle voxel grids; The information acquisition module is used to determine the continuous free voxel grids in a preset direction among all free voxel grids, and obtain multiple voxel continuity information, wherein the preset direction is one of the three-dimensional directions representing three-dimensional space; The pathfinding module is used to respond to a pathfinding request and determine the target path based on the continuous information of the multiple voxels and the start and end coordinates in the pathfinding request. The three-dimensional virtual scene model is located in a preset space, which includes multiple sub-space regions of the same size. The information acquisition module includes: The starting coordinate determination submodule is used to determine, based on the coordinates of the free voxel grids, the number of consecutive free voxel grids in a preset direction in each subspace region and the coordinates of the starting free voxel grid of the consecutive free voxel grids; The information generation submodule is used to generate voxel continuity information for each subspace region based on the coordinates of the starting free voxel cell in each subspace region and the number of consecutive free voxel cells containing the starting free voxel cell.

6. The pathfinding device in a virtual scene according to claim 5, characterized in that, The pathfinding module is also used to respond to pathfinding requests and determine the target path based on the A* algorithm, the continuous information of the multiple voxels, and the starting and ending coordinates in the pathfinding request.

7. A computer device, characterized in that, It includes a memory and a processor, the memory storing a computer program that, when run on the processor, executes the pathfinding method in a virtual scene as described in any one of claims 1-4.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed on a processor, performs the pathfinding method in the virtual scene as described in any one of claims 1-4.