Game resource object loading method and related apparatus
By using a grid-based hierarchical management approach in game scenes, the complexity and performance degradation of resource management in open-world games are solved, achieving efficient resource loading and an optimized user experience.
Patent Information
- Application Number
- CN202411959837.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-11-11
- Estimated Expiration
- 2044-12-30
AI Technical Summary
In open-world games, due to the memory limitations of mobile devices, chunked loading technology leads to high complexity in resource management, loading delays, wasted resource loading time, and performance degradation caused by frequent I/O operations.
The game scene is divided into grid levels, and resource objects are managed hierarchically according to their size and location. The information of resources to be cached is obtained in batches by predicting the route table, and the resource objects of the target resource page index are loaded according to priority.
It effectively reduces the complexity of resource management, reduces the number of I/O operations, improves game performance and user experience, and avoids resource loading pressure.
Smart Images

Figure CN119587986B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and more specifically, to a method and apparatus for loading game resource objects. Background Technology
[0002] With the rapid rise of the "open world" concept in the modern video game industry in recent years, the ability to support a "large world" has become one of the core competitive advantages of a game. In the design of implementing an open world, loading an open world scene requires managing a large number of resources such as models, textures, and animations. Due to the memory limitations of mobile devices, problems such as insufficient memory are prone to occur, and frequent garbage collection will lead to a drop in frame rate.
[0003] Currently, streaming is a common technique in modern game engines for managing large-scale scenes and objects. This technique allows game engines to retain only the resources currently needed by the player in memory, thereby reducing overall memory usage and improving performance. However, streaming requires fine-grained partitioning and management of resources, increasing the complexity of resource management. Since both resource loading and unloading involve I / O operations, the performance overhead of I / O operations is linearly related to the granularity of resource block partitioning, resulting in long resource loading times and low performance. Summary of the Invention
[0004] In view of this, the purpose of the present invention is to provide a method and related apparatus for loading game resource objects, which can improve the running performance of games and user experience.
[0005] To achieve the above objectives, the technical solutions adopted in the embodiments of the present invention are as follows:
[0006] In a first aspect, the present invention provides a method for loading game resource objects, the method comprising:
[0007] During game execution, the predicted route table corresponding to each grid level in the game scene is obtained sequentially; the predicted route table is used to record the resource page index corresponding to the resource objects contained in the player's predicted route; the resource page is used to record the resource information of the resource objects in the same grid unit; the grid level corresponding to each resource object in the game scene is determined according to the size and position of the resource object;
[0008] The index to be cached is determined based on the resource page index in the predicted route table and the player's coordinates, and the resource information corresponding to the index to be cached is cached.
[0009] The index to be cached corresponding to the grid cell whose distance from the player is less than the second threshold is determined as the index to be loaded; the index to be loaded is reselected when the player moves to the preset position;
[0010] The index to be loaded corresponding to the grid cell whose distance to the player is less than the third threshold is determined as the target resource page index, and the resource object corresponding to the target resource page index is loaded according to the priority and resource information of the resource object; the third threshold is less than the second threshold.
[0011] In an optional implementation, the resource page index includes grid level and grid cell coordinates; determining the index to be cached based on the resource page index in the predicted route table and the player's coordinates includes:
[0012] The player's grid coordinates are obtained based on the player's coordinates and the dividing edge length corresponding to the grid level;
[0013] Traverse the predicted route table and determine the resource page indexes where the distance between the player's grid coordinates and the grid cell coordinates is less than a first threshold as cacheable indexes; the first threshold is greater than the second threshold.
[0014] In an optional implementation, the resource page index includes grid cell coordinates; determining the index to be cached corresponding to the grid cell whose distance from the player is less than a second threshold as the index to be loaded includes:
[0015] Based on the grid cell coordinates corresponding to each index to be cached and the player's coordinates, the corresponding first distance is obtained;
[0016] The indexes to be cached that are less than the first distance to the second threshold are identified as the indexes to be loaded, and the indexes to be loaded are stored in the loading queue;
[0017] When the player moves to the preset position in the loading queue, a new loading index is selected, and the loading queue is updated according to the newly selected loading index.
[0018] In an optional implementation, the resource page index includes grid cell coordinates, and the method further includes:
[0019] During game runtime, the index of the loaded resource page corresponding to the loaded object is obtained from the predicted route table;
[0020] The second distance is obtained based on the grid cell coordinates corresponding to each loaded resource page index and the player's coordinates;
[0021] The loaded resource page index with a second distance greater than the fourth threshold is determined as the target unload index, and the resource object corresponding to the target unload index is unloaded; the fourth threshold is greater than the first threshold.
[0022] In an optional implementation, the method further includes:
[0023] During game design, resource objects in the game scene are read sequentially, and the grid level and grid cell coordinates of the resource objects are determined according to the bounding box of the resource objects and the partitioning side lengths corresponding to each grid level.
[0024] Generate a corresponding resource page index based on the grid level and grid cell coordinates of the resource object, and save the resource information of the resource object to the resource page corresponding to the resource page index;
[0025] The player's game route in the game scene is predicted based on all resource pages in each grid level, resulting in a predicted route for each grid level.
[0026] Record the resource page indexes contained in each predicted route into the corresponding predicted route table.
[0027] In an optional implementation, determining the grid level and grid cell coordinates corresponding to the resource object based on the bounding box of the resource object and the partitioning edge length corresponding to each grid level includes:
[0028] The minimum dividing side length that is greater than the hypotenuse length of the bounding box is determined as the initial side length, and the grid level corresponding to the initial side length is determined as the initial grid level;
[0029] The initial grid cell coordinates are determined based on the center coordinates of the bounding box, the size of the game scene, and the initial side length.
[0030] The region corresponding to the initial grid cell coordinates is extended in four directions according to a preset size to obtain the extended region;
[0031] When the vertex coordinates of the bounding box are all inside the extended region, the initial mesh level is used as the mesh level of the resource object, and the initial mesh cell coordinates are used as the mesh cell coordinates of the resource object;
[0032] When the vertex coordinates of the bounding box are not inside the extended region, the grid level corresponding to the smallest partition side length that is longer than the initial side length is determined as the grid level of the resource object, and the grid cell coordinates of the resource object are determined according to the center coordinates of the bounding box, the size of the game scene, and the partition side length corresponding to the grid level of the resource object.
[0033] Secondly, the present invention provides a game resource object loading device, the device comprising:
[0034] The acquisition module is used to sequentially acquire the predicted route table corresponding to each grid level in the game scene during game runtime; the predicted route table is used to record the resource page index corresponding to the resource objects contained in the player's predicted route; the resource page is used to record the resource information of the resource objects in the same grid unit; the grid level corresponding to each resource object in the game scene is determined according to the size and position of the resource object;
[0035] The processing module is used to determine the index to be cached based on the resource page index in the predicted route table and the player's coordinates, and to cache the resource information corresponding to the index to be cached.
[0036] The loading module is used to determine the index to be cached corresponding to the grid cell whose distance from the player is less than a second threshold as the index to be loaded; the index to be loaded is reselected when the player moves to a preset position; the index to be loaded corresponding to the grid cell whose distance from the player is less than a third threshold is determined as the target resource page index, and the resource object corresponding to the target resource page index is loaded according to the priority and resource information of the resource object; the third threshold is less than the second threshold.
[0037] Thirdly, the present invention provides an electronic device including a processor and a memory, wherein the memory stores a computer program executable by the processor, and the processor can execute the computer program to implement the game resource object loading method described in any of the foregoing embodiments.
[0038] Fourthly, 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 the game resource object loading method as described in any of the foregoing embodiments.
[0039] Fifthly, the present invention provides a program product that, when executed by a processor, implements the game resource object loading method as described in any of the foregoing embodiments.
[0040] Compared to existing technologies, the game resource object loading method and related apparatus provided in this invention divide the game scene based on different grid levels and manage resource objects hierarchically according to their size and location within the game scene, effectively reducing the complexity of resource management. During game runtime, resource information to be cached is acquired in batches based on the predicted route corresponding to each grid level, effectively reducing the number of I / O operations and avoiding performance overhead caused by frequent I / O operations.
[0041] When loading game objects, the system first selects grid cells that are relatively close to the player (below the second threshold) from the predicted route table, and uses the corresponding resource page index as the loading index. Next, based on the player's coordinates, it selects resource page indices that are even closer to the player (below the third threshold) from the loading index as the target resource page indices to be loaded. Then, it loads the resource objects corresponding to the target resource page indices according to their priority. This allows for loading resource objects at multiple grid levels, preserving the size characteristics of resource objects while ensuring that resource objects at different grid levels do not interfere with each other during loading. This effectively reduces the pressure on electronic devices for loading resources in the open world, improving game performance and user experience.
[0042] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0043] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used 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 a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0044] Figure 1 This diagram illustrates a flowchart of a game resource object loading method provided in an embodiment of the present invention.
[0045] Figure 2 A schematic diagram of a grid level provided by an embodiment of the present invention is shown.
[0046] Figure 3 This diagram illustrates another flowchart of the game resource object loading method provided in an embodiment of the present invention.
[0047] Figure 4 This diagram illustrates another flowchart of the game resource object loading method provided in an embodiment of the present invention.
[0048] Figure 5 A block diagram of a game resource object loading device provided in an embodiment of the present invention is shown.
[0049] Figure 6 A block diagram of an electronic device provided in an embodiment of the present invention is shown.
[0050] Icons: 100 - Electronic device; 110 - Memory; 120 - Processor; 130 - Communication module; 300 - Game resource object loading device; 301 - Acquisition module; 302 - Processing module; 303 - Loading module. Detailed Implementation
[0051] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.
[0052] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.
[0053] It should be noted that relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0054] Loading a game's world requires managing a large number of resource objects, and mobile devices are prone to lag due to insufficient memory. To ensure smooth gameplay despite hardware limitations, a management strategy is needed to optimize scene resource loading and improve overall game performance.
[0055] In existing technologies, resource objects in large-scale games are typically managed using chunked loading. The core idea of chunked loading is to divide the game world into multiple "chunks" and dynamically load and unload resource objects in these chunks based on the player's location and field of view.
[0056] The inventors discovered that the current industry practice of chunked loading typically divides the scene into two parts at once, resulting in the loss of size characteristics of objects within the scene. From a human observational perspective, the size of an object is often closely related to the range of human observation. While chunked loading can effectively reduce memory consumption, it also presents problems such as high resource management complexity, loading latency, the "pop-up" effect, wasted resource loading time, and performance degradation caused by frequent I / O operations.
[0057] (1) High complexity of resource management: Chunky loading requires developers to be able to finely divide and manage resources, and the result of the division needs to conform to human observation intuition: large objects are visible from a distance, while small objects are only visible up close, which undoubtedly increases the complexity of resource management. At the same time, due to the differences and complexity of scene objects in the game, the division strategy often has great limitations.
[0058] (2) Loading Delay and "Pop-up" Effect: Since resource loading is strongly tied to block division, improper block loading can lead to loading delays. This can cause resources to appear before the player when they enter a new area, creating a visual "pop-up" effect that significantly impacts the player's gaming experience. Furthermore, for objects that cover a large and continuous area in the scene, such as roads, improper loading delays can disrupt the object's overall appearance.
[0059] (3) Wasted time for resource loading: Since resource loading is generally directly related to file operations of resources, the performance overhead of engine loading is linearly related to the granularity of resource block division. When the number of resource blocks is too large, the main thread will spend a lot of time waiting for the resources to be loaded, which will prevent the main thread from executing other game tasks.
[0060] (4) Performance degradation caused by frequent I / O operations: Since both loading and unloading resources involve I / O operations, although the chunked loading following the player (i.e., the camera) has reduced most of the memory pressure, frequent I / O operations will still increase additional performance overhead. At the same time, since chunked loading obscures the type of resource and focuses on the size of the resource, when the resource thread performs the resource loading task, it sometimes has to make some trade-offs under the constraints of the device (such as displaying some resources last in the minimum loading range of low-end machines). In this case, the loading result often needs to be as close as possible to the expected goal.
[0061] Based on this, the game resource object loading method and related apparatus provided in this embodiment of the invention divide the game scene based on different grid levels and manage the resource objects hierarchically according to their size and position, effectively reducing the complexity of resource management. During game runtime, resource information to be cached is acquired in batches based on the predicted route corresponding to each grid level, effectively reducing the number of IO operations and avoiding performance overhead caused by frequent IO operations.
[0062] When loading game objects, the system first selects grid cells that are relatively close to the player (below the second threshold) from the predicted route table, and uses the corresponding resource page index as the loading index. Next, based on the player's coordinates, it selects resource page indices that are even closer to the player (below the third threshold) from the loading index as the target resource page indices to be loaded. Then, it loads the resource objects corresponding to the target resource page indices according to their priority. This allows for loading resource objects at multiple grid levels, preserving the size characteristics of resource objects while ensuring that resource objects at different grid levels do not interfere with each other during loading. This effectively reduces the pressure on electronic devices for loading resources in the open world, improving game performance and user experience.
[0063] The embodiments of the present invention will now be described in detail with reference to the accompanying drawings.
[0064] Please refer to Figure 1 , Figure 1 This diagram illustrates a flowchart of a game resource object loading method provided by an embodiment of the present invention. The method includes the following steps:
[0065] Step S100: During game execution, the predicted route table corresponding to each grid level in the game scene is obtained sequentially; the predicted route table is used to record the resource page index corresponding to the resource objects contained in the player's predicted route; the resource page is used to record the resource information of the resource objects in the same grid cell; the grid level corresponding to each resource object in the game scene is determined according to the size and position of the resource object.
[0066] In this embodiment of the invention, different partitioning rules are used to divide the game scene map into grids of different grid levels. The grid levels can be 64*64, 128*128, 256*256, 512*512, 1024*1024, 2048*2048, 4096*4096, etc. The incremental relationship between each grid level can be arbitrarily specified, as long as the incremental relationship conforms to the actual application of the game scene.
[0067] Assuming the game's scene map is divided into three grid levels—1024*1024, 2048*2048, and 4096*4096—the resulting grids would have side lengths of 1024, 2048, and 4096 respectively. Figure 2 As shown, the grid level corresponding to a resource object is determined based on its size and location. Resource objects in each grid level do not overlap, and there is a one-to-one correspondence between the grid level, the predicted route, and the predicted route table.
[0068] For example, a game scene contains 30 resource objects, designated A1-A10, B1-B10, and C1-C10. A1-A10 corresponds to a grid level of 1024*1024, B1-B10 to 2048*2048, and C1-C10 to 4096*4096. Therefore, resource objects on the predicted route corresponding to grid level 1024*1024 can only be selected from A1-A10, not from B1-B10 or C1-C10. The predicted route tables for the other grid levels are generated similarly.
[0069] Step S110: Determine the index to be cached based on the resource page index in the predicted route table and the player's coordinates, and cache the resource information corresponding to the index to be cached.
[0070] In this embodiment of the invention, the predicted route table for each grid level is processed to obtain the player's coordinates. Based on the player's coordinates, the index to be cached is determined from the resource page index of the predicted route table. The resource pages corresponding to the index to be cached are read in batches through a single I / O operation to obtain the resource information corresponding to the index to be cached. Here, a resource page is a file that records the resource information of each resource object in the same grid cell. The resource information includes file path, resource type, resource object coordinates, and special processing flags, etc.
[0071] Step S120: The index to be cached corresponding to the grid cell whose distance from the player is less than the second threshold is determined as the index to be loaded; the index to be loaded is reselected when the player moves to the preset position.
[0072] In this embodiment of the invention, based on the player's location, the resource page index corresponding to a grid cell whose distance from the player is less than a second threshold is selected from the cached index as the loading index. Changes in the player's position do not affect the reselection of the loading index in real time; when the player moves to a preset position, the loading index will be reselected, thereby avoiding frequent resource calls.
[0073] Step S130: The index to be loaded corresponding to the grid cell whose distance from the player is less than the third threshold is determined as the target resource page index, and the resource object corresponding to the target resource page index is loaded according to the priority of the resource object and the resource information; the third threshold is less than the second threshold.
[0074] In this embodiment of the invention, the grid cell corresponding to the index to be loaded is the grid cell to be loaded. From all the grid cells to be loaded, the grid cell that is less than the third threshold distance from the player is preferentially selected as the target grid cell. The resource page index corresponding to the target grid cell is the target resource page index. The resource object recorded in the resource page corresponding to the target resource page index is determined as the target resource object.
[0075] The priority and coordinates of the target resource object are obtained from its resource information. Target resource objects are loaded sequentially in descending order of priority. The loading position of a target resource object in the game scene is determined by its coordinates. The priority is determined based on a combination of the resource object's resource type, resource page size, and resource access frequency.
[0076] It should be noted that the second and third thresholds are preset based on the game scene, and this invention does not limit their application. Assuming the third threshold is set based on the player's field of view distance, for example, setting the third threshold to half the side length corresponding to the grid level, the second threshold can be obtained by increasing the third threshold by a fixed proportion.
[0077] In summary, the game resource object loading method provided by this invention divides the game scene based on different grid levels and manages resource objects hierarchically according to their size and location within the game scene, effectively reducing the complexity of resource management. During game runtime, resource information to be cached is retrieved in batches based on the predicted route corresponding to each grid level, effectively reducing the number of I / O operations and avoiding performance overhead caused by frequent I / O operations.
[0078] When loading game objects, the system first selects grid cells that are relatively close to the player (below the second threshold) from the predicted route table, and uses the corresponding resource page index as the loading index. Next, based on the player's coordinates, it selects resource page indices that are even closer to the player (below the third threshold) from the loading index as the target resource page indices to be loaded. Then, it loads the resource objects corresponding to the target resource page indices according to their priority. This allows for loading resource objects at multiple grid levels, preserving the size characteristics of resource objects while ensuring that resource objects at different grid levels do not interfere with each other during loading. This effectively reduces the pressure on electronic devices for loading resources in the open world, improving game performance and user experience.
[0079] Optionally, in practical applications, the resource page index includes grid level and grid cell coordinates. Regarding how to determine the index to be cached, one possible implementation is provided below. Figure 1 The sub-steps of step S110 may include:
[0080] Based on the player's coordinates and the corresponding grid level and its corresponding side length, the player's grid coordinates are obtained; the predicted route table is traversed, and resource page indexes whose distance between the player's grid coordinates and grid cell coordinates is less than a first threshold are identified as cacheable indexes; the first threshold is greater than a second threshold.
[0081] In this embodiment of the invention, each predicted route table records the resource page index corresponding to the same grid level. The player's coordinates are the player's world coordinates. Based on the partition side length and grid center coordinates corresponding to the grid level of the predicted route table, the player's coordinates are converted into the player's coordinates within the grid corresponding to the grid level, thus obtaining the player's grid coordinates.
[0082] The system iterates through the resource page indexes in the predicted route table, calculates the distance between the player and the grid cell based on the player's grid coordinates and the corresponding grid cell coordinates of the resource page index, and identifies resource page indexes with distances less than a first threshold as cacheable indexes. This ensures that resource pages within the first threshold range of distance from the player's location can be pre-cached in batches for fast loading and display, thereby improving the game's smoothness and responsiveness.
[0083] As one possible implementation, resource page I / O operations can be time-consuming. If only the main thread is used for loading, other game logic can only be processed after the resource object loading task is completed, which is quite time-consuming. Therefore, this invention creates a new resource thread that runs in parallel with the main thread. The resource thread handles the loading, decompression, decoding, and loading of resource objects, while the main thread handles game logic, such as rendering. The resource thread effectively separates resource loading tasks from game logic processing, avoiding screen stuttering caused by main thread blocking during resource loading. It also more effectively manages and schedules resource loading, ensuring that the game loads and uses resources more efficiently during runtime.
[0084] One possible implementation is to create a resource page pool on the electronic device. A resource thread dynamically loads resource pages corresponding to indexes within a first threshold range into the resource page pool in batches. The resource page pool includes a loading queue and an operation queue. The loading queue stores indexes to be loaded; the operation queue stores the target resource page indexes for which loading operations are performed.
[0085] Optionally, in practical applications, the resource page index includes grid cell coordinates. One possible implementation for determining the index to be loaded is provided below. Figure 1 The sub-steps of step S120 may include:
[0086] Based on the grid cell coordinates and player coordinates corresponding to each index to be cached, the corresponding first distance is obtained; the indexes to be cached with a first distance less than a second threshold are determined as the indexes to be loaded and are stored in the loading queue; when the player moves to the preset position in the loading queue, the index to be loaded is reselected, and the loading queue is updated according to the reselected index.
[0087] In this embodiment of the invention, the grid cell coordinates corresponding to each index to be cached are obtained sequentially. The distance between the player and the grid cell is calculated based on the grid cell coordinates and the player's coordinates to obtain a first distance. If the first distance between the player and the grid cell is less than a second threshold, the resource page index corresponding to the grid cell coordinates is determined as an index to be loaded, and the index to be loaded is stored in the loading queue.
[0088] The loading queue is not updated in real time as the player's position changes. When the player moves to a preset position in the loading queue (e.g., the middle position), a new index is selected, and the newly selected index overwrites the existing index in the loading queue. This reduces the frequency of resource calls while ensuring that players can always load and see the resources they need in a timely manner. This effectively manages resource loading, improving game smoothness and user experience.
[0089] It should be noted that, based on a third threshold, target resource page indexes are filtered from the loading queue, and then saved to the operation queue in descending order of resource object priority. This allows for the sequential retrieval of target resource page indexes from the operation queue, the acquisition of the corresponding target resource pages, and the loading of the resource objects corresponding to those indexes according to the resource information recorded on each target resource page. This ensures that resource objects closer to the player and with higher priority are loaded first, further optimizing the resource loading process. If a new resource page needs to be cached, the index to be cached is redefined, and the corresponding resource information is cached based on this newly determined index.
[0090] Optionally, in practical applications, the resource page index includes grid cell coordinates. The game resource object loading method also includes the following steps:
[0091] During game execution, the loaded resource page index corresponding to the loaded object is obtained from the predicted route table; based on the grid cell coordinates and player coordinates corresponding to each loaded resource page index, the corresponding second distance is obtained; loaded resource page indices with a second distance greater than a fourth threshold are determined as target unloading indices, and the resource objects corresponding to the target unloading indices are unloaded; the fourth threshold is greater than the first threshold.
[0092] In this embodiment of the invention, since the player's position may change, resource objects that are outside the player's field of vision need to be unloaded. To prevent frequent loading and unloading of resource objects due to the player's "repeated hopping" behavior, a fourth threshold can be set based on the player's hopping range, and resource objects that need to be unloaded can be filtered based on the fourth threshold.
[0093] As one possible implementation, the corresponding loaded resource page index is obtained based on the loaded objects in the predicted route table. The distance between the grid cell coordinates corresponding to the loaded resource page index and the player's coordinates is calculated to obtain the second distance. If the second distance is not greater than a fourth threshold, it means that the resource object corresponding to the loaded resource page index does not need to be unloaded at present. If the second distance is greater than the fourth threshold, the loaded resource page index is determined as the target unloading index, and the target unloading index is saved to the operation queue so that the resource object corresponding to the target unloading index can be unloaded, reducing memory resource consumption.
[0094] As another possible implementation, the resource page pool also includes a queue to be uninstalled. It calculates the distance between the grid cell coordinates corresponding to the loaded resource page indexes in the preset route table and the coordinates of the player's current position, obtaining a third distance. If the third distance is greater than a fifth threshold, the corresponding loaded resource page index is saved as an uninstallation index in the queue. The fifth threshold is less than the fourth threshold and greater than the first threshold. In other words, the indexes of resource pages that the player does not need are stored in the queue to be uninstalled.
[0095] When a player's position changes, the distance between the grid cell coordinates corresponding to the index to be unloaded and the player's new coordinates is calculated sequentially to obtain the second distance. If the second distance is greater than the fourth threshold, the corresponding index to be unloaded is moved from the unloaded queue to the operation queue as the target unloaded index, so that the resource object corresponding to the target unloaded index can be unloaded. This ensures that only resource objects near the player are retained, and resource objects that exceed the player's activity range are unloaded, thereby reducing memory resource consumption and improving game performance and response speed.
[0096] Alternatively, please refer to Figure 3 Before the game runs, the game resource object loading method also includes the following steps:
[0097] Step S200: During game design, resource objects in the game scene are read sequentially, and the grid level and grid cell coordinates corresponding to the resource objects are determined based on the bounding box of the resource objects and the dividing edge length corresponding to each grid level.
[0098] In this embodiment of the invention, during game design, the game scene is first divided according to the division duration corresponding to each grid level, resulting in a grid corresponding to each grid level. Each grid corresponds to a grid coordinate system.
[0099] The different grids after division are named using a unified rule. For example, the center point of the grid is taken as the origin of the grid coordinate system, the horizontal direction to the right is the positive direction of the x-axis, and the vertical direction downward is the positive direction of the y-axis. The coordinates of the grid cells are determined according to their positions in the grid.
[0100] Continue with Figure 2 For example, assume the coordinate system corresponding to a grid level of 4096*4096 is coordinate system A, the coordinate system corresponding to a grid level of 2048*2048 is coordinate system B, and the coordinate system corresponding to a grid level of 1024*1024 is coordinate system C. In coordinate system A, the top-left (black) grid cell corresponds to the coordinates (-0, 0), with a side length of 4096. In coordinate system B, the top-left (black) grid cell corresponds to the coordinates (-1, 1), with a side length of 2048. In coordinate system C, the top-left (black) grid cell corresponds to the coordinates (-3, 3).
[0101] After the grids of different grid levels are divided, all resource objects in the game scene are read in sequence, the bounding boxes of the resource objects are calculated, and the grid level corresponding to the resource object is determined based on the bounding boxes of the resource objects, the coordinates of the resource objects, and the grid division side length of each grid. The grid cell (i.e., grid cell coordinates) in which the resource object is located in the grid corresponding to the grid level is also determined, thereby realizing precise management and efficient scheduling of resource objects.
[0102] Step S210: Generate a corresponding resource page index based on the grid level and grid cell coordinates of the resource object, and save the resource information of the resource object to the resource page corresponding to the resource page index.
[0103] In this embodiment of the invention, after generating a corresponding resource page index based on the grid level and grid cell coordinates of the resource object, the resource page corresponding to the resource page index is obtained. If the resource page does not exist, the resource page corresponding to the resource page index is created, and the resource information of the resource object is saved to the newly created resource page. If the resource page already exists, the resource information of the resource object is saved to the resource page corresponding to the resource page index.
[0104] Continue with Figure 2For example, assuming resource object 1 corresponds to a grid level of 4096*4096 and the grid cell coordinates are (-0,0), meaning resource object 1 is located in the top-left grid cell of a grid with a side length of 4096, then the resource page index corresponding to the grid cell containing resource object 1 can be set to 4096_(-0,0) or 4096*4096_(-0,0). Furthermore, grids with side lengths of 4096, 2048, and 1024 can be defined as large, medium, and small, respectively. Based on this, the resource page index corresponding to the grid cell containing resource object 1 can also be set to large_(-0,0). The specific form of the resource page index is not limited in this invention.
[0105] It is worth mentioning that the embodiments of the present invention use grids with different partition lengths to manage resource objects, thereby obtaining resource pages with multiple grid levels. This enables resource loading based on the size of the resource object, which can effectively utilize the size of the resource object to solve the "pop-up" effect in resource loading.
[0106] Step S220: Predict the player's game route in the game scene based on all resource pages in each grid level to obtain the predicted route corresponding to each grid level.
[0107] Step S230: Record the resource page indexes contained in each predicted route into the corresponding predicted route table.
[0108] In this embodiment of the invention, in order to improve the accuracy of pre-cached resource information, that is, to ensure that the cached resource objects can be loaded during game runtime, it is necessary to analyze the resource pages in each grid level, predict the player's game route in the grid corresponding to each grid level, and obtain the predicted route corresponding to each grid level.
[0109] For example, in mission-based games, player behavior data is collected based on the resource objects corresponding to the resource pages in each grid level. AI statistical models are then used to analyze this player behavior data to obtain a predicted route for each grid level based on player behavior. For sandbox games, the predicted route for each grid level is predicted based on the frequency of resource object usage and the coordinates of the resource objects.
[0110] Regardless of the prediction method used to obtain the player's predicted route, the resource page indexes contained in the predicted route corresponding to each grid level are updated in the predicted route table for that grid level. By caching and loading the resource objects corresponding to each grid level using the player's predicted routes across multiple grid levels, the accuracy of caching and loading is improved, thereby optimizing the game experience and resource management efficiency, and enhancing the smoothness and responsiveness of the game.
[0111] It should be noted that if the prediction data in the prediction route changes significantly, the developer will modify the prediction route table according to the changed prediction data. At runtime, the game will load game resource objects based on the latest prediction route table to reduce the developer's manpower cost for resource allocation and management.
[0112] Optionally, regarding how to determine the grid level and grid cell coordinates corresponding to a resource object, the following is a possible implementation method. Please refer to... Figure 4 , Figure 3 The sub-steps of step S200 may include:
[0113] Step S201: Determine the minimum dividing side length that is greater than the length of the hypotenuse of the bounding box as the initial side length, and determine the mesh level corresponding to the initial side length as the initial mesh level.
[0114] In this embodiment of the invention, the lengths of the bounding box's hypotenuse and the partitioning side lengths are compared in ascending order of their respective partition lengths. If the hypotenuse length of the bounding box is not less than the partitioning side length, the next partitioning side length is obtained and compared with the hypotenuse length of the bounding box. If the hypotenuse length of the bounding box is less than the partitioning side length, the partitioning side length is used as the initial side length, and the mesh level corresponding to the initial side length is determined as the initial mesh level.
[0115] Step S202: Determine the initial grid cell coordinates based on the center coordinates of the bounding box, the size of the game scene, and the initial side length.
[0116] In this embodiment of the invention, the coordinates of each grid cell in the grid corresponding to the initial grid level are determined based on the size of the game scene and the initial side length; the coordinates of the grid cell where the bounding box is located are determined based on the center coordinates of the bounding box and the coordinates of each grid cell, thus obtaining the initial grid cell coordinates. The center coordinates of the bounding box are the same as the coordinates of the resource object corresponding to the bounding box.
[0117] Step S203: Extend the region corresponding to the initial grid cell coordinates in four directions according to the preset size to obtain the extended region.
[0118] In this embodiment of the invention, the region corresponding to the initial grid cell coordinates is extended in four directions of the grid coordinate system according to a preset size to obtain the extended region. Continuing with... Figure 2 For example, the initial grid level corresponding to the resource object is 1024*1024, and the initial grid cell coordinates are (-2,2). Assuming the preset size is half the length of the dividing side, the initial grid cell is extended outward by 512 units along the positive X-axis, negative X-axis, positive Y-axis, and negative Y-axis of the grid coordinate system to obtain the extended area.
[0119] Step S204: Determine whether the vertex coordinates of the bounding box are all inside the extended region.
[0120] In this embodiment of the invention, the coordinates of the four vertices of the bounding box corresponding to the resource object are obtained, and it is determined whether the coordinates of the four vertices are all located inside the extended region. If the coordinates of the four vertices are all located inside the extended region, step S205 is executed. If at least one vertex coordinate is located outside the extended region, step S206 is executed.
[0121] Step S205: Use the initial grid level as the grid level of the resource object, and use the initial grid cell coordinates as the grid cell coordinates of the resource object.
[0122] Step S206: Determine the grid level of the resource object as the grid level corresponding to the smallest partitioned side length that is longer than the initial side length, and determine the grid cell coordinates of the resource object based on the center coordinates of the bounding box, the size of the game scene, and the partitioned side length corresponding to the grid level of the resource object.
[0123] In this embodiment of the invention, continuing with Figure 2 For example, if the initial side length of a resource object is 1024, and there are vertex coordinates located outside the extended region, then the grid level corresponding to the partition side length of 2048 is determined as the grid level of the resource object. Based on the size of the game scene and the partition side length of 2048, the coordinates of each grid cell in the grid corresponding to the resource object are determined; based on the center coordinates of the bounding box and the grid cell coordinates corresponding to the resource object, the coordinates of the grid cell where the bounding box is located are determined, thus obtaining the grid cell coordinates of the resource object.
[0124] This invention extends the grid cells in four directions when dividing resource pages into multiple grid levels. Based on the extended area, it determines whether the resource object is completely covered within the tolerance boundary. Resource objects exceeding the tolerance boundary are placed in a grid level with a larger side length for management. This ensures that resource objects located at grid boundaries can be loaded from a greater distance, stabilizing the display effect within reasonable expectations and effectively avoiding the problems of delayed loading or "pop-up" effects of resource objects at grid cell boundaries in existing technologies.
[0125] Based on the same inventive concept, the basic principle and technical effects of the game resource object loading device provided in this embodiment are the same as those in the above embodiments. For the sake of brevity, any parts not mentioned in this embodiment can be referred to the corresponding content in the above embodiments.
[0126] Please refer to Figure 5 , Figure 5This is a block diagram of a game resource object loading device 300 provided in an embodiment of the present invention. The game resource object loading device 300 includes an acquisition module 301, a processing module 302, and a loading module 303.
[0127] The acquisition module 301 is used to sequentially acquire the predicted route table corresponding to each grid level in the game scene during game runtime; the predicted route table is used to record the resource page index corresponding to the resource objects contained in the player's predicted route; the resource page is used to record the resource information of the resource objects in the same grid cell; the grid level corresponding to each resource object in the game scene is determined according to the size and position of the resource object.
[0128] The processing module 302 is used to determine the index to be cached based on the resource page index in the predicted route table and the player's coordinates, and to cache the resource information corresponding to the index to be cached.
[0129] The loading module 303 is used to determine the index to be cached corresponding to the grid cell whose distance from the player is less than a second threshold as the index to be loaded; the index to be loaded is reselected when the player moves to a preset position; the index to be loaded corresponding to the grid cell whose distance from the player is less than a third threshold is determined as the target resource page index, and the resource object corresponding to the target resource page index is loaded according to the priority and resource information of the resource object; the third threshold is less than the second threshold.
[0130] In summary, the game resource object loading device provided in this embodiment of the invention divides the game scene based on different grid levels and manages resource objects hierarchically according to their size and location within the game scene, effectively reducing the complexity of resource management. During game runtime, resource information to be cached is acquired in batches based on the predicted route corresponding to each grid level, effectively reducing the number of I / O operations and avoiding performance overhead caused by frequent I / O operations.
[0131] When loading game objects, the system first selects grid cells that are relatively close to the player (below the second threshold) from the predicted route table, and uses the corresponding resource page index as the loading index. Next, based on the player's coordinates, it selects resource page indices that are even closer to the player (below the third threshold) from the loading index as the target resource page indices to be loaded. Then, it loads the resource objects corresponding to the target resource page indices according to their priority. This allows for loading resource objects at multiple grid levels, preserving the size characteristics of resource objects while ensuring that resource objects at different grid levels do not interfere with each other during loading. This effectively reduces the pressure on electronic devices for loading resources in the open world, improving game performance and user experience.
[0132] Optionally, the resource page index includes grid level and grid cell coordinates. Processing module 302 is specifically used to obtain the player's grid coordinates based on the player's coordinates and the partition length corresponding to the grid level; traverse the predicted route table, and determine resource page indexes whose distance between the player's grid coordinates and grid cell coordinates is less than a first threshold as cacheable indexes; the first threshold is greater than a second threshold.
[0133] Optionally, the resource page index includes grid cell coordinates. The loading module 303 is specifically used to obtain a first distance based on the grid cell coordinates corresponding to each index to be cached and the player's coordinates; to determine the indexes to be cached with a first distance less than a second threshold as indexes to be loaded, and to store these indexes in a loading queue; when the player moves to a preset position in the loading queue, a new index to be loaded is selected, and the loading queue is updated based on the newly selected index.
[0134] Optionally, the resource page index includes grid cell coordinates. The acquisition module 301 is also used to retrieve the loaded resource page index corresponding to the loaded object from the predicted route table during game runtime.
[0135] The loading module 303 is also used to obtain the corresponding second distance based on the grid cell coordinates and player coordinates corresponding to each loaded resource page index; determine the loaded resource page index with the second distance greater than the fourth threshold as the target unloading index, and unload the resource object corresponding to the target unloading index; the fourth threshold is greater than the first threshold.
[0136] Optionally, the processing module 302 is further configured to, during game design, sequentially read resource objects in the game scene, determine the grid level and grid cell coordinates corresponding to the resource objects based on the bounding box of the resource objects and the partitioning edge length corresponding to each grid level; generate corresponding resource page indexes based on the grid level and grid cell coordinates corresponding to the resource objects, and save the resource information of the resource objects to the resource pages corresponding to the resource page indexes; predict the player's game route in the game scene based on all resource pages in each grid level, and obtain the predicted route corresponding to each grid level; and record the resource page indexes contained in each predicted route to the corresponding predicted route table.
[0137] Optionally, the processing module 302 is specifically used to determine the minimum partition length greater than the hypotenuse length of the bounding box as the initial side length, and to determine the mesh level corresponding to the initial side length as the initial mesh level; to determine the initial mesh unit coordinates based on the center coordinates of the bounding box, the size of the game scene, and the initial side length; to extend the area corresponding to the initial mesh unit coordinates in four directions according to a preset size to obtain an extended area; when the vertex coordinates of the bounding box are all inside the extended area, the initial mesh level is used as the mesh level of the resource object, and the initial mesh unit coordinates are used as the mesh unit coordinates of the resource object; when the vertex coordinates of the bounding box are not inside the extended area, the mesh level corresponding to the minimum partition length greater than the initial side length is determined as the mesh level of the resource object, and the mesh unit coordinates of the resource object are determined based on the center coordinates of the bounding box, the size of the game scene, and the partition length corresponding to the mesh level of the resource object.
[0138] Please refer to Figure 6 This is a block diagram of an electronic device 100 provided in an embodiment of the present invention. The electronic device 100 includes a memory 110, a processor 120, and a communication module 130. The memory 110, processor 120, and communication module 130 are electrically connected to each other directly or indirectly to realize data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines.
[0139] The memory 110 is used to store programs or data. The memory 110 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.
[0140] The processor 120 is used to read / write data or programs stored in the memory 110 and perform corresponding functions. For example, when a computer program stored in the memory 110 is executed by the processor 120, the game resource object loading method disclosed in the above embodiments can be implemented.
[0141] The communication module 130 is used to establish a communication connection between the electronic device 100 and other communication terminals via a network, and to send and receive data via the network.
[0142] It should be understood that, Figure 6 The structure shown is only a schematic diagram of the electronic device 100. The electronic device 100 may also include components that are larger than... Figure 6 The more or fewer components shown, or having the same Figure 6 The different configurations shown. Figure 6 The components shown can be implemented using hardware, software, or a combination thereof.
[0143] This invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor 120, implements the game resource object loading method disclosed in the above embodiments.
[0144] This invention also provides a program product that, when executed by processor 120, implements the game resource object loading method disclosed in the above embodiments.
[0145] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative; for example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0146] In addition, the functional modules in the various embodiments of the present invention can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0147] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0148] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for loading game resource objects, characterized in that, The method includes: During game execution, the predicted route table corresponding to each grid level in the game scene is obtained sequentially; the predicted route table is used to record the resource page index corresponding to the resource objects contained in the player's predicted route; the resource page is used to record the resource information of the resource objects in the same grid unit; the grid level corresponding to each resource object in the game scene is determined according to the size and position of the resource object; The index to be cached is determined based on the resource page index in the predicted route table and the player's coordinates, and the resource information corresponding to the index to be cached is cached. The index to be cached corresponding to the grid cell whose distance from the player is less than the second threshold is determined as the index to be loaded; the index to be loaded is reselected when the player moves to the preset position; The index to be loaded corresponding to the grid cell whose distance to the player is less than the third threshold is determined as the target resource page index, and the resource object corresponding to the target resource page index is loaded according to the priority and resource information of the resource object; the third threshold is less than the second threshold.
2. The game resource object loading method according to claim 1, characterized in that, The resource page index includes grid level and grid cell coordinates; determining the index to be cached based on the resource page index in the predicted route table and the player's coordinates includes: The player's grid coordinates are obtained based on the player's coordinates and the dividing edge length corresponding to the grid level; Traverse the predicted route table and determine the resource page indexes where the distance between the player's grid coordinates and the grid cell coordinates is less than a first threshold as cacheable indexes; the first threshold is greater than the second threshold.
3. The game resource object loading method according to claim 1, characterized in that, The resource page index includes grid cell coordinates; determining the index to be cached corresponding to the grid cell whose distance from the player is less than the second threshold as the index to be loaded includes: Based on the grid cell coordinates corresponding to each index to be cached and the player's coordinates, the corresponding first distance is obtained; The indexes to be cached that are less than the first distance to the second threshold are identified as the indexes to be loaded, and the indexes to be loaded are stored in the loading queue; When the player moves to the preset position in the loading queue, a new loading index is selected, and the loading queue is updated according to the newly selected loading index.
4. The game resource object loading method according to claim 2, characterized in that, The resource page index includes grid cell coordinates, and the method further includes: During game runtime, the index of the loaded resource page corresponding to the loaded object is obtained from the predicted route table; The second distance is obtained based on the grid cell coordinates corresponding to each loaded resource page index and the player's coordinates; The loaded resource page index with a second distance greater than the fourth threshold is determined as the target unload index, and the resource object corresponding to the target unload index is unloaded; the fourth threshold is greater than the first threshold.
5. The game resource object loading method according to claim 1, characterized in that, The method further includes: During game design, resource objects in the game scene are read sequentially, and the grid level and grid cell coordinates of the resource objects are determined according to the bounding box of the resource objects and the partitioning side lengths corresponding to each grid level. Generate a corresponding resource page index based on the grid level and grid cell coordinates of the resource object, and save the resource information of the resource object to the resource page corresponding to the resource page index; The player's game route in the game scene is predicted based on all resource pages in each grid level, resulting in a predicted route for each grid level. Record the resource page indexes contained in each predicted route into the corresponding predicted route table.
6. The game resource object loading method according to claim 5, characterized in that, The step of determining the grid level and grid cell coordinates corresponding to the resource object based on the bounding box of the resource object and the partitioning edge length corresponding to each grid level includes: The minimum dividing side length that is greater than the hypotenuse length of the bounding box is determined as the initial side length, and the grid level corresponding to the initial side length is determined as the initial grid level; The initial grid cell coordinates are determined based on the center coordinates of the bounding box, the size of the game scene, and the initial side length. The region corresponding to the initial grid cell coordinates is extended in four directions according to a preset size to obtain the extended region; When the vertex coordinates of the bounding box are all inside the extended region, the initial mesh level is used as the mesh level of the resource object, and the initial mesh cell coordinates are used as the mesh cell coordinates of the resource object; When the vertex coordinates of the bounding box are not inside the extended region, the grid level corresponding to the smallest partition side length that is longer than the initial side length is determined as the grid level of the resource object, and the grid cell coordinates of the resource object are determined according to the center coordinates of the bounding box, the size of the game scene, and the partition side length corresponding to the grid level of the resource object.
7. A game resource object loading device, characterized in that, The device includes: The acquisition module is used to sequentially acquire the predicted route table corresponding to each grid level in the game scene during game runtime; the predicted route table is used to record the resource page index corresponding to the resource objects contained in the player's predicted route; the resource page is used to record the resource information of the resource objects in the same grid unit; the grid level corresponding to each resource object in the game scene is determined according to the size and position of the resource object; The processing module is used to determine the index to be cached based on the resource page index in the predicted route table and the player's coordinates, and to cache the resource information corresponding to the index to be cached. The loading module is used to determine the index to be cached corresponding to the grid cell whose distance from the player is less than a second threshold as the index to be loaded; the index to be loaded is reselected when the player moves to a preset position; the index to be loaded corresponding to the grid cell whose distance from the player is less than a third threshold is determined as the target resource page index, and the resource object corresponding to the target resource page index is loaded according to the priority and resource information of the resource object; the third threshold is less than the second threshold.
8. An electronic device, characterized in that, It includes a processor and a memory, the memory storing a computer program that can be executed by the processor, the processor being able to execute the computer program to implement the game resource object loading method according to any one of claims 1-6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the game resource object loading method as described in any one of claims 1-6.
10. A program product, characterized in that, When the program product is executed by the processor, it implements the game resource object loading method as described in any one of claims 1-6.
Citation Information
Patent Citations
Game scene loading method and device, storage medium and equipment
CN115708958A
Scene entity processing using flattened list of sub-items in computer game
US20230115603A1