Game scene management method and device, electronic equipment and storage medium

By dividing the game scene into multiple areas and building a scene tree with the smallest size, the problem of low object query efficiency in three-dimensional games is solved, the game operation and management efficiency is improved, and memory consumption and CPU overhead are reduced.

CN119034204APending Publication Date: 2024-11-29BEIJING PIXEL SOFTWARE TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411134216.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-19
Publication Date
2024-11-29

AI Technical Summary

Technical Problem

The efficiency of object query in existing three-dimensional games is low, resulting in low game operation efficiency and scene management efficiency. In addition, existing technologies such as octave or quad-tree occupying a large amount of memory space, affecting game performance.

Method used

Divide the game scene into multiple areas, update the scene management information according to the area index of the objects to be managed, build a scene tree of the smallest size, and record only the objects and node information that already exist in the game scene, reducing memory consumption and query time.

Benefits of technology

Improve object query efficiency, game operation efficiency and scene management efficiency, reduce CPU overhead, and save memory space.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119034204A_ABST
    Figure CN119034204A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a game scene management method and device, electronic equipment and a storage medium, and relates to the technical field of computer application. According to the method, a game scene is divided into a plurality of areas, object information, node information and layer information corresponding to the game scene are updated according to the areas where to-be-managed objects are located in the game scene, and a scene tree is constructed according to the object information, the node information and the layer information. Only the objects existing in the game scene are recorded in the object information, only the nodes generated according to the objects existing in the game scene are recorded in the node information, and only the hierarchy where the nodes existing in the node information are located is recorded in the layer information, so that the game scene can be maintained and managed by utilizing the scene tree with the minimum size; therefore, the memory space consumption and the object query time are reduced, the object query efficiency, the game operation efficiency and the game scene management efficiency are improved, and the CPU overhead is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer application technology, and in particular to a game scene management method, device, electronic device and storage medium. Background Art

[0002] In 3D games, it is often necessary to query all objects within a certain range near a target point. For example, when releasing a skill, it is necessary to find out how many objects (such as characters) are attacked according to the skill's attack range. Usually, the query is performed by traversing all objects, which is very time-consuming and greatly affects the running efficiency of the game. Alternatively, the game scene is divided into a complete octree or quadtree in advance, which will take up more memory space and affect the efficiency of game scene management. Summary of the invention

[0003] In view of this, an object of the present invention is to provide a game scene management method, device, electronic device and storage medium, which can effectively improve the object query efficiency, game operation efficiency and game scene management efficiency.

[0004] In order to achieve the above purpose, the technical solution adopted by the embodiment of the present invention is as follows:

[0005] In a first aspect, the present invention provides a game scene management method, the method comprising:

[0006] Determine the region index of the object to be managed in the game scene; the game scene is divided into a plurality of regions, and the regions correspond to the region indexes one by one;

[0007] The scene management information corresponding to the game scene is updated according to the area index and the object to be managed; the scene management information is used to record object information, node information and layer information, the object information includes objects existing in the game scene, the node information includes nodes generated according to objects existing in the game scene, and the layer information includes the layer at which the node in the node information is located;

[0008] A scene tree is constructed according to the object information, the node information and the layer information; each layer of the scene tree corresponds one-to-one to each level in the layer information, the nodes in each layer of the scene tree are nodes of the corresponding level in the node information, the leaf nodes of the scene tree store the existing objects, and the leaf nodes correspond one-to-one to the area indexes.

[0009] In an optional implementation manner, updating the scene management information corresponding to the game scene according to the area index and the object to be managed includes:

[0010] When the object to be managed is an object to be added and the target leaf node corresponding to the area index does not exist in the node information, create a target leaf node including an object list, add the object to be added to the object list of the target leaf node, and update the layer information and the node information according to the target leaf node; the object information includes the object list;

[0011] When the object to be managed is an object to be added and there is a target leaf node corresponding to the area index in the node information, the object to be added is added to the object list of the target leaf node.

[0012] In an optional implementation manner, updating the layer information and the node information according to the target leaf node includes:

[0013] When the layer level where the target leaf node is located does not exist in the layer information, creating a leaf node list; the node information includes the leaf node list;

[0014] Adding the target leaf node to the leaf node list;

[0015] The level at which the target leaf node is located is added to the level information.

[0016] In an optional implementation manner, updating the layer information and the node information according to the target leaf node includes:

[0017] When there is a leaf node list in the node information and the target leaf node is not recorded in the leaf node list, adding the target leaf node to the leaf node list;

[0018] When the parent node of the target leaf node exists, adding the target leaf node to the child node list of the parent node;

[0019] When there are multiple leaf nodes in the leaf node list, create a parent node including a child node list for the leaf nodes that do not have a parent node among the multiple leaf nodes, and add the leaf nodes that do not have a parent node to the child node list of the corresponding parent node;

[0020] When the level at which the parent node is located does not exist in the layer information, create an intermediate node list corresponding to the level at which the parent node is located, add the parent node to the intermediate node list, and add the level at which the parent node is located to the layer information;

[0021] When there are at least two parent nodes in the same level, the layer information and the node information are updated upward layer by layer until a root node is generated; the node information includes the leaf node list, the intermediate node list, the child node list and the root node.

[0022] In an optional implementation, the object information includes an object list, and the node information includes a leaf node list, an intermediate node list, and a child node list; and updating the scene management information corresponding to the game scene according to the area index and the object to be managed includes:

[0023] When the object to be managed is an object to be deleted, obtaining a target leaf node according to the area index;

[0024] Removing the object to be deleted from the object list of the target leaf node;

[0025] If the object list is empty after removing the object to be deleted, removing the target leaf node from the leaf node list;

[0026] If the leaf node list is empty after removing the target leaf node, the level where the target leaf node is located is removed from the level information;

[0027] If the target leaf node has a parent node, remove the target leaf node from the child node list of the parent node;

[0028] If the child node list of the parent node is empty after removing the target leaf node, the parent node is removed from the intermediate node list corresponding to the previous level, and the layer information and the intermediate node list are updated upward layer by layer.

[0029] In an optional implementation, the object information includes an object list; and the method further includes:

[0030] When the object to be managed is moved, the object to be managed is removed from the object list of the node corresponding to the area where the object to be managed was located before it was moved;

[0031] The object to be managed is added to the object list of the node corresponding to the area where the object to be managed is moved.

[0032] In an optional embodiment, the method further comprises:

[0033] receiving an object query instruction; the object query instruction includes a query coordinate and a query distance;

[0034] Taking the root node of the scene tree as a candidate node, calculating the distance value between the bounding box of the candidate node and the query coordinates;

[0035] Re-select the child nodes of the candidate node whose distance value is less than the query distance as the candidate node;

[0036] Return objects in the object list of leaf nodes whose distance values ​​are less than the query distance.

[0037] In a second aspect, the present invention provides a game scene management device, the device comprising:

[0038] A processing module, used to determine the region index of the object to be managed in the game scene; the game scene is divided into a plurality of regions, and the regions correspond to the region indexes one by one;

[0039] An updating module, used for updating the scene management information corresponding to the game scene according to the area index and the object to be managed; the scene management information is used for recording object information, node information and layer information, the object information includes objects existing in the game scene, the node information includes nodes generated according to objects existing in the game scene, and the layer information includes the layer at which the nodes in the node information are located;

[0040] A construction module is used to construct a scene tree according to the object information, the node information and the layer information; each layer of the scene tree corresponds one-to-one to each level in the layer information, the nodes in each layer of the scene tree are nodes of the corresponding level in the node information, the leaf nodes of the scene tree store the existing objects, and the leaf nodes correspond one-to-one to the area indexes.

[0041] In a third aspect, the present invention provides an electronic device, comprising a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor can execute the machine executable instructions to implement the game scene management method described in any of the aforementioned implementations.

[0042] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements a game scene management method as described in any one of the aforementioned embodiments.

[0043] Compared with the prior art, the game scene management method, device, electronic device and storage medium provided by the embodiments of the present invention divide the game scene into multiple areas, update the object information, node information and layer information corresponding to the game scene according to the area where the object to be managed is located in the game scene, and build a scene tree according to the object information, node information and layer information. Since the object information only records the objects that already exist in the game scene, the node information only records the nodes generated according to the objects that already exist in the game scene, and the layer information only records the level of the nodes that already exist in the node information, the game scene can be maintained and managed using a scene tree of the smallest size, thereby reducing the consumption of memory space and the object query time, thereby improving the object query efficiency, the game operation efficiency and the game scene management efficiency, and reducing CPU overhead.

[0044] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.

[0046] Figure 1 A schematic flow chart of a game scene management method provided by an embodiment of the present invention is shown.

[0047] Figure 2 Shows Figure 1 A flow chart of the sub-steps of step S20.

[0048] Figure 3 A schematic diagram of scene tree splitting provided by an embodiment of the present invention is shown.

[0049] Figure 4 Another schematic diagram of scene tree splitting provided by an embodiment of the present invention is shown.

[0050] Figure 5 Another flowchart of the game scene management method provided by the embodiment of the present invention is shown.

[0051] Figure 6 Another flowchart of the game scene management method provided by the embodiment of the present invention is shown.

[0052] Figure 7 A block diagram of a game scene management device provided by an embodiment of the present invention is shown.

[0053] Figure 8 A block diagram of an electronic device provided by an embodiment of the present invention is shown.

[0054] Icon: 100 - electronic device; 110 - memory; 120 - processor; 130 - communication module; 200 - game scene management device; 201 - processing module; 202 - update module; 203 - construction module. DETAILED DESCRIPTION

[0055] The following will be combined with the accompanying drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. 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.

[0056] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, 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 making creative work are within the scope of protection of the present invention.

[0057] It should be noted that relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0058] With the rapid development of digital technology, scene management is becoming more and more important in games. Existing technologies usually use full octrees or full quadtrees to manage game scenes, which will take up more memory space and cause high CPU overhead when searching for objects, greatly affecting the efficiency of game operation and game scene management. Alternatively, a global list is used to manage all objects in the game scene, and the objects to be managed need to be traversed, which will result in a long query time and low query efficiency, seriously affecting the running efficiency of the game.

[0059] In order to solve the above problems, the core improvement of the present invention is to divide the game scene into multiple areas, update the object information, node information and layer information corresponding to the game scene according to the area where the object to be managed is located in the game scene, and build a scene tree based on the object information, node information and layer information. Since the object information only records the objects that already exist in the game scene, the node information only records the nodes generated according to the objects that already exist in the game scene, and the layer information only records the level of the nodes that already exist in the node information, the game scene can be maintained and managed using a scene tree of the smallest size, thereby reducing the consumption of memory space and the object query time, thereby improving the object query efficiency, the game operation efficiency and the management efficiency of the game scene, and reducing CPU overhead.

[0060] The embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0061] Please refer to Figure 1 , Figure 1 A flowchart of a game scene management method provided by an embodiment of the present invention is shown. The method comprises the following steps:

[0062] Step S10, determining the region index of the object to be managed in the game scene; the game scene is divided into multiple regions, and the regions correspond to the region indexes one by one.

[0063] In the embodiment of the present invention, when the game is initialized, the three-dimensional coordinate system and the area size are set according to the three-dimensional game scene, and the starting coordinates of the three-dimensional game scene are determined. Generally, the minimum coordinates in the three-dimensional coordinate system are determined as the starting coordinates. For example, the starting coordinates are set to worldOrigin(-32768.f,-32768.f,-32768.f), and the area size is set to a 64*64*64 cube.

[0064] The game scene is divided into multiple areas according to the size of the game scene and the area size. Each area can be considered as a cube, and the area index is used to uniquely identify the area. The area index of the object to be managed in the game scene is determined according to the coordinates of the object to be managed, the starting coordinates of the game scene and the area size.

[0065] As a possible implementation, assuming that the coordinates of the object to be managed are (x1, y1, z1), the starting coordinates are (x2, y2, z2), and the side length of the region is cellSize, the calculation formula of the three-dimensional region index index is as follows:

[0066]

[0067]

[0068] Step S20, update the scene management information corresponding to the game scene according to the area index and the objects to be managed; the scene management information is used to record object information, node information and layer information, the object information includes the objects already existing in the game scene, the node information includes the nodes generated according to the objects already existing in the game scene, and the layer information includes the level of the nodes in the node information.

[0069] Step S30, construct a scene tree according to the object information, node information and layer information; each layer of the scene tree corresponds one-to-one to each level in the layer information, and the nodes in each layer of the scene tree are the nodes of the corresponding level in the node information. The leaf nodes of the scene tree store existing objects, and the leaf nodes correspond one-to-one to the region index.

[0070] In an embodiment of the present invention, object information is used to record objects that have been added to the game scene, node information is used to record nodes generated based on objects that have been added to the game scene, and layer information is used to record the level of existing nodes.

[0071] As a possible implementation, assume that three levels are recorded in the layer information. The nodes belonging to the three levels are recorded in the node information respectively, and the objects existing in each area are recorded in the object information respectively. A three-layer scene tree is generated according to the three levels in the layer information, and the root node, intermediate node and leaf node of the scene tree are constructed according to each layer of nodes in the node information. The objects existing in each area recorded in the object information are saved in the corresponding leaf nodes in the scene tree. Among them, the areas in the game scene correspond to the leaf nodes one by one, and the objects existing in each area are recorded in the leaf nodes of the scene tree.

[0072] It should be noted that quadtrees and octrees are usually a partitioning strategy for space management in three-dimensional scenes. Taking the octree as an example, each parent node contains eight child nodes, and the three-dimensional space of the game scene is divided into different areas through layer-by-layer decomposition. The scene tree of this solution can be a tree structure such as a sparse quadtree or a sparse octree. Nodes are dynamically created according to the existing objects in the game scene, and empty nodes will not be created in advance, which can effectively save memory space.

[0073] In summary, the game scene management method provided by the embodiment of the present invention divides the game scene into multiple areas, updates the object information, node information and layer information corresponding to the game scene according to the area where the object to be managed is located in the game scene, and constructs a scene tree according to the object information, node information and layer information. Since the object information only records the objects that already exist in the game scene, the node information only records the nodes generated according to the objects that already exist in the game scene, and the layer information only records the level of the nodes that already exist in the node information, the game scene can be maintained and managed using a scene tree of the smallest size, thereby reducing the consumption of memory space and the object query time, thereby improving the object query efficiency, the game operation efficiency and the game scene management efficiency, and reducing CPU overhead.

[0074] Optionally, in actual applications, when adding objects to a game scene, the objects to be added are objects to be managed. Figure 2 , Figure 1 The sub-steps of step S20 may include:

[0075] Step S201, when the object to be managed is an object to be added and there is no target leaf node corresponding to the area index in the node information, create a target leaf node including an object list, add the object to be added to the object list of the target leaf node, and update the layer information and node information according to the target leaf node; the object information includes the object list.

[0076] In the embodiment of the present invention, when adding an object to the game scene, the node information is queried according to the region index of the object to be added. If the target leaf node corresponding to the region index does not exist in the node information, it means that the object to be added is the first object in the game scene that falls in the region corresponding to the region index, and a target leaf node corresponding to the region index needs to be newly created. The target leaf node includes an object list, and the object to be added is added to the object list of the target leaf node. The leaf node corresponds to the object list one by one.

[0077] Step S202: When the object to be managed is an object to be added and there is a target leaf node corresponding to the region index in the node information, the object to be added is added to the object list of the target leaf node.

[0078] In an embodiment of the present invention, if a target leaf node corresponding to the area index already exists in the node information, it means that the object to be added is not the first object in the game scene that falls in the area corresponding to the area index. There is no need to create a target leaf node, and the object to be added can be added to the object list of the target leaf node.

[0079] It can be seen that the embodiment of the present invention dynamically creates leaf nodes according to objects added to the game scene, and dynamically updates layer information and node information according to the newly created leaf nodes, thereby effectively reducing the occupancy of memory space and further improving object query efficiency and game operation efficiency.

[0080] Optionally, in actual applications, when adding an object to a game scene for the first time, Figure 2 The sub-step of updating the layer information and the node information according to the target leaf node in step S201 may include:

[0081] When the layer where the target leaf node is located does not exist in the layer information, a leaf node list is created; the node information includes the leaf node list; the target leaf node is added to the leaf node list; and the layer where the target leaf node is located is added to the layer information.

[0082] In an embodiment of the present invention, a leaf node list is used to record the created leaf nodes in the game scene. Once a leaf node is created, it means that at least one object has been added to the area corresponding to the leaf node. When the layer information does not contain the layer where the target leaf node is located, it means that the game scene is blank, there is no object in the game scene, and a leaf node list needs to be created. The target leaf node where the object to be added is located is added to the leaf list, and the layer where the target leaf node is located is added to the layer information.

[0083] Among them, the level corresponds to the level index one by one. The level index is used to uniquely identify the level. For example, the level index starts from 0 and increases. If the level index of the level where the leaf node is located is set to 0, then the level index of the level where the parent node of the leaf node is located is set to 1, and so on. Only the leaf node stores objects, and the parent node and child node of the node are recorded in the nodes of other levels.

[0084] It can be seen that in the embodiment of the present invention, when adding the first object to the game scene, only one leaf node needs to be created, and the leaf node is regarded as the root node of the scene tree, so that a leaf node is used as needed to manage objects in the game scene, effectively reducing memory consumption.

[0085] Optionally, in actual applications, when adding objects to the game scene multiple times, Figure 2 The sub-step of updating the layer information and the node information according to the target leaf node in step S201 may include:

[0086] When there is a leaf node list in the node information and the target leaf node is not recorded in the leaf node list, the target leaf node is added to the leaf node list; when the parent node of the target leaf node exists, the target leaf node is added to the child node list of the parent node.

[0087] When there are multiple leaf nodes in the leaf node list, a parent node including a child node list is created for the leaf nodes without a parent node among the multiple leaf nodes, and the leaf nodes without a parent node are added to the child node list of the corresponding parent node.

[0088] When the layer where the parent node is located does not exist in the layer information, create an intermediate node list corresponding to the layer where the parent node is located, add the parent node to the intermediate node list, and add the layer where the parent node is located to the layer information; when there are at least two parent nodes in the same layer, update the layer information and node information layer by layer until the root node is generated; the node information includes a leaf node list, an intermediate node list, a child node list and a root node.

[0089] As a possible implementation, when the target leaf node of the object to be added is already recorded in the target leaf node list, the object to be added is added to the object list of the target leaf node. That is, other objects already exist in the area where the object to be added is located, and the target leaf node is created when the first object is added to the area, and the target leaf node is added to the leaf node list.

[0090] As another possible implementation, when there is a leaf node list in the node information and the target leaf node is not recorded in the leaf node list, it means that objects have been added to the area corresponding to other leaf nodes in the game scene, but the object to be added is the first object added to the area corresponding to the target leaf node, and it is necessary to newly create a target leaf node including the object list and add the target leaf node to the leaf node list. When the parent node of the target leaf node exists, the target leaf node is added to the child node list of the parent node.

[0091] In order to more clearly explain the updating process of the layer information and the node information in the embodiment of the present invention, an exemplary description is given with reference to the accompanying drawings.

[0092] As an implementation method, it is assumed that before object A (object to be added) is added, leaf node node00 already exists in the leaf node list. After the target leaf node node01 corresponding to object A to be added is added to the leaf node list, there are two leaf nodes in the leaf node list. The parent node of each leaf node is determined according to the area index corresponding to the leaf node and the number of child nodes in the parent node. Assuming that the two leaf nodes belong to the same parent node, a parent node node10 is created. The parent node node10 includes a child node list, and the two leaf nodes are added to the child node list of the parent node.

[0093] Since the parent node is the first parent node created in level 1, it is necessary to create an intermediate node list corresponding to level 1, add the parent node node10 to the intermediate node list corresponding to level 1, and add level 1 to the layer information. After adding object A to the game scene, the scene tree is constructed according to the layer information, node information, and object information. The scene tree corresponding to the game scene changes from one layer to two layers, such as Figure 3 shown.

[0094] As another implementation, assuming that the two leaf nodes node00 and node01 do not belong to the same parent node, then create the parent node node10 of the leaf node node00 and the parent node node11 of the leaf node node01 respectively, and the parent nodes node10 and node11 respectively include corresponding child node lists, node00 is added to the child node list corresponding to the parent node node10, and node01 is added to the child node list corresponding to the parent node node11.

[0095] Since two new parent nodes are created in level 1, it is necessary to create a list of intermediate nodes corresponding to level 1, and add node10 and node11 to the list of intermediate nodes corresponding to level 1. Since there are two node10 and node11 without parent nodes in level 1, it is necessary to create parent nodes of node10 and node11 in the previous level, that is, to create new parent nodes of node10 and node11 in level 2.

[0096] If node10 and node11 belong to the same parent node, then create node10 and node11's parent node node20 at level 2. Parent node node20 includes a child node list. Add node10 and node11 to the child node list corresponding to node20, and add parent node node20 to the newly created intermediate node list corresponding to level 2. Add level 2 to the layer information. After adding object A to the game scene, build a scene tree based on the layer information and node information. The scene tree corresponding to the game scene changes from one layer to three layers, such as Figure 4 shown.

[0097] It is worth mentioning that if node10 and node11 do not belong to the same parent node, the parent node of the previous level is created layer by layer referring to the process of creating node10 and node11 in level 1 until there is only one node in the level, and the node in the top level is the root node.

[0098] Among them, the node indexes of nodes at each level (including leaf nodes, intermediate nodes and root nodes) are independently addressed, and the nodes in each level correspond to the node index of the level one by one. The node index of the leaf node is the regional index.

[0099] Assume that the scene tree is an octree, each parent node contains eight child nodes, the node index of the parent node is determined according to the node index of any child node, and the level of the parent node is determined according to the level of the child node. The calculation formulas for the node index of the parent node and the level of the parent node are as follows:

[0100] fatherIndex.x=childIndex.x / 2

[0101] fatherIndex.y=childIndex.y / 2

[0102] fatherIndex.z=childIndex.z / 2

[0103] fatherDepth=childDepth+1

[0104] Among them, fatherIndex is the node index of the parent node; childIndex is the node index of the child node; fatherDepth is the level of the parent node; childDepth is the level of the child node.

[0105] It should be noted that the node index represents the position of the node in the three-dimensional game scene. As the levels increase layer by layer, the node size of the nodes in each layer increases layer by layer. Assuming that the node size of the leaf node is 64, the node size of the parent node of the leaf node can be 128, and so on.

[0106] Optionally, in actual applications, object information includes an object list, and node information includes a leaf node list, an intermediate node list, and a child node list; when deleting an existing object in a game scene, the object to be deleted is the object to be managed. Figure 2 , Figure 1 The sub-steps of step S20 may include:

[0107] Step S203: when the object to be managed is an object to be deleted, a target leaf node is obtained according to the region index.

[0108] In the embodiment of the present invention, the leaf nodes and the object lists correspond one to one. The object lists may exist independently of the leaf nodes, or the object lists may be set inside the leaf nodes, which is not limited by the present invention.

[0109] The object list is used to record the objects that exist in the same area, that is, the objects that exist in the same leaf node are saved in the object list corresponding to the leaf node. The leaf node list is used to record the leaf nodes that exist in the game scene.

[0110] The node information also includes the root node. The levels include the leaf level, the middle level and the root level. The leaf level is the level where the leaf node is located, the middle level is the level where the middle node is located, and the root level is the level where the root node is located. Each middle level recorded in the level information creates a corresponding middle node list, which is used to record the middle nodes that already exist in the same middle level; the root node and each existing middle node create a corresponding child node list, which is used to record the child nodes that already exist in the root node or the same middle node.

[0111] Step S204: remove the object to be deleted from the object list of the target leaf node.

[0112] Step S205: If the object list is empty after removing the object to be deleted, the target leaf node is removed from the leaf node list.

[0113] In the embodiment of the present invention, objects correspond to object identifiers one by one, and the object list of the target leaf node is searched according to the object identifier of the object to be deleted, and the object to be deleted is removed from the object list of the target leaf node. If there are other objects in the target leaf node, the deletion operation is completed. If there are no other objects in the target leaf node, the target leaf node is deleted from the leaf list.

[0114] Step S206: If the leaf node list is empty after removing the target leaf node, the level where the target leaf node is located is removed from the level information.

[0115] Step S207: If the target leaf node has a parent node, remove the target leaf node from the child node list of the parent node.

[0116] In the embodiment of the present invention, after the target leaf node is deleted, the target leaf node needs to be deleted from the leaf node list. If there are other leaf nodes in the leaf node list, step S207 is executed. If there are no other leaf nodes in the leaf node list, it means that there are no objects in the game scene, and the level where the target node is located can be removed from the layer information. If the target leaf node has a parent node recorded in it, the target leaf node is removed from the child node list of the parent node.

[0117] Step S208: If the child node list of the parent node is empty after removing the target leaf node, the parent node is removed from the intermediate node list corresponding to the previous level, and the layer information and the intermediate node list are updated upward layer by layer.

[0118] In an embodiment of the present invention, if the child node list of the parent node is empty after the target leaf node is removed, it means that the parent node has no child nodes, and the parent node without child nodes is removed from the intermediate node list corresponding to the previous level. The parent node without child nodes is recursively deleted layer by layer upward, and the layer information and intermediate node list are updated. If there is only one leaf node in the leaf node list, the parent node is recursively deleted layer by layer upward, and the layer information and intermediate node list are updated, and the leaf node is used as the root node.

[0119] As a possible implementation, Figure 4 For example, assuming that the object to be deleted is the only object G in the leaf node node00 in the three-level management tree, then after deleting object G, there are no other objects in the leaf node node00, so the leaf node node00 is removed from the leaf node list and the child node list of the parent node node10. Since the parent node node10 has only one child node, the parent node is removed from the intermediate node list of level 1 and the child node list of the root node node20. At this point, the scene tree includes the root node node20, the intermediate node node11, and the leaf node node01.

[0120] In order to further reduce memory space usage and improve object query efficiency, when there is only one leaf node, recursively delete the intermediate node and the root node to merge and obtain the scene tree with the smallest memory space. Since the leaf node node01 is the only leaf node and has a parent node node10, the intermediate node node11 and the root node node20 are recursively deleted, and the level corresponding to the intermediate node node11 and the root node node20 is deleted from the layer information, and finally only the leaf node node01 is retained.

[0121] It is worth mentioning that when no level is recorded in the layer information, the root node of the scene tree is empty.

[0122] It can be seen that the embodiment of the present invention dynamically updates the scene management information corresponding to the game scene based on the object to be deleted, and merges the scene tree according to the scene management information, thereby maintaining the scene tree that occupies the smallest memory space, effectively improving the object query efficiency and game operation efficiency.

[0123] Optionally, in actual applications, when an object (such as a character) in the game moves, it is necessary to update the object information, node information, and layer information based on the displacement information. Object information includes an object list; please refer to Figure 5 , the game scene management method also includes the following steps:

[0124] Step S40: When the object to be managed is moved, the object to be managed is removed from the object list of the node corresponding to the area where the object to be managed is located before it is moved.

[0125] Step S50: adding the object to be managed to the object list of the node corresponding to the area where the object to be managed is located after it moves.

[0126] In an embodiment of the present invention, the region where the object to be managed is located before the movement is determined according to the coordinates of the object to be managed before the movement, and the object to be managed is deleted from the object list corresponding to the region where the object to be managed is located before the movement. Deleting the object to be managed may cause a hierarchical change in the scene management information. Please refer to the step of deleting the object to update the scene management information. The region where the object to be managed is located after the movement is determined according to the coordinates of the object to be managed after the movement, and the object to be managed is added to the object list of the node corresponding to the region where the object to be managed is located after the movement. If a new leaf node corresponding to the object to be managed needs to be created, it may cause a hierarchical change in the scene management information. Please refer to the step of adding the object to update the scene management information. Finally, the scene tree is constructed according to the updated scene management information.

[0127] Optionally, in actual applications, you can use the scene tree to quickly query objects. Object information includes object lists; please refer to Figure 6 , the game scene management method also includes the following steps:

[0128] Step S60, receiving an object query instruction; the object query instruction includes query coordinates and query distance.

[0129] In the embodiment of the present invention, assuming that a game character (object) releases a skill, it is necessary to query which objects are attacked according to the attack range of the skill. When querying objects within a specified range, objects that meet the query conditions are obtained according to the query coordinates and query distance in the query object instruction. The query coordinates represent the query starting point in the game scene, and the query distance represents the effective distance from the query coordinates.

[0130] Step S70: taking the root node of the scene tree as a candidate node, and calculating the distance value between the bounding box of the candidate node and the query coordinates.

[0131] In the embodiment of the present invention, when a node is created, the minimum coordinate and the maximum coordinate are determined according to the node index, the node size and the starting coordinate, and the bounding box is determined according to the minimum coordinate and the maximum coordinate. The bounding box corresponds to the node one by one, and the bounding box calculation method is as follows:

[0132] min=(x1*size+x2,y1*size+y2,z1*size+z2)

[0133] max=((x1+1)*size+x2,(y1+1)*size+y2,(z1+1)*size+z2)

[0134] box(min,max)

[0135] Among them, (x1, y1, z1) is the node index; (x2, y2, z2) is the starting coordinate of the game scene; size is the node size, box is the bounding box corresponding to the node; min is the minimum coordinate of the bounding box; max is the maximum coordinate of the bounding box.

[0136] Step S80: Re-select the child nodes of the candidate nodes whose distance values ​​are smaller than the query distance as candidate nodes.

[0137] Start traversing from the root node of the scene tree, obtain the minimum and maximum coordinates of the bounding box of the root node, and if the query coordinate is between the minimum and maximum coordinates, determine all child nodes of the root node as candidate nodes. If the query coordinate is not between the minimum and maximum coordinates, determine the minimum or maximum coordinate close to the query coordinate as the target coordinate, and calculate the distance value based on the query coordinate and the target coordinate.

[0138] If the distance between the bounding box of the root node and the query coordinates is not less than the query distance, there is no object in the scene tree that meets the query conditions, the query fails, and the query operation is terminated directly, thereby improving query efficiency.

[0139] If the distance between the bounding box of the root node and the query coordinates is less than the query distance, all child nodes of the root node are determined as candidate nodes, and the distance between each candidate node and the query coordinates is calculated. If there are two candidate nodes whose distance values ​​are less than the query distance, the child nodes of these two candidate nodes are determined as candidate nodes, and the query is filtered in the direction of the leaf nodes.

[0140] Step S90, returning objects in the object list of leaf nodes whose distance values ​​are less than the query distance.

[0141] In the embodiment of the present invention, leaf nodes whose distance values ​​are less than the query distance are obtained through layer-by-layer filtering and screening, and objects in the object list of leaf nodes whose distance values ​​are less than the query distance are saved to the query list, and the query list is returned after the query is completed. If the distance values ​​of the leaf nodes are not less than the query distance, the query fails.

[0142] It can be seen that the embodiment of the present invention filters and screens layer by layer according to the coverage of the node bounding box, terminates the query operation of invalid nodes in time, and continues to filter and screen only the nodes within the query range, effectively reducing the data of the nodes to be queried, thereby greatly improving the object query efficiency and the game operation efficiency.

[0143] Based on the same inventive concept, the basic principles and technical effects of the game scene management device provided in the embodiment of the present invention are the same as those in the above embodiment. For the sake of brief description, for parts not mentioned in this embodiment, reference may be made to the corresponding contents in the above embodiment.

[0144] Please refer to Figure 7 , Figure 7 A block diagram of a game scene management device 200 provided in an embodiment of the present invention is shown. The game scene management device 200 includes a processing module 201, an updating module 202 and a building module 203.

[0145] The processing module 201 is used to determine the region index of the object to be managed in the game scene; the game scene is divided into multiple regions, and the regions correspond to the region indexes one by one;

[0146] An updating module 202 is used to update the scene management information corresponding to the game scene according to the region index and the object to be managed; the scene management information is used to record object information, node information and layer information, the object information includes objects existing in the game scene, the node information includes nodes generated according to objects existing in the game scene, and the layer information includes the layer at which the node in the node information is located;

[0147] Construction module 203 is used to construct a scene tree based on object information, node information and layer information; each layer of the scene tree corresponds one-to-one to each level in the layer information, and the nodes in each layer of the scene tree are nodes of the corresponding level in the node information. The leaf nodes of the scene tree store existing objects, and the leaf nodes correspond one-to-one to the region index.

[0148] In summary, the game scene management device provided by the embodiment of the present invention divides the game scene into multiple areas, updates the object information, node information and layer information corresponding to the game scene according to the area where the object to be managed is located in the game scene, and constructs a scene tree according to the object information, node information and layer information. Since the object information only records the objects that already exist in the game scene, the node information only records the nodes generated according to the objects that already exist in the game scene, and the layer information only records the level of the nodes that already exist in the node information, the game scene can be maintained and managed using a scene tree of the smallest size, thereby reducing the consumption of memory space and the object query time, thereby improving the object query efficiency, the game operation efficiency and the game scene management efficiency, and reducing CPU overhead.

[0149] Optionally, the update module 202 is specifically used to create a target leaf node including an object list when the object to be managed is an object to be added and the target leaf node corresponding to the regional index does not exist in the node information, add the object to be added to the object list of the target leaf node, and update the layer information and node information according to the target leaf node; the object information includes the object list; when the object to be managed is an object to be added and there is a target leaf node corresponding to the regional index in the node information, add the object to be added to the object list of the target leaf node.

[0150] Optionally, the update module 202 is specifically used to create a leaf node list when the layer where the target leaf node is located does not exist in the layer information; the node information includes the leaf node list; add the target leaf node to the leaf node list; and add the layer where the target leaf node is located to the layer information.

[0151] Optionally, the update module 202 is specifically used to add the target leaf node to the leaf node list when there is a leaf node list in the node information and the target leaf node is not recorded in the leaf node list; when the parent node of the target leaf node exists, add the target leaf node to the child node list of the parent node; when there are multiple leaf nodes in the leaf node list, create a parent node including a child node list for the leaf nodes that do not have a parent node among the multiple leaf nodes, and add the leaf nodes that do not have a parent node to the child node list of the corresponding parent node; when the layer where the parent node is located does not exist in the layer information, create an intermediate node list corresponding to the layer where the parent node is located, add the parent node to the intermediate node list, and add the layer where the parent node is located to the layer information; when there are at least two parent nodes in the same layer, update the layer information and node information upward layer by layer until the root node is generated; the node information includes a leaf node list, an intermediate node list, a child node list and a root node.

[0152] Optionally, the object information includes an object list, and the node information includes a leaf node list, an intermediate node list, a child node list and a root node; the update module 202 is specifically used to obtain the target leaf node according to the area index when the object to be managed is an object to be deleted; remove the object to be deleted from the object list of the target leaf node; if the object list is empty after removing the object to be deleted, remove the target leaf node from the leaf node list; if the leaf node list is empty after removing the target leaf node, remove the level where the target leaf node is located from the layer information; if the target leaf node has a parent node, remove the target leaf node from the child node list of the parent node; if the child node list of the parent node is empty after removing the target leaf node, remove the parent node from the intermediate node list corresponding to the previous level, and update the layer information and the intermediate node list upward layer by layer.

[0153] Optionally, the object information includes an object list; the update module 202 is specifically used to remove the object to be managed from the object list of the node corresponding to the area where the object to be managed is located before it is moved; and add the object to be managed to the object list of the node corresponding to the area where the object to be managed is located after it is moved.

[0154] Optionally, the processing module 201 is also used to receive a query object instruction; the query object instruction includes query coordinates and query distance; the root node of the scene tree is used as a candidate node, and the distance value between the bounding box of the candidate node and the query coordinates is calculated; the child nodes of the candidate node whose distance value is less than the query distance are re-used as candidate nodes; and the objects in the object list of the leaf nodes whose distance value is less than the query distance are returned.

[0155] Please refer to Figure 8 , is a block diagram of an electronic device 100 provided in an embodiment of the present invention. The electronic device 100 may be a server, a personal computer (PC), a laptop computer, a tablet computer, or the like, which has data processing capabilities, and is not limited thereto. The electronic device 100 includes a memory 110, a processor 120, and a communication module 130. The memory 110, the processor 120, and the communication module 130 are electrically connected to each other directly or indirectly to achieve data transmission or interaction. For example, these components may be electrically connected to each other via one or more communication buses or signal lines.

[0156] The memory 110 is used to store programs or data. The memory 110 may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), etc.

[0157] The processor 120 is used to read / write data or programs stored in the memory 110 and execute corresponding functions. For example, when the computer program stored in the memory 110 is executed by the processor 120, the game scene management method disclosed in the above embodiments can be implemented.

[0158] The communication module 130 is used to establish a communication connection between the electronic device 100 and other communication terminals through a network, and to send and receive data through the network.

[0159] It should be understood that Figure 8 The structure shown is only a schematic diagram of the structure of the electronic device 100. The electronic device 100 may also include Figure 8 More or fewer components as shown, or with Figure 8 Different configurations shown. Figure 8 Each component shown in the figure can be implemented by hardware, software or a combination thereof.

[0160] The embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by the processor 120, the game scene management method disclosed in the above embodiments is implemented.

[0161] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

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

[0163] If the 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 this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the 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, including several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0164] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A game scene management method, characterized in that: The method comprises: Determine the region index of the object to be managed in the game scene; the game scene is divided into a plurality of regions, and the regions correspond to the region indexes one by one; The scene management information corresponding to the game scene is updated according to the area index and the object to be managed; the scene management information is used to record object information, node information and layer information, the object information includes objects existing in the game scene, the node information includes nodes generated according to objects existing in the game scene, and the layer information includes the layer at which the node in the node information is located; A scene tree is constructed according to the object information, the node information and the layer information; each layer of the scene tree corresponds one-to-one to each level in the layer information, the nodes in each layer of the scene tree are nodes of the corresponding level in the node information, the leaf nodes of the scene tree store the existing objects, and the leaf nodes correspond one-to-one to the area indexes.

2. The game scene management method according to claim 1, characterized in that: The updating of the scene management information corresponding to the game scene according to the area index and the object to be managed includes: When the object to be managed is an object to be added and the target leaf node corresponding to the area index does not exist in the node information, create the target leaf node including an object list, add the object to be added to the object list of the target leaf node, and update the layer information and the node information according to the target leaf node; the object information includes the object list; When the object to be managed is an object to be added and there is a target leaf node corresponding to the area index in the node information, the object to be added is added to the object list of the target leaf node.

3. The game scene management method according to claim 2, characterized in that: The updating of the layer information and the node information according to the target leaf node includes: When the layer level where the target leaf node is located does not exist in the layer information, creating a leaf node list; the node information includes the leaf node list; Adding the target leaf node to the leaf node list; The level at which the target leaf node is located is added to the level information.

4. The game scene management method according to claim 2, characterized in that: The updating of the layer information and the node information according to the target leaf node includes: When there is a leaf node list in the node information and the target leaf node is not recorded in the leaf node list, adding the target leaf node to the leaf node list; When the parent node of the target leaf node exists, adding the target leaf node to the child node list of the parent node; When there are multiple leaf nodes in the leaf node list, create a parent node including a child node list for the leaf nodes that do not have a parent node among the multiple leaf nodes, and add the leaf nodes that do not have a parent node to the child node list of the corresponding parent node; When the level at which the parent node is located does not exist in the layer information, create an intermediate node list corresponding to the level at which the parent node is located, add the parent node to the intermediate node list, and add the level at which the parent node is located to the layer information; When there are at least two parent nodes in the same level, the layer information and the node information are updated upward layer by layer until a root node is generated; the node information includes the leaf node list, the intermediate node list, the child node list and the root node.

5. The game scene management method according to claim 1, characterized in that: The object information includes an object list, and the node information includes a leaf node list, an intermediate node list, and a child node list; and updating the scene management information corresponding to the game scene according to the area index and the object to be managed includes: When the object to be managed is an object to be deleted, obtaining a target leaf node according to the area index; Removing the object to be deleted from the object list of the target leaf node; If the object list is empty after removing the object to be deleted, removing the target leaf node from the leaf node list; If the leaf node list is empty after removing the target leaf node, the level where the target leaf node is located is removed from the level information; If the target leaf node has a parent node, remove the target leaf node from the child node list of the parent node; If the child node list of the parent node is empty after removing the target leaf node, the parent node is removed from the intermediate node list corresponding to the previous level, and the layer information and the intermediate node list are updated upward layer by layer.

6. The game scene management method according to claim 1, characterized in that: The object information includes an object list; the method further includes: When the object to be managed is moved, the object to be managed is removed from the object list of the node corresponding to the area where the object to be managed was located before it was moved; The object to be managed is added to the object list of the node corresponding to the area where the object to be managed is moved.

7. The game scene management method according to claim 1, characterized in that: The method further comprises: receiving an object query instruction; the object query instruction includes a query coordinate and a query distance; Taking the root node of the scene tree as a candidate node, calculating the distance value between the bounding box of the candidate node and the query coordinates; Re-select the child nodes of the candidate node whose distance value is less than the query distance as the candidate node; Return objects in the object list of leaf nodes whose distance values ​​are less than the query distance.

8. A game scene management device, characterized in that: The device comprises: A processing module, used to determine the region index of the object to be managed in the game scene; the game scene is divided into a plurality of regions, and the regions correspond to the region indexes one by one; An updating module, used for updating the scene management information corresponding to the game scene according to the area index and the object to be managed; the scene management information is used for recording object information, node information and layer information, the object information includes objects existing in the game scene, the node information includes nodes generated according to objects existing in the game scene, and the layer information includes the layer at which the nodes in the node information are located; A construction module is used to construct a scene tree according to the object information, the node information and the layer information; each layer of the scene tree corresponds one-to-one to each level in the layer information, the nodes in each layer of the scene tree are nodes of the corresponding level in the node information, the leaf nodes of the scene tree store the existing objects, and the leaf nodes correspond one-to-one to the area indexes.

9. An electronic device, characterized in that: It comprises a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor can execute the machine executable instructions to implement the game scene management method described in any one of claims 1-7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the game scene management method according to any one of claims 1 to 7 is implemented.