A data processing method and related apparatus
By defining the user's field of view in a virtual space scene and utilizing the preset hierarchical structure data in the resource files of the streaming scene, only object instances at the specified SLOD level are loaded, thus solving the performance bottleneck problem caused by frequent dynamic loading and unloading in the virtual space scene and achieving optimized memory management.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING CHANGYOU CHUANGXIANG SOFTWARE TECH CO LTD
- Filing Date
- 2025-11-10
- Publication Date
- 2026-04-21
AI Technical Summary
In virtual space scenarios, frequent dynamic loading and unloading of objects leads to disk I/O and CPU performance bottlenecks, failing to meet memory optimization requirements.
By determining the user's field of view and utilizing the preset hierarchical structure data in the resource files of the streaming scene, dynamically loaded objects are loaded and unloaded, retaining only object instances at the specified SLOD level, thereby reducing the frequency of dynamic loading and unloading and minimizing memory usage.
It effectively reduces the frequency of dynamic loading and unloading, prevents disk I/O and CPU performance bottlenecks, and meets the memory management requirements of virtual space scenarios.
Smart Images

Figure CN121437249B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer graphics technology, and in particular to a data processing method and related apparatus. Background Technology
[0002] Virtual space scenes can be constructed within a virtual environment, featuring vast geographical areas and complex objects. These scenes place extremely high demands on memory management and rendering performance. Currently, when loading objects, all levels of object instances reside in memory, failing to meet the memory optimization requirements of virtual space scenes. Furthermore, dynamic loading and unloading of objects based on distance—loading objects closer to the user's field of view and unloading them further away—increases the frequency of dynamic loading and unloading. Frequent dynamic loading and unloading can lead to performance bottlenecks in disk I / O (Input / Output) and CPU (Central Processing Unit). Summary of the Invention
[0003] In view of the above problems, this application provides a data processing method and related apparatus to reduce the frequency of memory usage and loading / unloading. The specific solution is as follows:
[0004] The first aspect of this application provides a data processing method, including:
[0005] Determine the user's field of vision;
[0006] Read preset hierarchical structure data from the resource file of the streaming scene. The streaming scene is a scene in the virtual space scene. The virtual space scene includes a base scene and multiple streaming scenes. The base scene includes non-dynamically loaded global objects. The streaming scenes include dynamically loaded objects. The dynamically loaded objects have StreamableObject components that can be streamed. The StreamableObject components are configured with Streamable Levels of Detail (SLODs). Each SLOD contains object instances at different levels. The identifier of the StreamableObject component is recorded in a node of the preset hierarchical structure. The node of the preset hierarchical structure represents a data block. The preset hierarchical structure data is used to reconstruct the preset hierarchical structure that records the identifier of the StreamableObject component.
[0007] Based on the preset hierarchical structure data, determine the target node in the preset hierarchical structure that matches the user's field of view;
[0008] Based on the identifier of the StreamableObject component recorded in the target node, the dynamic loading object to be loaded is determined, and based on the data block represented by the target node and the Datalayer configured for the dynamic loading object, the dynamic loading object to be loaded is determined, wherein the Datalayer is used to indicate the data block to which the dynamic loading object belongs;
[0009] Based on the storage path of the SLOD resource file of the dynamically loaded object to be loaded in the resource file of the streaming scene, obtain the SLOD resource file of the dynamically loaded object to be loaded. The SLOD resource file of the dynamically loaded object to be loaded records the object instance of the dynamically loaded object at the specified SLOD level.
[0010] Load the SLOD resource file of the dynamically loaded object to complete the loading of the dynamically loaded object;
[0011] Unload dynamically loaded objects that were loaded before this load.
[0012] In one possible implementation, the process of generating SLOD resource files for dynamically loaded objects configured in the Datalayer includes:
[0013] Obtain the first generation instruction;
[0014] In response to the first generation instruction, find all target objects. The target objects are dynamically loaded objects with an added ObjectPartitionComponent component and specified Datalayer and SLOD generation rules. The SLOD generation rules are the generation rules corresponding to the cells of the target objects. The SLOD generation rules are at least used to specify the SLOD level of the target objects.
[0015] For any target object, obtain the object instance of the target object at the specified SLOD level according to the SLOD level specified by the target object;
[0016] For any target object, generate the SLOD resource file of the target object based on the target object's Datalayer, the target object's SLOD generation rules, and the object instance of the target object at the specified SLOD level.
[0017] In one possible implementation, the process of generating resource files for the streaming scene includes:
[0018] Obtain the second generation instruction;
[0019] In response to the second generation instruction, a resource file for the streaming scene is generated; the resource file for the streaming scene is used to record the storage path and preset hierarchical structure data of the SLOD resource file of the dynamically loaded object.
[0020] In one possible implementation, the method further includes: after generating the SLOD resource file of the target object, encapsulating the SLOD resource file of the target object into a reusable prefab, wherein the storage path of the reusable prefab is recorded in the resource file of the streaming scene.
[0021] In one possible implementation, the method further includes: encapsulating the shared resources of all target objects into an AssetBundle, wherein the reusable Prefab does not contain the shared resources.
[0022] In one possible implementation, the SLOD generation rules include: hierarchy, SLODLayerType, MeshMergeType, and SimplifyMeshQuality. The hierarchy indicates the next layer to be loaded, the SLODLayerType indicates the SLOD level, the MeshMergeType indicates the mesh merging method, and the SimplifyMeshQuality indicates the mesh simplification quality.
[0023] A second aspect of this application provides a data processing apparatus, comprising:
[0024] The first determining module is used to determine the user's field of vision.
[0025] The reading module is used to read preset hierarchical structure data from the resource files of the streaming scene. The streaming scene is a scene in the virtual space scene. The virtual space scene includes a base scene and multiple streaming scenes. The base scene includes non-dynamically loaded global objects. The streaming scenes include dynamically loaded objects. The dynamically loaded objects have added StreamableObject components that can be streamed. The StreamableObject components are configured with Streamable Levels of Detail (SLODs). Each SLOD contains object instances at different levels. The identifier of the StreamableObject component is recorded in a node of the preset hierarchical structure. The node of the preset hierarchical structure represents a data block. The preset hierarchical structure data is used to reconstruct the preset hierarchical structure that records the identifier of the StreamableObject component.
[0026] The second determining module is used to determine the target node in the preset hierarchical structure that matches the user's field of view based on the preset hierarchical structure data.
[0027] The third determining module is used to determine the dynamic loading object to be loaded based on the identifier of the StreamableObject component recorded in the target node, and to determine the dynamic loading object to be loaded based on the data block represented by the target node and the Datalayer configured for the dynamic loading object. The Datalayer is used to indicate the data block to which the dynamic loading object belongs.
[0028] The acquisition module is used to acquire the SLOD resource file of the dynamically loaded object to be loaded based on the storage path of the SLOD resource file of the dynamically loaded object to be loaded in the resource file of the streaming scene. The SLOD resource file of the dynamically loaded object to be loaded records the object instance of the dynamically loaded object at the specified SLOD level.
[0029] The load / unload module is used to load the SLOD resource file of the dynamic loading object to be loaded in order to complete the loading of the dynamic loading object, and to unload the dynamic loading object that has been loaded before this loading.
[0030] A third aspect of this application provides a computer program product including computer-readable instructions that, when executed on an electronic device, cause the electronic device to implement the data processing method described in the first aspect or any implementation thereof.
[0031] A fourth aspect of this application provides an electronic device, including at least one processor and a memory connected to the processor, wherein:
[0032] The memory is used to store computer programs;
[0033] The processor is used to execute the computer program so that the electronic device can implement the data processing method of the first aspect or any implementation thereof.
[0034] The fifth aspect of this application provides a computer storage medium carrying one or more computer programs, which, when executed by an electronic device, enable the electronic device to perform the data processing method described in the first aspect or any implementation thereof.
[0035] By employing the above technical solution, the data processing method and related apparatus provided in this application, after determining the user's field of view, determine the target node in the preset hierarchical structure that matches the user's field of view based on the preset hierarchical structure data in the resource file of the streaming scene; determine the dynamically loaded object to be loaded based on the identifier of the StreamableObject component recorded in the target node, and determine the dynamically loaded object to be loaded based on the data block represented by the target node and the Datalayer configured for the dynamically loaded object; after obtaining the SLOD resource file of the dynamically loaded object to be loaded, load the SLOD resource file of the dynamically loaded object to complete the loading of the dynamically loaded object. Here, the dynamically loaded objects to be loaded are all dynamically loaded objects located in the data block represented by the target node. As long as the target node matches the user's field of view, the loading of the dynamically loaded object in the data block can be maintained regardless of the distance from the user, thereby reducing the frequency of dynamic loading and unloading and preventing disk I / O and CPU performance bottlenecks caused by frequent dynamic loading and unloading. Furthermore, the SLOD resource file of the dynamically loaded object records the object instance of the dynamically loaded object at the specified SLOD level. Therefore, when loading the dynamically loaded object, only the object instance at its SLOD level needs to be loaded. Only the object instance of the dynamically loaded object at the specified SLOD level is in memory, avoiding the residing of all SLOD level object instances of the dynamically loaded object in memory. This reduces memory usage to a certain extent and can meet the memory management requirements of virtual space scenarios. Attached Figure Description
[0036] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale.
[0037] Figure 1 A flowchart of a data processing method provided in this application;
[0038] Figure 2 A schematic diagram illustrating the division of the basic scene and the streaming scene provided for this application;
[0039] Figure 3 A schematic diagram illustrating the addition of a StreamableObject component to a GameObject in a streaming scene, as provided in this application;
[0040] Figure 4 A schematic diagram showing a GameObject displayed in a Hierarchy window, provided for this application;
[0041] Figure 5 and Figure 6 A schematic diagram illustrating the configuration of SLOD levels and object instances for a StreamableObject component provided in this application;
[0042] Figure 7 The flowchart for generating SLOD resource files provided in this application;
[0043] Figure 8 A schematic diagram illustrating the specification of Datalayer and HLODLayer in ObjectPartitionComponent for the purposes of this application;
[0044] Figure 9 A schematic diagram of the HLODLayer provided for this application;
[0045] Figure 10 A schematic diagram illustrating the creation of a ScenePartition node provided in this application;
[0046] Figure 11 A schematic diagram illustrating the setting of the WorldPosition and CellSize of the Grid provided in this application;
[0047] Figure 12 A schematic diagram illustrating the enabling of FindInScene provided in this application;
[0048] Figure 13 A schematic diagram of the structure of a data processing device provided in this application;
[0049] Figure 14 This is a schematic diagram of the structure of an electronic device provided in this application. Detailed Implementation
[0050] The embodiments of this application are described below with reference to the accompanying drawings. The terminology used in the implementation section of this application is for explaining specific embodiments only and is not intended to limit the scope of this application.
[0051] The embodiments of this application will now be described with reference to the accompanying drawings. Those skilled in the art will recognize that, with technological advancements and the emergence of new scenarios, the technical solutions provided in the embodiments of this application are equally applicable to similar technical problems.
[0052] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such terms are interchangeable where appropriate; this is merely a way of distinguishing objects with the same attributes in the embodiments of this application. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion, so that a process, method, system, product, or apparatus that comprises a series of elements is not necessarily limited to those elements but may include other elements not explicitly listed or inherent to such processes, methods, systems, products, or apparatus.
[0053] The technical terms used in the embodiments of this application are explained as follows:
[0054] Base Scene: The basic scene contains non-dynamically loaded global objects, such as the Directional Light and the Main Camera.
[0055] StreamableScene: A streaming scene containing StreamableObject, used to reduce memory usage and optimize rendering performance.
[0056] StreamableObject: A streamable object containing a multilevel hierarchy of details (SLOD) that supports dynamic loading and unloading to optimize memory and rendering.
[0057] SLOD: Streamable Level of Detail, similar to LODGroup but with a greater focus on memory management. LODGroup is used to record data at different levels of LOD (Level of Detail).
[0058] WorldStreamer: The world streamer loading manager, responsible for dynamically scheduling asset loading and object instantiation.
[0059] Grid: The scene is divided into grids, which define the center point and cell size of the world region. It is used to organize and manage objects. The world region is an area in the scene.
[0060] Cell: The smallest unit in a Grid, used to store objects. It supports distributing objects to different Chunks by Datalayer (data hierarchy configuration).
[0061] HLODLayer: High-level detail layer configuration, defines the generation rules for SLOD, including hierarchical relationships, mesh merging methods, and simplification quality.
[0062] ObjectPartitionComponent: An object partitioning component used to specify the Datalayer and HLODLayer to which an object belongs.
[0063] Please see Figure 1 It illustrates an optional flow of a data processing method provided in an embodiment of this application, which may include the following steps:
[0064] S101. Determine the user's field of view. In this embodiment, the user's field of view is used to determine the area of the object to be loaded. When the user's field of view changes, the corresponding area of the loaded object also changes. In practical applications, an observer is added through the IObserver interface in WorldStreamer. The observer is the user, and the position of the observer is dynamically updated through the IObserver interface. The user's field of view is determined based on the position of the observer. WorldStreamer is used to load and unload objects.
[0065] S102. Read the preset hierarchical structure data from the resource file of the streaming scene. Here, the streaming scene is a scene in the virtual space scene. The virtual space scene includes a base scene and multiple streaming scenes. The base scene includes non-dynamically loaded global objects, and the streaming scenes include dynamically loaded objects. The dynamically loaded objects have StreamableObject components that can be stream-loaded.
[0066] In one possible implementation, the virtual space scene can be configured using World Builder, such as... Figure 2 As shown, World Builder divides the virtual space scene into a base scene and multiple Streamable Scenes. Multiple scene designers can edit a single Streamable Scene, effectively avoiding editing conflicts when multiple scene designers work simultaneously.
[0067] Add a StreamableObject component to a GameObject object in a Streamable Scene to indicate that the GameObject is a dynamically loaded object. A Streamable Scene must contain at least one GameObject with the StreamableObject component added. Figure 3As shown, the Inspector adds a StreamableObject component to the GameObject.
[0068] A GameObject's StreamableObject component is configured with SLOD (e.g. Figure 3 In StreamableLODs, each SLOD contains object instances at different levels, with SLOD0 being the highest level and decreasing progressively. SLODInf is the most distant simplified expression and is the lowest level. Higher levels indicate higher precision of the object instances. To illustrate, a GameObject with the StreamableObject component added can be displayed in the Hierarchy window, such as... Figure 4 As shown. Scene01 For Streamable Scene, Scene01 The GameObject has an "S" symbol on its right side, which indicates that the GameObject has a StreamableObject component added.
[0069] Next, click on GameObject to enter the Inspector, and drag the 3D Object→Cube selected for the StreamableObject component of GameObject to button 0 in the StreamableLODs panel to add the Cube to SLOD0, thus creating an object instance for the SLOD0 level of the StreamableObject component, as shown below. Figure 5 As shown.
[0070] Next, after detecting that the user right-clicked on button 0, the InsertAfter dialog box is entered to create SLOD1. Similar to creating an object instance corresponding to the SLOD level, a Sphere sub-object is added to the StreamableObject component and dragged into SLOD1, as shown below. Figure 6 As shown. If the user alternately clicks button 0 and button 1, the display of the object instance corresponding to SLOD0 level and the object instance corresponding to SLOD1 level can be switched, allowing the user to observe the StreamableObject component changing back and forth between Cube and Sphere in the Scene window.
[0071] It should be noted that the use of Cube and Sphere in this embodiment is merely for demonstration purposes. In actual projects, there should not be such abrupt changes between object instances corresponding to multiple SLOD levels of a StreamableObject component.
[0072] Each SLOD level can contain multiple object instances, and object instances can be shared between SLOD levels. Therefore, whether it is a simple GameObject (such as a tree) or a complex GameObject (such as a castle or a small village), it can be described and represented by the StreamableObject component. Thus, the SLOD level of a GameObject can be the SLOD level of its StreamableObject component, and an object instance of a GameObject at any SLOD level can be an object instance of its StreamableObject component at that SLOD level.
[0073] GameObjects should be displayed with the highest level of detail at SLOD0, decreasing progressively from SLOD1. If a GameObject needs to be observable from an extremely far distance, its most simplified instance can be dragged to the SLODInf level. Instances at the SLODInf level can remain in memory without being unloaded (unless all Observers are removed from the WorldStreamer).
[0074] In this embodiment, the identifier of the StreamableObject component is recorded in a node of a preset hierarchical structure. Each node in the preset hierarchical structure represents a data block. The preset hierarchical structure data is used to reconstruct the preset hierarchical structure that records the identifier of the StreamableObject component. The node to which the StreamableObject component belongs can be found through the preset hierarchical structure. Since the StreamableObject component is a component of GameObject, the node to which the StreamableObject component belongs is the node to which the GameObject belongs. Each node represents a data block, thus the data block to which the GameObject belongs can be found through the preset hierarchical structure.
[0075] For example, the default hierarchical structure can be a quadtree. The parameters `Minimal Side Length` and `AreaProportion` control the generation of the quadtree. `Minimal Side Length` is the minimum allowed side length of a node, defaulting to 30 (Unity's default unit of measurement is meters). `AreaProportion` is the critical value for the ratio of the area of a node to the area of a StreamableObject component located within that node, expressed as a fraction with a default value of 16. Using the default value of 16 as an example, during the top-down quadtree generation process, if the area of a StreamableObject component exceeds 1 / 16 of the current node's area, it will be kept in the current node; otherwise, it will continue to move to descendant nodes until the critical condition is no longer met. `Minimal Side Length` and `AreaProportion` affect the accuracy and performance of runtime collision detection; generally, the default values are sufficient.
[0076] The area of the StreamableObject component is the area of the GameObject to which it belongs. Since a StreamableObject component is added to a GameObject, recording the identifier of the StreamableObject component in the nodes of the predefined hierarchy is equivalent to recording the GameObject in the nodes of the predefined hierarchy. Then, based on the relationship between the area of the GameObject and the area of the node, the GameObject is recorded under the matching node.
[0077] In passing Figures 2 to 6 After completing the partitioning of the streaming scene, the configuration of GameObjects within the streaming scene, and the configuration of the preset hierarchical structure, the user can trigger a second generation command to generate the resource files for the streaming scene. For example... Figure 2 The "Build" button shown triggers a second generation instruction to generate resource files for the streaming scene when clicked by the user. Correspondingly, the data processing method provided in this embodiment further includes: obtaining the second generation instruction; responding to the second generation instruction to generate resource files for the streaming scene; the resource files for the streaming scene are used to record the storage path and preset hierarchical structure data of the SLOD resource files of dynamically loaded objects.
[0078] Combination Figure 2To explain, click the Build button in WorldBuilder to generate a WorldInfo binary file (World_1.bytes) and an XML (Extensible Markup Language) description file (World_1.bytes.xml). The WorldInfo binary file is... Figure 2 The resource file for the streaming scene World_1 records the storage path of the SLOD resource files for dynamically loaded objects, as well as the quadtree data (a preset hierarchical structure data when managing StreamableObject components using quadtrees). When loading the virtual space scene, WorldStreamer needs to load the WorldInfo binary file to manage dynamic loading and object instantiation. In some examples, the streaming scene's resource file also records the hierarchical structure of the object instances corresponding to the StreamableObject components, in order to load object instances.
[0079] S103. Based on the preset hierarchical structure data, determine the target node in the preset hierarchical structure that matches the user's field of view. In this embodiment, the preset hierarchical structure data can reconstruct a preset hierarchical structure marked with the identifier of the StreamableObject component. The boundary range of the data block represented by each node in the preset hierarchical structure is obtained from the preset hierarchical structure data. The node where the boundary range intersects with the user's field of view is determined. Based on the node where the boundary range intersects with the user's field of view, the target node that matches the user's field of view is determined.
[0080] S104. Determine the dynamic loading object to be loaded by using the identifier of the StreamableObject component recorded in the target node, and determine the dynamic loading object to be loaded based on the data block represented by the target node and the Datalayer configured for the dynamic loading object. The Datalayer is used to indicate the data block to which the dynamic loading object belongs.
[0081] In this embodiment, the dynamic loading object to be loaded is determined. The dynamic loading object to be loaded is the dynamic loading object located in the data block represented by the target node. The dynamic loading object is indicated by the Datalayer to the data block to which the dynamic loading object belongs.
[0082] In this embodiment, the target node records the StreamableObject component of the GameObject (dynamically loaded object). Therefore, the target node to which the StreamableObject component belongs is the target node to which the GameObject belongs. The dynamically loaded object to be loaded can be determined through the target node.
[0083] In addition to identifying the dynamically loaded object by the identifier of the StreamableObject component recorded in the target node, the dynamically loaded object can also be identified based on the data block represented by the target node and the Datalayer configured for the dynamically loaded object. The Datalayer indicates the data block to which the dynamically loaded object belongs. The target node is a node in the preset hierarchical structure that matches the user's field of view. One target node can represent one data block. Therefore, based on the Datalayer configured for the dynamically loaded object, it can be determined whether the data block to which the dynamically loaded object belongs matches the data block represented by the target node. If they match, the dynamically loaded object is identified as the dynamically loaded object to be loaded.
[0084] S105. Based on the storage path of the SLOD resource file of the dynamically loaded object to be loaded in the resource file of the streaming scene, obtain the SLOD resource file of the dynamically loaded object to be loaded. The SLOD resource file of the dynamically loaded object to be loaded records the object instance of the dynamically loaded object at the specified SLOD level.
[0085] S106. Load the SLOD resource file of the dynamically loaded object to complete the loading of the dynamically loaded object.
[0086] In this embodiment, loading the SLOD resource file of the dynamically loaded object mainly involves loading the object instances of the dynamically loaded object at the specified SLOD level. Because only the object instances at the specified SLOD level need to be loaded when loading a dynamically loaded object, only the object instances of the dynamically loaded object at the specified SLOD level reside in memory. This avoids all SLOD level object instances of the dynamically loaded object residing in memory, thereby reducing memory usage to a certain extent and meeting the memory management requirements of the virtual space scenario.
[0087] The virtual space scene includes a base scene (Base Scene) and a streaming scene (StreamableScene). Each scene includes at least one object. When loading a virtual space scene, the base scene (which may include the object that loads the base scene) is loaded first. Then, WorldStreamer is used to manage the loading of dynamically loaded objects in the streaming scene to support user roaming in the virtual space.
[0088] WorldStreamer is a task scheduling system that uses abstract design of specific tasks to meet the customized needs of different projects. Therefore, in order to manage the loading of dynamically loaded objects in StreamableScene through WorldStreamer, WorldStreamer needs to utilize the following interfaces:
[0089] The interfaces are IAssetLoader, IObjectInstantiator, ILightmapBinder, and IVisibilityController. IAssetLoader is used to load resources, IObjectInstantiator is used to display loaded objects, ILightmapBinder is used to adjust lighting, and IObjectInstantiator is used to control the display or hiding of objects. Except for IAssetLoader, all other interfaces in Infwd2 provide default implementations. Unless there are special requirements, these default implementations can be used directly.
[0090] In one possible implementation, the IAssetLoader interface is defined as follows:
[0091] publicinterfaceIAssetLoader
[0092] {
[0093] IAssetLoadTaskLoadAsync(stringassetPath);
[0094] voidRelease(UnityEngine.Objectasset);
[0095] }
[0096] After loading, WorldStreamer can call WorldStreamer.Update to update the loading status and call TotalTaskCount to check if loading is complete, ensuring that all objects within the user's field of view have been loaded.
[0097] In some instances, when WorldStreamer calls IAssetLoader to load resources (such as dynamically loaded objects), it can call LoadAsync to create an asynchronous asset loading task (AssetLoadTask) and return it to load the resources asynchronously.
[0098] S107. Unload dynamically loaded objects that were loaded before this load. WorldStreamer can call Release to release a specified asset. Therefore, when unloading dynamically loaded objects, WorldStreamer can call Release to release dynamically loaded objects that were loaded before this load, thus completing the unloading of dynamically loaded objects that were loaded before this load.
[0099] After the user's field of vision changes, the above... Figure 1 The process shown can redetermine the dynamically loaded object to be loaded and reload it, offering high flexibility and adapting to the loading needs of complex virtual space scenarios.
[0100] As can be seen from the above technical solution, the data processing method provided in this embodiment, after determining the user's field of view, determines the target node in the preset hierarchical structure that matches the user's field of view based on the preset hierarchical structure data in the resource file of the streaming scene; determines the dynamically loaded object to be loaded based on the identifier of the StreamableObject component recorded in the target node, and determines the dynamically loaded object to be loaded based on the data block represented by the target node and the Datalayer configured for the dynamically loaded object; after obtaining the SLOD resource file of the dynamically loaded object to be loaded, the SLOD resource file of the dynamically loaded object to be loaded is loaded to complete the loading of the dynamically loaded object. Here, the dynamically loaded objects to be loaded are all dynamically loaded objects located in the data block represented by the target node. As long as the target node matches the user's field of view, the loading of the dynamically loaded objects in the data block can be maintained regardless of the distance from the user, thereby reducing the frequency of dynamic loading and unloading and preventing disk I / O and CPU performance bottlenecks caused by frequent dynamic loading and unloading. Furthermore, the SLOD resource file of the dynamically loaded object records the object instance of the dynamically loaded object at the specified SLOD level. Therefore, when loading the dynamically loaded object, only the object instance at its SLOD level needs to be loaded. Only the object instance of the dynamically loaded object at the specified SLOD level is in memory, avoiding the residing of all SLOD level object instances of the dynamically loaded object in memory. This reduces memory usage to a certain extent and can meet the memory management requirements of virtual space scenarios.
[0101] In this embodiment, the process of generating the SLOD resource file of the dynamically loaded object configured in the Datalayer is as follows: Figure 7 As shown, the following steps may be included:
[0102] S201. Obtain the first generation instruction. The first generation instruction is used to generate SLOD resource files for dynamically loaded objects of the Datalayer in batches. That is, multiple SLOD resource files for dynamically loaded objects of the Datalayer can be generated through the first generation instruction.
[0103] S202. In response to the first generation instruction, find all target objects. The target objects are dynamically loaded objects with an added ObjectPartitionComponent component and specified Datalayer and SLOD generation rules. The SLOD generation rules are the generation rules corresponding to the cells of the target objects. The SLOD generation rules are used to specify the SLOD level of the target objects at least.
[0104] like Figure 8 As shown, add an ObjectPartitionComponent to the GameObject that needs to generate SLOD resource files, and specify the Datalayer (such as Building; BigBuilding) and HLODLayer in the ObjectPartitionComponent. HLODLayer is the SLOD generation rule.
[0105] SLOD generation rules include: hierarchy, SLODLayerType, MeshMergeType, and SimplifyMeshQuality. The hierarchy indicates the next layer to be loaded, SLODLayerType indicates the SLOD level, MeshMergeType indicates the mesh merging method, and SimplifyMeshQuality indicates the mesh simplification quality. For example... Figure 9 As shown, configure HLODLayer (SLOD generation rule) in HLODLayerDatas. Figure 9 In this context, the hierarchy is represented by ChildLayerName, indicating the next layer to be loaded. SLODLayerType can be selected from LOD0 to LODlnf, with the selected LODi serving as the SLOD level. MeshMergeType can be selected from Not Merge, Simplify, MergeAndSimplify, and Null, while SimplifyMeshQuality can be entered by the user.
[0106] In this embodiment, the SLOD generation rule is the generation rule corresponding to the cell storing the target object, and the cell settings are as follows: Figure 10 and Figure 11 As shown. In Figure 10In the middle, create a ScenePartition node for the streaming scene, add a ScenePartitionComponent component to the ScenePartition node, and set the WorldPosition and CellSize of the Grid through the ScenePartitionComponent component, such as... Figure 11 As shown.
[0107] In some examples, ObjectPartitionComponents are automatically added to GameObjects in the streaming scene using preset tools; the specific process will not be described further.
[0108] In this embodiment, finding all target objects can be done by either starting the search from the root node specified by the user, or by enabling FindInScene and searching all target objects in the streaming scenario. An example of enabling FindInScene is shown below. Figure 12 As shown, checking "FindInScene Enable" enables FindInScene. When the user clicks "Build," the system receives the first build command, responds to it, and searches for all target objects.
[0109] S203. For any target object, obtain the object instance of the target object at the specified SLOD level according to the SLOD level specified by the target object.
[0110] S204. For any target object, generate the SLOD resource file of the target object based on the target object's Datalayer, the target object's SLOD generation rules, and the object instance of the target object at the specified SLOD level.
[0111] For example, the SLOD resource file of the target object records the target object's Datalayer, the target object's SLOD generation rules, and the object instance of the target object at the specified SLOD level, so as to facilitate loading the target object.
[0112] As can be seen from the above technical solution, after obtaining the first generation instruction, the system responds by searching for all target objects. The target objects are dynamically loaded objects with an added ObjectPartitionComponent and specified DataLayer and SLOD generation rules. The SLOD generation rules are the generation rules corresponding to the cells containing the target objects. Then, based on the target object's DataLayer, the target object's SLOD generation rules, and the object instance of the target object at the specified SLOD level, the SLOD resource file for the target object is generated. Therefore, under the action of the first generation instruction, SLOD resource files for multiple target objects can be generated in batches, achieving batch generation of SOLD resource files. Furthermore, target objects with an ObjectPartitionComponent added to the same cell can share the same HLODLayer, eliminating the need to configure HLODLayer for each target object, reducing manual configuration workload, and improving development efficiency.
[0113] In some examples, the data processing method provided in this embodiment may further include: after generating the SLOD resource file of the target object, encapsulating the SLOD resource file of the target object into a reusable prefab, and recording the storage path of the reusable prefab in the resource file of the streaming scene to reduce repeated export and reduce asset redundancy.
[0114] In some examples, the data processing method provided in this embodiment further includes: encapsulating the shared resources of all target objects into an AssetBundle, and there are no shared resources in the reusable Prefab, thereby avoiding the encapsulation of shared resources in each Prefab and optimizing storage and memory usage.
[0115] The above describes a data processing method provided by an embodiment of this application. The following describes an apparatus for performing the above data processing method.
[0116] Please see Figure 13 , Figure 7 This is a schematic diagram of the structure of a data processing device provided in an embodiment of this application. Figure 13 As shown, the data processing device includes: a first determining module 10, a reading module 20, a second determining module 30, a third determining module 40, an acquiring module 50, and a loading / unloading module 60.
[0117] The first determining module 10 is used to determine the user's field of vision.
[0118] The reading module 20 is used to read preset hierarchical structure data from the resource files of the streaming scene. The streaming scene is a scene in the virtual space scene. The virtual space scene includes a base scene and multiple streaming scenes. The base scene includes non-dynamically loaded global objects, and the streaming scene includes dynamically loaded objects. The dynamically loaded objects have StreamableObject components that can be streamed. The StreamableObject components are configured with Streamable Level of Detail (SLOD). Each SLOD contains object instances at different levels, and the identifier of the StreamableObject component is recorded in a node of the preset hierarchical structure. The node of the preset hierarchical structure represents a data block. The preset hierarchical structure data is used to reconstruct the preset hierarchical structure that records the identifier of the StreamableObject component.
[0119] The second determining module 30 is used to determine the target node in the preset hierarchical structure that matches the user's field of view based on the preset hierarchical structure data.
[0120] The third determining module 40 is used to determine the dynamic loading object to be loaded based on the identifier of the StreamableObject component recorded in the target node, and to determine the dynamic loading object to be loaded based on the data block represented by the target node and the Datalayer configured for the dynamic loading object. The Datalayer is used to indicate the data block to which the dynamic loading object belongs.
[0121] The acquisition module 50 is used to obtain the SLOD resource file of the dynamically loaded object to be loaded based on the storage path of the SLOD resource file of the dynamically loaded object to be loaded in the resource file of the streaming scene. The SLOD resource file of the dynamically loaded object to be loaded records the object instance of the dynamically loaded object at the specified SLOD level.
[0122] The load / unload module 60 is used to load the SLOD resource file of the dynamic object to be loaded in order to complete the loading of the dynamic object to be loaded, and to unload the dynamic object that has been loaded before this loading.
[0123] In one possible implementation, the data processing apparatus may further include: a file generation module for generating SLOD resource files of dynamically loaded objects that configure Datalayer; specifically, the file generation module is used to obtain a first generation instruction; in response to the first generation instruction, search for all target objects, wherein the target objects are dynamically loaded objects with an added ObjectPartitionComponent component and specified Datalayer and SLOD generation rules, and the SLOD generation rules are the generation rules corresponding to the cells storing the target objects, and the SLOD generation rules are used to specify at least the SLOD level of the target objects; for any target object, obtain an object instance of the target object at the specified SLOD level according to the SLOD level specified by the target object; and for any target object, generate an SLOD resource file of the target object according to the Datalayer of the target object, the SLOD generation rules of the target object, and the object instance of the target object at the specified SLOD level.
[0124] In one possible implementation, the SLOD generation rules include: hierarchy, SLODLayerType, MeshMergeType, and SimplifyMeshQuality. The hierarchy indicates the next layer to be loaded, SLODLayerType indicates the SLOD level, MeshMergeType indicates the mesh merging method, and SimplifyMeshQuality indicates the mesh simplification quality.
[0125] In one possible implementation, the data processing device may further include: a file generation module for acquiring a second generation instruction; responding to the second generation instruction to generate a resource file for the streaming scene; the resource file for the streaming scene is used to record the storage path and preset hierarchical structure data of the SLOD resource file of dynamically loaded objects.
[0126] In one possible implementation, the data processing apparatus may further include: an encapsulation module, used to encapsulate the SLOD resource file of the target object into a reusable prefab after generating the SLOD resource file of the target object, wherein the storage path of the reusable prefab is recorded in the resource file of the streaming scene.
[0127] In one possible implementation, the data processing apparatus may further include: an encapsulation module for encapsulating the shared resources of all target objects into an AssetBundle, wherein the reusable Prefab has no shared resources.
[0128] In this embodiment, please refer to the method embodiment for a detailed description of each module in the above data processing device, which will not be repeated here.
[0129] This application also provides an electronic device in its embodiments. (See reference...) Figure 14 The diagram illustrates a structural schematic suitable for implementing the electronic device in the embodiments of this application. The electronic device in the embodiments of this application may include, but is not limited to, fixed terminals such as mobile phones, laptops, PDAs (personal digital assistants), PADs (tablet computers), desktop computers, etc. Figure 14 The electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.
[0130] like Figure 14 As shown, the electronic device may include a processing unit (e.g., a central processing unit, a graphics processing unit, etc.) 301, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 302 or a program loaded from a storage device 308 into a random access memory (RAM) 303. When the electronic device is powered on, the RAM 303 also stores various programs and data required for the operation of the electronic device. The processing unit 301, ROM 302, and RAM 303 are interconnected via a bus 304. An input / output (I / O) interface 305 is also connected to the bus 304. The processing unit 301 can be a processor in the electronic device, and the ROM 302, RAM 303, and storage device 308 can be a memory in the electronic device. The memory is used to store computer programs; the processor is used to execute the computer programs to enable the electronic device to implement any of the data processing methods provided in the embodiments of this application.
[0131] Typically, the following devices can be connected to I / O interface 305: input devices 306 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 307 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 308 including, for example, memory cards, hard drives, etc.; and communication devices 309. Communication device 309 allows electronic devices to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 14 Electronic devices with various devices are shown, but it should be understood that it is not required to implement or have all of the devices shown. More or fewer devices may be implemented or have alternatively.
[0132] This application also provides a computer program product including computer-readable instructions, which, when executed on an electronic device, cause the electronic device to implement any of the data processing methods provided in this application.
[0133] This application also provides a computer-readable storage medium that carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any of the data processing methods provided in this application.
[0134] It should also be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. In addition, in the device embodiment drawings provided in this application, the connection relationship between modules indicates that they have a communication connection, which can be implemented as one or more communication buses or signal lines.
[0135] Through the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware, or it can be implemented by special-purpose hardware including application-specific integrated circuits, special-purpose CPUs, special-purpose memory, special-purpose components, etc. Generally, any function performed by a computer program can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be diverse, such as analog circuits, digital circuits, or special-purpose circuits. However, for this application, software program implementation is more often the preferred implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a readable storage medium, such as a computer floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk, or optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, training equipment, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0136] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product.
[0137] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, training device, or data center to another website, computer, training device, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device or data center that integrates one or more available media. The available media may be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state drives (SSDs)).
Claims
1. A data processing method, characterized in that, include: Determine the user's field of vision; Read preset hierarchical structure data from the resource file of the streaming scene. The streaming scene is a scene in the virtual space scene. The virtual space scene includes a base scene and multiple streaming scenes. The base scene includes non-dynamically loaded global objects. The streaming scenes include dynamically loaded objects. The dynamically loaded objects have StreamableObject components that can be streamed. The StreamableObject components are configured with Streamable Levels of Detail (SLODs). Each SLOD contains object instances at different levels. The identifier of the StreamableObject component is recorded in a node of the preset hierarchical structure. The node of the preset hierarchical structure represents a data block. The preset hierarchical structure data is used to reconstruct the preset hierarchical structure that records the identifier of the StreamableObject component. Based on the preset hierarchical structure data, determine the target node in the preset hierarchical structure that matches the user's field of view; Based on the identifier of the StreamableObject component recorded in the target node, the dynamic loading object to be loaded is determined, and based on the data block represented by the target node and the Datalayer configured for the dynamic loading object, the dynamic loading object to be loaded is determined, wherein the Datalayer is used to indicate the data block to which the dynamic loading object belongs; Based on the storage path of the SLOD resource file of the dynamically loaded object to be loaded in the resource file of the streaming scene, obtain the SLOD resource file of the dynamically loaded object to be loaded. The SLOD resource file of the dynamically loaded object to be loaded records the object instance of the dynamically loaded object at the specified SLOD level. Load the SLOD resource file of the dynamically loaded object to complete the loading of the dynamically loaded object; Unload dynamically loaded objects that were loaded before this load; The process of generating SLOD resource files for dynamically loaded objects configured in Datalayer includes: Obtain the first generation instruction; In response to the first generation instruction, find all target objects. The target objects are dynamically loaded objects with an added ObjectPartitionComponent component and specified Datalayer and SLOD generation rules. The SLOD generation rules are the generation rules corresponding to the cells of the target objects. The SLOD generation rules are at least used to specify the SLOD level of the target objects. For any target object, obtain the object instance of the target object at the specified SLOD level according to the SLOD level specified by the target object; For any target object, generate the SLOD resource file of the target object based on the target object's Datalayer, the target object's SLOD generation rules, and the object instance of the target object at the specified SLOD level.
2. The method according to claim 1, characterized in that, The process of generating resource files for the streaming scene includes: Obtain the second generation instruction; In response to the second generation instruction, a resource file for the streaming scene is generated; the resource file for the streaming scene is used to record the storage path and preset hierarchical structure data of the SLOD resource file of the dynamically loaded object.
3. The method according to claim 1, characterized in that, The method further includes: after generating the SLOD resource file of the target object, encapsulating the SLOD resource file of the target object into a reusable prefab, and recording the storage path of the reusable prefab in the resource file of the streaming scene.
4. The method according to claim 3, characterized in that, The method further includes: encapsulating the shared resources of all target objects into an AssetBundle, wherein the reusable Prefab does not contain the shared resources.
5. The method according to any one of claims 1, 3, and 4, characterized in that, The SLOD generation rules include: hierarchy, SLODLayerType, MeshMergeType, and SimplifyMeshQuality. The hierarchy indicates the next layer to be loaded, the SLODLayerType indicates the SLOD level, the MeshMergeType indicates the mesh merging method, and the SimplifyMeshQuality indicates the mesh simplification quality.
6. A data processing apparatus, characterized in that, include: The first determining module is used to determine the user's field of vision. The reading module is used to read preset hierarchical structure data from the resource files of the streaming scene. The streaming scene is a scene in the virtual space scene. The virtual space scene includes a base scene and multiple streaming scenes. The base scene includes non-dynamically loaded global objects. The streaming scenes include dynamically loaded objects. The dynamically loaded objects have added StreamableObject components that can be streamed. The StreamableObject components are configured with Streamable Levels of Detail (SLODs). Each SLOD contains object instances at different levels. The identifier of the StreamableObject component is recorded in a node of the preset hierarchical structure. The node of the preset hierarchical structure represents a data block. The preset hierarchical structure data is used to reconstruct the preset hierarchical structure that records the identifier of the StreamableObject component. The second determining module is used to determine the target node in the preset hierarchical structure that matches the user's field of view based on the preset hierarchical structure data. The third determining module is used to determine the dynamic loading object to be loaded based on the identifier of the StreamableObject component recorded in the target node, and to determine the dynamic loading object to be loaded based on the data block represented by the target node and the Datalayer configured for the dynamic loading object. The Datalayer is used to indicate the data block to which the dynamic loading object belongs. The acquisition module is used to acquire the SLOD resource file of the dynamically loaded object to be loaded based on the storage path of the SLOD resource file of the dynamically loaded object to be loaded in the resource file of the streaming scene. The SLOD resource file of the dynamically loaded object to be loaded records the object instance of the dynamically loaded object at the specified SLOD level. The loading and unloading module is used to load the SLOD resource file of the dynamic loading object to be loaded in order to complete the loading of the dynamic loading object, and to unload the dynamic loading object that has been loaded before this loading. The process of generating SLOD resource files for dynamically loaded objects configured with Datalayer includes: obtaining a first generation instruction; responding to the first generation instruction, searching for all target objects, wherein the target objects are dynamically loaded objects with an added ObjectPartitionComponent component and specified Datalayer and SLOD generation rules, and the SLOD generation rules are the generation rules corresponding to the cells storing the target objects, and the SLOD generation rules are at least used to specify the SLOD level of the target objects; for any target object, obtaining an object instance of the target object at the specified SLOD level according to the SLOD level specified by the target object; and for any target object, generating the SLOD resource file of the target object according to the Datalayer of the target object, the SLOD generation rules of the target object, and the object instance of the target object at the specified SLOD level.
7. A computer program product, characterized in that, It includes computer-readable instructions that, when executed on an electronic device, cause the electronic device to perform the data processing method as described in any one of claims 1 to 5.
8. An electronic device, characterized in that, It includes at least one processor and a memory connected to the processor, wherein: The memory is used to store computer programs; The processor is used to execute the computer program to enable the electronic device to implement the data processing method as described in any one of claims 1 to 5.
9. A computer storage medium, characterized in that, The storage medium carries one or more computer programs that, when executed by an electronic device, enable the electronic device to implement the data processing method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Resource dynamic loading method and terminal
CN106547599A
Object loading method and device, storage medium and electronic device
CN109523621A