Data Processing Method, Device, Computer Equipment and Medium for Game Scenes

By generating sparse voxel octree and cropping immovable nodes, the problem of excessive voxel storage demand in three-dimensional game scenarios is solved, and the pathfinding speed and efficiency are improved.

CN114404984BActive Publication Date: 2025-07-25BEIJING PIXEL SOFTWARE TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111648703.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-30
Publication Date
2025-07-25
Estimated Expiration
2041-12-30

AI Technical Summary

Technical Problem

In three-dimensional game scenarios, when using voxels as pathfinding data, storage demand is too high, and existing algorithms such as the Dijkstra algorithm and the A* algorithm have problems with inefficiency.

Method used

By voxelizing the game scene, a sparse voxel octree is generated, immovable nodes are cut off, only movable nodes are retained, and the sparse voxel octree is stored and the pathfinding algorithm is optimized.

Benefits of technology

Reduces memory requirements for memory voxel nodes, and improves pathfinding speed and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114404984B_ABST
    Figure CN114404984B_ABST
Patent Text Reader

Abstract

An embodiment of the present invention discloses a data processing method, device, computer device and medium for a game scene. The method includes: voxelizing the game scene to determine the node information of each voxel node corresponding to the game scene; generating a sparse voxel octree based on the voxel nodes; selecting a preset number of nodes from the tree and writing them into a preset queue; taking out a node from the queue as a starting node and marking it; for each unmarked neighbor node adjacent to the starting node, if the starting node and the neighbor node meet a preset rule, writing the neighbor node into the queue; taking out a node from the queue again as a new starting node, and repeating the step of marking the starting node until the queue is empty, so as to mark all the markable nodes in the tree; deleting the unmarked nodes in the tree to obtain a trimmed tree. Thus, the present invention enables the nodes in the trimmed tree to be all nodes where game virtual characters can move, thereby reducing the space required to store voxel nodes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of games, and in particular to a method, apparatus, computer device and medium for processing data of a game scene. Background Art

[0002] In online games, it is often necessary to provide a movable route for a game character controlled by a player according to a pathfinding algorithm, which can avoid various static obstacles. Common pathfinding algorithms such as Dijkstra algorithm and A* algorithm need to convert the game scene into pathfinding data such as a map grid to complete pathfinding.

[0003] In pathfinding for a three-dimensional game scene, the game scene is often converted into three-dimensional voxels as pathfinding data. However, the memory occupied by voxels is very large. If the pathfinding accuracy is 1 meter, one voxel occupies 1 bit, and it takes about 1.5 GB of memory to store the game scene using a three-dimensional array.

[0004] It can be seen that there are still certain limitations in using voxels as pathfinding data in a three-dimensional game scene. Summary of the Invention

[0005] In view of this, the present invention provides a method, apparatus, computer device and medium for processing data of a game scene, which is used to improve the current situation that there are still certain limitations in using voxels as pathfinding data in a three-dimensional game scene.

[0006] In a first aspect, an embodiment of the present invention provides a method for processing data of a game scene, including:

[0007] Performing voxelization processing on the game scene, and determining node information of each voxel node corresponding to the game scene, where the node information includes height and node type, and the node type is used to indicate whether the voxel node intersects with the game scene;

[0008] Generating a sparse voxel octree corresponding to the game scene based on all the voxel nodes;

[0009] Selecting a preset number of nodes from the sparse voxel octree, and writing the preset number of nodes into a preset queue, where the preset number of nodes includes nodes where a game virtual character can move;

[0010] Taking out a node from the preset queue as a starting node, and marking the starting node;

[0011] For each neighbor node adjacent to the starting node and not marked, if it is determined that the starting node and the neighbor node satisfy a preset node connection rule according to the node information of the neighbor node and the node information of the starting node, then writing the neighbor node into the preset queue;

[0012] Take a node from the preset queue as the new starting node, and repeat the step of marking the starting node until the preset queue is empty;

[0013] Delete the unmarked nodes in the sparse voxel octree to obtain a cropped sparse voxel octree.

[0014] Optionally, in an implementation provided by an embodiment of the present invention, the node types include a first node type that does not intersect with the terrain of the game scene, and a second node type that intersects with the terrain of the game scene;

[0015] For each unmarked neighbor node adjacent to the starting node, if it is determined that the starting node and the neighbor node satisfy a preset node connection rule according to the node information of the neighbor node and the node information of the starting node, then write the neighbor node into the preset queue, including:

[0016] For each unmarked neighbor node adjacent to the starting node, if the type of the neighbor node and / or the starting node is the second node type, obtain the maximum height of the neighbor node and the maximum height of the starting node;

[0017] According to the terrain height map corresponding to the game scene, obtain the terrain height corresponding to the starting node and the terrain height corresponding to the starting node;

[0018] When the maximum height of the neighbor node is greater than the terrain height corresponding to the neighbor node, and the maximum height of the starting node is greater than the terrain height corresponding to the starting node, write the neighbor node into the preset queue.

[0019] Optionally, in an implementation provided by an embodiment of the present invention, after deleting the unmarked nodes in the sparse voxel octree to obtain a cropped sparse voxel octree, the method further includes:

[0020] Based on the cropped sparse voxel octree, generate subtrees of a preset size and corresponding parent trees for the subtrees.

[0021] Further, in an implementation provided by an embodiment of the present invention, after generating subtrees of a preset size and corresponding parent trees for the subtrees based on the cropped sparse voxel octree, the method further includes:

[0022] Record the adjacent situation of each node in each layer in the parent tree and each subtree, where the adjacent situation indicates whether there are adjacent nodes in a preset direction;

[0023] Label the trivial nodes in the 0th layer of the parent tree and each of the child trees, where the trivial node indicates that there are adjacent nodes in the preset direction of the trivial node.

[0024] Optionally, in an implementation provided by an embodiment of the present invention, after voxelizing the game scene and determining the node information of each voxel node corresponding to the game scene, before generating the sparse voxel octree corresponding to the game scene based on all the voxel nodes, the method further includes:

[0025] Based on the Morton code encoding rule, encode each voxel node as a Morton code node according to the type and position of each voxel node;

[0026] The generating the sparse voxel octree corresponding to the game scene based on all the voxel nodes includes:

[0027] Generate the sparse voxel octree corresponding to the game scene based on all the Morton code nodes.

[0028] Optionally, in an implementation provided by an embodiment of the present invention, the voxelizing the game scene and determining the node information of each voxel node corresponding to the game scene includes:

[0029] Divide the game scene into blocks based on a preset block size to obtain the blocks corresponding to the game scene;

[0030] Solve the type of each voxel node corresponding to each block through a preset bounding box;

[0031] Obtain the node information of each voxel node according to the type and height of each voxel node.

[0032] Further, in an implementation provided by an embodiment of the present invention, the solving the type of each voxel node corresponding to each block through a preset bounding box includes:

[0033] Obtain the terrain height map corresponding to the game scene;

[0034] Determine the lowest terrain value of each block according to the terrain height map;

[0035] Based on the preset bounding box, solve the type of each voxel node corresponding to each block with a height greater than the lowest terrain value.

[0036] In a second aspect, an embodiment of the present invention provides a data processing device for a game scene, including:

[0037] A voxelization module for voxelizing a game scene and determining node information for each voxel node corresponding to the game scene, where the node information includes height and node type, and the node type is used to indicate whether the voxel node intersects with the game scene;

[0038] A generation module for generating a sparse voxel octree corresponding to the game scene based on all the voxel nodes;

[0039] A first writing module for selecting a preset number of nodes from the sparse voxel octree and writing the preset number of nodes into a preset queue, where the preset number of nodes includes nodes that the game virtual character can move to;

[0040] A first reading module for taking out a node from the preset queue as a starting node and marking the starting node;

[0041] A second writing module for, for each unmarked neighbor node adjacent to the starting node, if it is determined that the starting node and the neighbor node satisfy a preset node connection rule according to the node information of the neighbor node and the node information of the starting node, writing the neighbor node into the preset queue;

[0042] A second reading module for taking out a node from the preset queue as a new starting node and repeating the step of marking the starting node until the preset queue is empty;

[0043] A pruning module for deleting the unmarked nodes in the sparse voxel octree to obtain a pruned sparse voxel octree.

[0044] In a third aspect, an embodiment of the present invention provides a computer device, including a memory and a processor, where the memory stores a computer program, and when the computer program runs on the processor, it executes the data processing method of the game scene disclosed in any one of the first aspects.

[0045] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, and when the computer program runs on a processor, it executes the data processing method of the game scene disclosed in any one of the first aspects.

[0046] In the data processing method for a game scene provided by an embodiment of the present invention, first, the game scene is voxelized, that is, all voxel nodes corresponding to the game scene are obtained. At the same time, the node information of each voxel node corresponding to the game scene is determined, such as whether it intersects with the terrain of the game scene, three-dimensional coordinate information, etc.; then, a sparse voxel octree corresponding to the game scene is generated based on all the voxel nodes to store the voxel nodes through the sparse voxel octree; then, a preset number of nodes are selected from the sparse voxel octree, and the preset number of nodes are written into a preset queue; a node is taken out from the preset queue as the starting node and the starting node is marked; for each neighbor node adjacent to the starting node and not marked, if it is determined that the starting node and the neighbor node meet the preset node connection rule according to the node information of the neighbor node and the starting node information, the neighbor node is written into the preset queue; that is, the computer device determines whether other nodes in the sparse voxel octree that have not been written into the preset queue can also be written into the preset queue; a node is taken out from the preset queue as a new starting node, and the step of marking the starting node is repeated until the preset queue is empty, that is, when the computer device continuously writes and reads the queue until all the nodes in the sparse voxel octree are traversed once, all the nodes in the sparse voxel octree that can be written into the preset queue are determined, and all the nodes in the preset queue are marked; the unmarked nodes in the sparse voxel octree are deleted to obtain a trimmed sparse voxel octree, that is, the nodes in the sparse voxel octree that cannot be moved by the game virtual character are deleted.

[0047] Thus, in the embodiment of the present invention, the voxel nodes corresponding to the game scene are stored through the sparse voxel octree, and the sparse voxel octree is trimmed, and the nodes in the sparse voxel octree that cannot be moved by the game virtual character are deleted, so that the nodes in the trimmed sparse voxel octree are all nodes that can be moved by the game virtual character, thereby reducing the memory space required for the computer device to store the voxel nodes; moreover, when the data processing method for the game scene provided by the embodiment of the present invention is applied to the actual pathfinding process, since the nodes in the trimmed sparse voxel octree are all nodes that can be moved by the game virtual character, the pathfinding algorithm can output the path more quickly, thereby improving the pathfinding speed. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to more clearly illustrate the technical solutions of the present invention, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as limiting the protection scope of the present invention. In each drawing, similar components are numbered similarly.

[0049] Figure 1 The flowchart showing the data processing method for the first game scene provided by the embodiment of the present invention is shown;

[0050] Figure 2 It shows a schematic flowchart of the data processing method for the second game scenario provided by the embodiment of the present invention;

[0051] Figure 3 It shows a schematic flowchart of the data processing method for the third game scenario provided by the embodiment of the present invention;

[0052] Figure 4 It shows a schematic structural diagram of the data processing device for the game scenario provided by the embodiment of the present invention. Detailed implementation manners

[0053] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments.

[0054] Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed present invention, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative efforts belong to the scope of protection of the present invention.

[0055] Hereinafter, the terms "including", "having" and their cognates that can be used in various embodiments of the present invention are only intended to represent specific features, numbers, steps, operations, elements, components or combinations of the foregoing items, and should not be construed as first excluding the existence of one or more other features, numbers, steps, operations, elements, components or combinations of the foregoing items or increasing the possibility of one or more features, numbers, steps, operations, elements, components or combinations of the foregoing items.

[0056] In addition, the terms "first", "second", "third", etc. are only used for distinguishing descriptions and cannot be understood as indicating or implying relative importance.

[0057] Unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meaning as commonly understood by those of ordinary skill in the art to which the various embodiments of the present invention belong. The terms (such as those defined in a commonly used dictionary) will be interpreted as having the same meaning as the contextual meaning in the relevant technical field and will not be interpreted as having an idealized meaning or an overly formal meaning unless clearly defined in the various embodiments of the present invention.

[0058] Refer to Figure 1, Figure 1 The figure shows a schematic flowchart of a data processing method for a first game scenario provided by an embodiment of the present invention. The data processing method for the game scenario provided by the embodiment of the present invention includes:

[0059] S101, perform voxelization on the game scenario, and determine the node information of each voxel node corresponding to the game scenario, where the node information includes height and node type, and the node type is used to indicate whether the voxel node intersects with the game scenario.

[0060] It can be understood that the game scenario in the embodiment of the present invention refers to the three-dimensional model corresponding to the game scenario, and performing voxelization on the game scenario means simplifying the three-dimensional model into multiple voxel nodes of the same size to describe the game scenario through the voxel nodes. Among them, each voxel node corresponds to a unique three-dimensional coordinate, and the three-dimensional coordinate is used to describe the position of the voxel node in the model. It should be noted that if the three-dimensional coordinates of the voxel node are described by the left-handed coordinate system, the height of the voxel node is the Y-axis coordinate.

[0061] Optionally, in a feasible manner provided in this embodiment, the size of each voxel node is 1 meter × 1 meter × 1 meter, that is, a voxel node represents a cube with a length, width, and height of 1 meter.

[0062] Furthermore, during the voxelization process, the embodiment of the present invention will also determine whether each voxel node intersects with the three-dimensional model corresponding to the game scenario, that is, determine the type of each voxel node.

[0063] It can also be understood that the processes of voxelization and node type judgment can be set according to actual situations. For example, in a feasible manner, the processes of voxelization and node type judgment may include: a computer device constructs a bounding box corresponding to the game scenario; voxelizes the bounding box; calculates the signed distance field value (SDF) of each voxel node according to the bounding box and the three-dimensional model corresponding to the game scenario, and determines the type of each voxel node according to the signed distance field value.

[0064] And in a feasible manner, the processes of voxelization and node type judgment, that is, S101, include:

[0065] Based on a preset block size, divide the game scenario into blocks to obtain the blocks corresponding to the game scenario;

[0066] Solve the type of each voxel node corresponding to each block through a preset bounding box;

[0067] Obtain the node information of each voxel node according to the type and height of each voxel node.

[0068] That is, in this implementation, the computer device first divides the three-dimensional model corresponding to the game scene into multiple blocks; for each block, an intersection judgment is performed using a preset axis-aligned bounding box, and then the type of each voxel node corresponding to each block is obtained.

[0069] It should be understood that through the GPU (graphics processing unit), the computer device can quickly complete the voxelization process and the voxel node intersection judgment. However, when the three-dimensional model corresponding to the game scene is too large, directly performing the voxelization process and the voxel node intersection judgment on the complete game scene requires ensuring that the video memory of the GPU is large enough to support the execution of the voxelization process and the voxel node intersection judgment.

[0070] Therefore, in the embodiments of the present invention, in order to enable the computer device to complete the voxelization process and the voxel node intersection judgment through the GPU, the game scene is divided into blocks, so that the computer device can use the GPU to quickly perform the voxelization process and the voxel node intersection judgment on each block.

[0071] In addition, it should be noted that the embodiments of the present invention do not limit the preset block size, and the preset block size can be set according to actual needs.

[0072] Furthermore, in order to further reduce the video memory pressure of the GPU, in an implementation provided by the embodiments of the present invention, the process of solving the type of each voxel node corresponding to each block through the preset bounding box includes:

[0073] Obtain the terrain height map corresponding to the game scene;

[0074] Determine the lowest terrain value of each block according to the terrain height map;

[0075] Based on the preset bounding box, solve the type of each voxel node whose height in each block is greater than the lowest terrain value.

[0076] That is, during the process of the computer device performing the voxelization process and the node type judgment on the block, the lowest value of the terrain height map of each block will be obtained. It can be understood that in game design, the terrain height map is often used to simulate hills and valleys in real life; the terrain height map can be understood as an array, and each element of the array represents the height position of the ground surface of a certain range of the game scene. It is not difficult to understand that the game virtual characters in the game generally move above the ground surface, and the position below the ground surface is usually considered immovable.

[0077] Therefore, in this embodiment of the present invention, voxelization processing and node type judgment are performed according to the lowest height at which the game virtual character can move, that is, the lowest value of the terrain height map of the blocks. That is to say, after the computer device generates voxel nodes, it will not solve the node types of voxel nodes with height positions less than the lowest value of the terrain height map, and thus voxel nodes with height positions less than the lowest value of the terrain height map will not participate in subsequent steps. Thereby, the load on the GPU and the computer device is further reduced.

[0078] S102. Generate a sparse voxel octree corresponding to the game scene based on all the voxel nodes.

[0079] That is to say, the computer device arranges all the voxel nodes into a sparse voxel octree (SVO) structure.

[0080] Optionally, in a feasible manner, the computer device starts generating the sparse voxel octree structure from the 0th layer of the sparse voxel octree.

[0081] It should be understood that the embodiment of the present invention does not limit the specific generation process of the sparse voxel octree by the computer device, and the generation process of the sparse voxel octree can be set according to the actual situation.

[0082] S103. Select a preset number of nodes from the sparse voxel octree and write the preset number of nodes into a preset queue, where the preset number of nodes includes nodes that the game virtual character can move.

[0083] It should be understood that the nodes written into the preset queue are all nodes that can be moved by the game virtual character, that is, the game virtual character can move in the game scene corresponding to the nodes.

[0084] It should also be understood that whether a node can be moved by the game virtual character can be set according to the actual situation. For example, in a feasible manner, if a node does not intersect with the terrain of the game scene, that is, the game scene corresponding to the node is the sky, and in the game setting, the game character can move in the sky, the nodes that do not intersect with the terrain of the game scene will be recognized as nodes that can be moved by the game virtual character.

[0085] In another feasible manner, whether a node can be moved by the game virtual character will be determined according to the height of the node and the terrain height map of the game scene. That is to say, the terrain height of the game scene corresponding to the node is determined according to the terrain height map, and then the maximum height of the node is obtained. If the maximum height of the node is greater than the terrain height of the game scene, the node will be recognized as a node that can be moved by the game virtual character. It can be understood that if the size of the node is 1 meter × 1 meter × 1 meter, then the height position of the node plus 1 meter represents the maximum height of the node.

[0086] It should also be noted that the specific process of selecting nodes from the sparse voxel octree in the embodiments of the present invention is not limited, and can be specifically set according to the actual situation.

[0087] For example, in a feasible manner, the selection of nodes will be completed by receiving the input of the staff.

[0088] In another feasible manner, the computer device traverses all nodes to search for nodes that can be moved by the game virtual character, and then randomly selects multiple nodes from all the nodes that can be moved by the game virtual character and writes them into a preset queue.

[0089] S104, Take out a node from the preset queue as the starting node and mark the starting node.

[0090] That is, take out a node from the preset queue to reduce the queue size of the preset queue by 1. And take the taken-out node as the starting node to determine whether the game character can move from the starting node to other adjacent nodes in the subsequent process.

[0091] It should be understood that marking a node means that the game scene corresponding to the node can be moved by the game virtual character.

[0092] S105, For each neighbor node adjacent to the starting node and not marked, if it is determined that the starting node and the neighbor node satisfy the preset node connection rule according to the node information of the neighbor node and the node information of the starting node, then write the neighbor node into the preset queue.

[0093] That is, the computer device first determines whether the neighbor node adjacent to the starting node has been marked. If not, it will determine whether the game virtual character can move from the starting node to the neighbor node. It can be understood that if the neighbor node has been marked, the game virtual character can move in the game scene corresponding to the neighbor node, and thus the game virtual character can move from the starting node to the neighbor node. Therefore, the computer device will skip the neighbor node.

[0094] It should be understood that the definition of the neighbor node can be set according to the actual situation, and the embodiments of the present invention do not make additional limitations. In a feasible manner, the neighbor node of the starting node is the node connected to the starting node in the preset direction of the starting node.

[0095] Exemplarily, if the size of any node is 1 meter × 1 meter, the preset directions include the X-axis direction and the Y-axis direction, and the coordinates of a node are set as (1, 1), then the neighbor nodes of this node may include the node with coordinates (0, 1), the node with coordinates (2, 1), the node with coordinates (1, 2), and the node with coordinates (1, 0).

[0096] Further, after determining the neighbor nodes of the starting node, the computer device will determine whether the node information of the neighbor nodes and the node information of the starting node meet the preset node connection rule, that is, determine whether the game character moves from the game scene corresponding to the starting node to the game scene corresponding to the neighbor node.

[0097] It should be noted that the embodiments of the present invention do not limit the specific process of the preset node connection rule, that is, determining whether the game virtual character can move from the starting node to the neighbor node. The specific process can be set according to the actual situation.

[0098] In a feasible manner, for example, the process of determining whether the game virtual character can move from the starting node to the neighbor node includes: if both the starting node and the neighbor node are nodes that do not intersect with the terrain of the game scene, it is considered that the game virtual character can move from the starting node to the neighbor node.

[0099] In a feasible embodiment provided by the embodiments of the present invention, when the node type includes a first node type that does not intersect with the terrain of the game scene and a second node type that intersects with the terrain of the game scene, the S105 includes:

[0100] For each unmarked neighbor node adjacent to the starting node, if the type of the neighbor node and / or the starting node is the second node type, obtain the maximum height of the neighbor node and the maximum height of the starting node;

[0101] According to the terrain height map corresponding to the game scene, obtain the terrain height corresponding to the starting node and the terrain height corresponding to the starting node;

[0102] When the maximum height of the neighbor node is greater than the terrain height corresponding to the neighbor node, and the maximum height of the starting node is greater than the terrain height corresponding to the starting node, write the neighbor node into the preset queue.

[0103] It should be understood that the first node type indicates that the voxel node does not intersect with the ground surface of the game scene, that is, the game scene corresponding to the voxel node is a space above the ground surface where there are no game object models such as house models, or a space above the ground surface including game object models; the second node type indicates that the game scene corresponding to the voxel node is a space including above and below the ground surface.

[0104] It should also be understood that the node type of the voxel node can be set according to the actual situation, and the embodiments of the present invention do not impose excessive limitations. For example, in a feasible manner, the first node type is divided into a blank node type and a non - blank node type. Among them, the blank node type indicates that the game scene corresponding to the voxel node is a space without any game object models; the non - blank node type indicates that the game scene corresponding to the voxel node is a space above the ground surface and including game object models.

[0105] Furthermore, when the node type of any one of the starting node and the neighbor node is the second node type, that is, any one of the nodes intersects with the terrain of the game scene, the computer device will obtain the maximum height of the two nodes, that is, determine the height of the node according to the size and position of the node.

[0106] Then, according to the terrain height map corresponding to the game scene, determine the height position of the terrain of the game scene corresponding to the node, that is, the terrain height.

[0107] Finally, for any one of the two nodes, determine whether the maximum height of the node is greater than the terrain height; if so, it means that the game virtual character can move above the ground of the game scene corresponding to the node, and then write the neighbor node into the preset queue; if not, it means that the game scene corresponding to the node is below the ground, and then the game virtual character cannot move in the game scene corresponding to the point.

[0108] It can be understood that when the embodiments of the present invention do not limit the types of the starting node and the neighbor node to other situations, the computer device will not limit the specific process of how to determine whether the game virtual character can move from the starting node to the neighbor node, and the specific process can be set according to the actual situation.

[0109] For example, in a feasible manner, if the game scenes corresponding to the starting node and the neighbor node both represent spaces above the ground surface without any object models, it is determined that the game virtual character can move from the starting node to the neighbor node.

[0110] In addition, it should also be noted that according to the definition of the sparse voxel octree, in two adjacent upper and lower layers of the sparse voxel octree, 1 upper - layer node corresponds to 8 lower - layer nodes. Furthermore, it can be known that 1 upper - layer node with a size of 4m×4m×4m corresponds to 8 lower - layer nodes with a size of 2m×2m×2m, and then corresponds to 64 lower - layer nodes with a size of 1m×1m×1m. For any node in the sparse voxel octree whose size is not 1m×1m×1m, if the lower - layer nodes corresponding to the node include nodes of the second node type, then the node whose size is not 1m×1m×1m is also determined to be of the second node type.

[0111] Further, when calculating the maximum height of any node whose size is not 1 meter × 1 meter × 1 meter, the node with the highest height position among all the lower-layer nodes corresponding to the node is selected to calculate the maximum height.

[0112] S106, Take a node from the preset queue as a new starting node, and repeat the step of marking the starting node until the preset queue is empty.

[0113] It can be understood that in the foregoing steps, whenever the starting node and the neighboring node satisfy the preset node connection rule, the neighboring node will be written into the preset queue; and the nodes in the preset queue will be continuously taken out and marked. When the preset queue is empty, for any two adjacent nodes in the sparse voxel octree, if both nodes are marked, it means that the game virtual character can move from one node to the other; and if only one of the two nodes is marked or neither is marked, it means that the game virtual character cannot move from one node to the other.

[0114] S107, Delete the unmarked nodes in the sparse voxel octree to obtain a cropped sparse voxel octree.

[0115] That is, the computer device crops the sparse voxel octree to delete the unmarked nodes, that is, the nodes where the game virtual character cannot move. Furthermore, in the cropped sparse voxel octree, all nodes are nodes where the game virtual character can move, and the game virtual character can move from one of two adjacent nodes to the other.

[0116] Thus, in the embodiment of the present invention, the voxel nodes corresponding to the game scene are stored through the sparse voxel octree, and the sparse voxel octree is cropped to delete the nodes in the sparse voxel octree where the game virtual character cannot move, so that the nodes in the cropped sparse voxel octree are all nodes where the game virtual character can move, thereby reducing the memory space required for the computer device to store voxel nodes; moreover, when applying the game scene data processing method provided in the embodiment of the present invention to the actual pathfinding process, since the nodes in the cropped sparse voxel octree are all nodes where the game virtual character can move, the pathfinding algorithm can output the path more quickly, thus improving the pathfinding speed.

[0117] Optionally, the process of the computer device cropping the sparse voxel octree may include: if all the lower-layer nodes corresponding to an upper-layer node are nodes where the game virtual character can move and the types are all second-type nodes, the computer device will delete the upper-layer node and mark the upper-layer node in the upper-layer node corresponding to the more upper-layer node to avoid generating the upper-layer node when rendering the voxel grid through the sparse voxel octree later.

[0118] Exemplarily, in a node with a size of 4 meters × 4 meters × 4 meters, among the 64 lower-layer nodes with a size of 1 meter × 1 meter × 1 meter, when all the nodes with a size of 1 meter × 1 meter × 1 meter are second-type nodes and are not nodes where game virtual characters can move, the computer device will mark the node with a size of 4 meters × 4 meters × 4 meters in the upper-layer node with a size of 8 meters × 8 meters × 8 meters corresponding to the node with a size of 4 meters × 4 meters × 4 meters.

[0119] Furthermore, the process of the computer device trimming the sparse voxel octree may further include: when there is a lower-layer node to be deleted among all the lower-layer nodes corresponding to an upper-layer node, the upper-layer node will also be deleted.

[0120] Thereby, the memory space occupied by the sparse voxel octree is further reduced; and when the embodiment of the present invention is applied to the actual pathfinding process, since there is a lower-layer node to be deleted among all the lower-layer nodes corresponding to an upper-layer node, the upper-layer node will also be deleted, thus avoiding the situation where the pathfinding algorithm accesses immovable lower-layer nodes through the upper-layer node and improving the pathfinding efficiency.

[0121] Optionally, in an implementation manner provided by the embodiment of the present invention, specifically, reference may be made to Figure 2 , Figure 2 which shows a schematic flowchart of the data processing method for the second game scenario provided by the embodiment of the present invention. That is, after S107, the method further includes:

[0122] S108, based on the trimmed sparse voxel octree, generate a subtree with a preset size and a parent tree corresponding to the subtree.

[0123] It can be understood that the preset size can be adjusted according to the actual situation and is not limited in the embodiment of the present invention.

[0124] It can also be understood that the parent tree is a tree including the original tree, that is, the root node of the trimmed sparse voxel octree. And the subtree is a part of the trimmed sparse voxel octree. Thus, when the game scenario changes, the corresponding subtree can be directly modified instead of directly modifying the trimmed sparse voxel octree, reducing the load on the computer device when the game scenario is modified.

[0125] Further, in an implementation manner provided by the embodiment of the present invention, specifically, reference may be made to Figure 3 , Figure 3 which shows a schematic flowchart of the data processing method for the third game scenario provided by the embodiment of the present invention. That is, after S108, the method further includes:

[0126] S109. Record the adjacency of each node in each layer of the parent tree and each of the child trees, where the adjacency indicates whether there are adjacent nodes in a preset direction.

[0127] S110. Mark the trivial nodes in the 0th layer of the parent tree and each of the child trees, where the trivial node means that there are adjacent nodes in the preset direction of the trivial node.

[0128] It can be understood that the preset direction can be set according to the actual situation. For example, in a feasible way, the preset directions include 6 directions such as the positive x-axis direction, the negative x-axis direction, the positive y-axis direction, the negative y-axis direction, the positive z-axis direction, and the negative z-axis direction. Furthermore, the adjacency of each node represents which direction among the 6 directions of the node has neighbor nodes and which direction does not have neighbor nodes. And the trivial node means that neighbor nodes exist in all 6 directions of the node. In other words, the game virtual character can move to the plane where any one of the neighbor nodes is located through the trivial node.

[0129] Thus, since the embodiments of the present invention record the adjacency of each node and mark the trivial nodes, when the embodiments of the present invention are applied to the actual pathfinding process, the computer device can complete route planning according to the adjacency and the trivial nodes, thereby effectively improving the pathfinding efficiency.

[0130] Optionally, in an implementation manner provided by the embodiments of the present invention, after performing voxelization processing on the game scene and determining the node information of each voxel node corresponding to the game scene, before generating the sparse voxel octree corresponding to the game scene based on all the voxel nodes, the method further includes:

[0131] Based on the Morton code encoding rule, encode each voxel node into a Morton code node according to the type and position of each voxel node.

[0132] The generating the sparse voxel octree corresponding to the game scene based on all the voxel nodes includes:

[0133] Generate the sparse voxel octree corresponding to the game scene based on all the Morton code nodes.

[0134] Exemplarily, the process of generating Morton code nodes from voxel nodes may include: for 512 voxel nodes with a size of 1 meter × 1 meter × 1 meter, generate a key-value pair corresponding to each voxel node according to the three-dimensional coordinates and type of each voxel node, and sort and combine the 512 voxel nodes to obtain a voxel node block with a size of 8 meters × 8 meters × 8 meters, that is, the Morton code node.

[0135] It should be noted that the key in the key-value pair is calculated through the three-dimensional coordinates of the voxel node; the value in the key-value pair is the type of the voxel node.

[0136] It should also be noted that the Morton code encoding rule can convert any coordinate in space into an unsigned integer number, which can ensure that the numbers of each voxel node do not repeat, and the order of each voxel node can be quickly determined through the unsigned integer number corresponding to the coordinate of each voxel node.

[0137] Based on this, in the embodiment of the present invention, after encoding the voxel nodes into Morton code nodes based on the Morton code encoding rule, each voxel node in the Morton code nodes can be efficiently sorted in an optional manner. For example, in a feasible manner, each voxel node in the Morton code nodes is sorted in the order of the z-axis, thereby improving the generation efficiency of the sparse voxel octree.

[0138] Corresponding to the data processing method of the game scene provided by the embodiment of the present invention, the embodiment of the present invention also provides a data processing device for the game scene. Referring to Figure 4 , Figure 4 FIG. shows a schematic structural diagram of the data processing device for the game scene provided by the embodiment of the present invention. The data processing device 200 for the game scene provided by the embodiment of the present invention includes:

[0139] A voxelization module 201, configured to perform voxelization processing on the game scene and determine the node information of each voxel node corresponding to the game scene, where the node information includes height and node type, and the node type is used to indicate whether the voxel node intersects with the game scene;

[0140] A generation module 202, configured to generate a sparse voxel octree corresponding to the game scene based on all the voxel nodes;

[0141] A first writing module 203, configured to select a preset number of nodes from the sparse voxel octree and write the preset number of nodes into a preset queue;

[0142] A first reading module 204, configured to take out a node from the preset queue as a starting node and mark the starting node;

[0143] A second writing module 205, configured to, for each neighbor node adjacent to the starting node and not marked, if it is determined that the starting node and the neighbor node satisfy a preset node connection rule according to the node information of the neighbor node and the node information of the starting node, write the neighbor node into the preset queue;

[0144] A second reading module 206, configured to take a node from the preset queue as a new starting node, and repeatedly execute the step of marking the starting node until the preset queue is empty;

[0145] A clipping module 207, configured to delete the unmarked nodes in the sparse voxel octree to obtain a clipped sparse voxel octree.

[0146] The game scene data processing device provided by the embodiments of the present application can implement Figure 1 each process of the game scene data processing method in the method embodiment shown, and can achieve the same technical effect. To avoid repetition, it will not be elaborated here.

[0147] An embodiment of the present invention further provides a computer device, including a memory and a processor. The memory stores a computer program, and when the computer program runs on the processor, it executes the game scene data processing method disclosed in the method embodiment as Figure 1 shown.

[0148] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program runs on the processor, it executes the game scene data processing method disclosed in the method embodiment as Figure 1 shown.

[0149] In several embodiments provided by the present application, it should be understood that the disclosed device and method can also be implemented in other ways. The device embodiments described above are merely illustrative. For example, the flowcharts and structure diagrams in the drawings show the possible architectures, functions, and operations of the device, method, and computer program product according to multiple embodiments of the present invention. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code, and the module, program segment, or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in an alternative implementation, the functions marked in the blocks may occur in a different order than marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the structure diagram and / or flowchart, and the combination of blocks in the structure diagram and / or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.

[0150] In addition, in each embodiment of the present invention, the various functional modules or units may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.

[0151] If the above-mentioned functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a smart phone, a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The foregoing storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs.

[0152] The above is only the specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present invention can easily think of changes or substitutions, which should all be covered by the protection scope of the present invention.

Claims

1. A data processing method for a game scenario, characterized in that, Including: Voxelize the game scene and determine the node information of each voxel node corresponding to the game scene, where the node information includes height and node type, and the node type is used to indicate whether the voxel node intersects with the game scene; Generate a sparse voxel octree corresponding to the game scene based on all the voxel nodes; Select a preset number of nodes from the sparse voxel octree and write the preset number of nodes into a preset queue, where the preset number of nodes includes nodes that the game virtual character can move to; Take out a node from the preset queue as the starting node and mark the starting node; For each unmarked neighbor node adjacent to the starting node, if it is determined that the starting node and the neighbor node satisfy a preset node connection rule according to the node information of the neighbor node and the node information of the starting node, then write the neighbor node into the preset queue; Take out a node from the preset queue as a new starting node, and repeat the step of marking the starting node until the preset queue is empty; Delete the unmarked nodes in the sparse voxel octree to obtain a cropped sparse voxel octree; The node type includes a first node type that does not intersect with the terrain of the game scene, and a second node type that intersects with the terrain of the game scene; The step of, for each unmarked neighbor node adjacent to the starting node, if it is determined that the starting node and the neighbor node satisfy a preset node connection rule according to the node information of the neighbor node and the node information of the starting node, then write the neighbor node into the preset queue, includes: For each unmarked neighbor node adjacent to the starting node, if the type of the neighbor node and / or the starting node is the second node type, obtain the maximum height of the neighbor node and the maximum height of the starting node; According to the terrain height map corresponding to the game scene, obtain the terrain height corresponding to the starting node and the terrain height corresponding to the starting node; When the maximum height of the neighbor node is greater than the terrain height corresponding to the neighbor node, and the maximum height of the starting node is greater than the terrain height corresponding to the starting node, write the neighbor node into the preset queue.

2. The method according to claim 1, wherein After the step of deleting the unmarked nodes in the sparse voxel octree to obtain a cropped sparse voxel octree, the method further includes: Generate a subtree of a preset size and a parent tree corresponding to the subtree based on the cropped sparse voxel octree.

3. The method according to claim 2, wherein After the step of generating a subtree of a preset size and a parent tree corresponding to the subtree based on the cropped sparse voxel octree, the method further includes: Record the adjacent situation of each node in each layer of the parent tree and each subtree, where the adjacent situation indicates whether there are adjacent nodes in a preset direction; Mark the trivial nodes in the 0th layer of the parent tree and each subtree, where the trivial node indicates that there are adjacent nodes in the preset direction of the trivial node.

4. The method according to claim 1, characterized in that, After performing voxelization on the game scene and determining the node information of each voxel node corresponding to the game scene, before generating the sparse voxel octree corresponding to the game scene based on all the voxel nodes, the method further includes: Based on the Morton code encoding rule, encoding each voxel node as a Morton code node according to the type and position of each voxel node; The generating the sparse voxel octree corresponding to the game scene based on all the voxel nodes includes: Generating the sparse voxel octree corresponding to the game scene based on all the Morton code nodes.

5. The method according to claim 1, characterized in that The performing voxelization on the game scene and determining the node information of each voxel node corresponding to the game scene includes: Dividing the game scene into blocks based on a preset block size to obtain the blocks corresponding to the game scene; Solving the type of each voxel node corresponding to each block through a preset bounding box; Obtaining the node information of each voxel node according to the type and height of each voxel node.

6. The method according to claim 5, wherein The solving the type of each voxel node corresponding to each block through a preset bounding box includes: Obtaining the terrain height map corresponding to the game scene; Determining the lowest terrain value of each block according to the terrain height map; Based on the preset bounding box, solving the type of each voxel node corresponding to each block with a height greater than the lowest terrain value.

7. A data processing device for a game scene, characterized in that Includes: A voxelization module for performing voxelization on the game scene and determining the node information of each voxel node corresponding to the game scene, where the node information includes height and node type, and the node type is used to indicate whether the voxel node intersects with the game scene; A generation module for generating the sparse voxel octree corresponding to the game scene based on all the voxel nodes; A first writing module for selecting a preset number of nodes from the sparse voxel octree and writing the preset number of nodes into a preset queue, where the preset number of nodes includes the nodes where the game virtual character can move; A first reading module for taking out a node from the preset queue as the starting node and marking the starting node; A second writing module for, for each unmarked neighbor node adjacent to the starting node, if it is determined that the starting node and the neighbor node satisfy a preset node connection rule according to the node information of the neighbor node and the node information of the starting node, writing the neighbor node into the preset queue; A second reading module for taking out a node from the preset queue as the new starting node and repeating the step of marking the starting node until the preset queue is empty; A pruning module for deleting the unmarked nodes in the sparse voxel octree to obtain the pruned sparse voxel octree; The node type includes a first node type that does not intersect with the terrain of the game scene and a second node type that intersects with the terrain of the game scene; The second writing module is further configured to, for each unmarked neighbor node adjacent to the starting node, if the type of the neighbor node and / or the starting node is the second node type, obtain the maximum height of the neighbor node and the maximum height of the starting node; According to the terrain height map corresponding to the game scene, obtain the terrain height corresponding to the starting node and the terrain height corresponding to the starting node; When the maximum height of the neighbor node is greater than the terrain height corresponding to the neighbor node, and the maximum height of the starting node is greater than the terrain height corresponding to the starting node, write the neighbor node into the preset queue.

8. A computer device, characterized in that, It includes a memory and a processor, and the memory stores a computer program, and when the computer program runs on the processor, it executes the data processing method of the game scene according to any one of claims 1-6.

9. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, and when the computer program runs on the processor, it executes the data processing method of the game scene according to any one of claims 1-6.

Citation Information

Patent Citations

  • Three-dimensional data search method and device based on octree

    CN103440350A

  • Game role path finding method and device and computer equipment

    CN112657190A