A method for building a path-based asset reference relational database
By registering asset suffix names and maintainers in the game engine and analyzing asset reference relationships in the engine editor, and building an asset reference relation database with a directed and ring graph, the problems of asset mobile and non-uniform format support in the existing technology are solved, and a database system that is extensible and real-time updated is realized.
Patent Information
- Application Number
- CN202411926096.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-25
- Publication Date
- 2025-04-04
AI Technical Summary
The existing path-based asset reference relational database construction method needs to update the pointer of the dependent asset node when the asset is moved or renamed, and does not support non-uniform asset files, which limits the compression optimization and third-party expansion of file data.
When the game engine is started, each functional module obtains the asset registry object and registers the suffix name, and is associated with the asset maintainer; when the engine editor starts, it scans the asset file list, parses the reference relationship, forms a directed and ring graph, builds an asset reference relation database, and monitors the file status and updates the database in real time.
It implements an asset reference relational database system that can be expanded and supports non-uniform asset files. It can update the database in real time when the asset files are moved or renamed, improving the flexibility and efficiency of the database.
Smart Images

Figure CN119759928A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of game development, and in particular to a method for constructing a path-based asset reference relation database. Background Art
[0002] The asset reference relationship database is a very important underlying support tool in the game engine. Based on this tool, asset references can be retrieved when the project is released, thereby removing assets that are not actually used in the project and reducing the size of the final package.
[0003] There are currently two main ways to build an asset reference relational database: one is based on GUID (Globally Unique Identifier), and the other is based on path. Once the asset reference relational database is built, it can provide query services to other modules (with a cost close to O(1)).
[0004] The advantage of the GUID-based solution is that when moving assets, you don't need to update other asset nodes in the database, you only need to update the actual asset path of the asset node. There are two disadvantages: you can't intuitively see which path the GUID points to, you have to go through a query; and you need to solve the potential conflict problem of GUID.
[0005] The advantage of the path-based solution is that the actual asset reference can be directly seen from the path. The disadvantage is that when the asset is moved, the pointer to the asset node that depends on this asset needs to be updated. And most of the path-based solutions are based on the premise of a unified asset file format. This solution based on a unified asset file format has the advantage of a fixed way of parsing asset references, which is easy to implement in code. The disadvantage is that the fixed file format is not conducive to specific compression optimization of file data and third-party extension. Summary of the invention
[0006] In order to solve the defects of the prior art, the purpose of the present invention is to provide a path-based asset reference relational database construction method, which realizes the construction of an asset reference relational database system that is scalable and supports asset files in non-uniform formats.
[0007] In order to achieve the above object, the present invention provides a method for constructing a path-based asset reference relation database, comprising: Start the game engine, and each functional module obtains the asset registry object and registers various suffixes; one suffix corresponds to one asset type, and any of the functional modules allows registration of multiple suffixes; Associating the suffix name registered by each functional module with the asset maintainer provided by it one by one; Start the engine editor, scan the asset file list of a game project, obtain all asset information of the project and perform reference analysis one by one, form a directed cyclic graph in the memory according to all assets and asset reference relationships, and build an asset reference relationship database; the asset reference relationship refers to the reference relationship between various assets; Monitor the status of the asset files of the project, and if the files are moved or renamed, update the asset reference relationship database in real time.
[0008] Furthermore, any asset will correspond to an asset node, and the asset referenced by the asset will also correspond to an asset node. According to all asset nodes and the reference relationship between each asset, a directed cyclic graph is formed in the memory.
[0009] Furthermore, the step of starting the engine editor, scanning an asset file list of a game project, obtaining all asset information of the project and performing reference parsing one by one, forming a directed cyclic graph in the memory according to the assets and asset reference relationships, and constructing an asset reference relationship database further includes: Collect project file lists, including: file name, last modified time of the file; Analyze the list of files referenced by each file; The analysis results are stored in memory as a directed cyclic graph of asset reference relational databases to support external queries; The steps of collecting the project file list and analyzing the file list referenced by each file do not need to be performed every time. By caching the asset reference relationship database to the hard disk, the construction of the asset reference relationship database is optimized in combination with the cached data at the next startup.
[0010] Furthermore, it also includes: Load the cached asset reference database, which records the results of the last build; Collect a list of project files; Compare the collected project file list with the data of the asset reference relationship database. If each file exists in the cached asset reference relationship database and the last modification time of the files is consistent, the cached asset reference relationship database is directly used; if any file is not in the cached asset reference relationship database, or the last modification time of the file is earlier than the latest file last modification time, start the analysis routine to analyze the reference relationship, and form a directed cyclic graph of the analysis results in the memory, and update the asset reference relationship database; when the engine editor exits, save the data of the updated asset reference relationship database to disk for subsequent acceleration.
[0011] Furthermore, it also includes: A file monitoring system is implemented based on the Master File Table of the NTFS file system and the USN journal to query the project file list on the user's hard disk. The file monitoring system runs in an independent process and is resident. Load the cached asset reference database, which records the results of the last build; Using the file monitoring system, collecting a list of project files; Compare the collected project file list with the data of the asset reference relationship database. If each file exists in the cached asset reference relationship database and the last modification time of the files is consistent, the cached asset reference relationship database is directly used; if any file is not in the cached asset reference relationship database, or the last modification time of the file is earlier than the latest file last modification time, start the analysis routine to analyze the reference relationship, and form a directed cyclic graph of the analysis results in the memory, and update the asset reference relationship database; when the engine editor exits, save the data of the updated asset reference relationship database to disk for subsequent acceleration.
[0012] Furthermore, the steps of starting the engine editor, scanning a list of asset files of a game project, obtaining asset information and performing reference resolution one by one further include: parsing the suffix of the asset file, obtaining the asset maintainer corresponding to the suffix name, and calling the virtual interface of the asset maintainer to obtain a list of referenced asset files.
[0013] The method for constructing a path-based asset reference relation database provided by the present invention has the following beneficial effects compared with the prior art: When the game engine is started, each functional module obtains the asset registry object, and associates the asset suffix name registered by each functional module with the asset maintainer provided by the functional module one-to-one; when the engine editor is started, the asset file list of the game project is scanned, all asset information of the project is obtained and referenced and parsed one by one, and a directed cyclic graph is formed in the memory according to the asset and asset reference relationship, and an asset reference relationship database is constructed; the asset file status of the project is monitored, and if the file is moved or renamed, the asset reference relationship database is updated in real time. The construction of an extensible asset reference relationship database system that supports asset files in non-uniform formats is realized, and the database is updated in real time after file movement and renaming is supported.
[0014] Other features and advantages of the present invention will be set forth in the description which follows, and in part will be apparent from the description, or may be learned by practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings: Figure 1 A flow chart of a method for building a path-based asset reference relationship database according to an embodiment of the present invention; Figure 2 A process diagram for optimizing and constructing an asset reference relationship database according to an embodiment of the present invention. DETAILED DESCRIPTION
[0016] The preferred embodiments of the present invention are described below in conjunction with the accompanying drawings. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention.
[0017] Embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present invention. It should be understood that the drawings and embodiments of the present invention are only for exemplary purposes and are not intended to limit the scope of protection of the present invention.
[0018] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0019] It should be noted that the modifications of "one" and "plurality" mentioned in the present invention are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more". "Plurality" should be understood as two or more.
[0020] In an embodiment of the present invention, a method for constructing a path-based asset reference relationship database is provided, the method comprising: starting a game engine, each functional module respectively obtaining an asset registry object and registering assets with various suffix names, any of the functional modules allowing registration of assets with multiple suffix names; associating the asset suffix name registered by each functional module with the asset maintainer provided by it on a one-to-one basis; starting an engine editor, scanning an asset file list of a game project, obtaining all asset information of the project and performing reference parsing one by one, forming a directed cyclic graph in memory according to all assets and asset reference relationships, and constructing an asset reference relationship database; the asset reference relationship refers to the reference relationship between various assets; monitoring the asset file status of the project, and updating the asset reference relationship database in real time if the file is moved or renamed.
[0021] Figure 1 The following is a flow chart of a method for constructing a path-based asset reference relation database according to an embodiment of the present invention. Figure 1 Specific embodiments of the invention are described in detail.
[0022] First, in step 101, the game engine is started, and each functional module obtains an asset registry object and registers various suffixes.
[0023] In the embodiment of the present invention, the asset registry object is the manager of the asset reference relationship (the reference relationship between various assets). The asset registry object includes a mapping table of asset suffixes (asset types) and asset maintainers, an asset file list, and an asset reference relationship database. The asset registry object is responsible for planning the construction process of the asset reference relationship database and providing query services to other modules.
[0024] When the game engine is started, its various functional modules (such as model module, rendering module, animation module, UI module, terrain module, etc.) will obtain the asset registry object by calling the relevant interface (that is, the functional module gets in touch with the asset registry object) and register the suffixes of various asset types, such as texture, model, animation, data table, etc. A functional module can register assets with multiple suffixes, and multiple assets may have mutual reference relationships. For example, a model asset in the model module will reference multiple texture assets in the rendering module, and multiple animation assets in the animation module, and so on.
[0025] Those skilled in the art can understand that the functional modules described in the present invention are not limited to the model modules, rendering modules, animation modules, UI modules, and terrain modules described as examples, and the asset objects are not limited to the assets such as textures, models, animations, and data tables described as examples, that is, the present invention does not limit this.
[0026] In step 102, after each functional module obtains the asset registration table object, it associates its registered suffix name with the asset maintainer provided by the functional module one-to-one.
[0027] In the embodiment of the present invention, each functional module binds its registered asset suffix name with the asset maintainer it provides, and then a corresponding asset maintainer can be obtained through a suffix name. A functional module can provide multiple asset maintainers, each of which corresponds to a suffix name, and then the reference relationship of a certain asset can be obtained by calling the relevant interface of the asset maintainer corresponding to the specific suffix name, and the update of the reference relationship after the asset is moved can be processed.
[0028] In the embodiment of the present invention, each functional module only registers an asset type with one or more suffixes, and associates the asset type with the suffix with the asset maintainer it provides. Then, the asset registry object scans the resource file directory of the project (obtains the asset file list, see step 103). After the asset registry object obtains the asset file list, it traverses the list, obtains the suffix of the asset file for each asset file, finds the corresponding asset maintainer through the suffix, and then analyzes the asset reference relationship through the asset maintainer. The asset registry object builds an asset reference database in memory based on the results returned by the asset maintainer.
[0029] In step 103, the engine editor is started, the asset file list of the project is scanned, the asset information is obtained and references are parsed one by one, a directed cyclic graph is formed in the memory according to the assets and asset reference relationships, and then an asset reference relationship database is constructed.
[0030] In an embodiment of the present invention, for a game project, when the engine editor is started, it scans the asset file list of the entire project through the asset registry object, obtains asset information (by calling the relevant interface of the asset maintainer corresponding to the file suffix name to obtain the referenced asset file list), and parses the obtained asset information one by one to analyze the reference relationship of the assets.
[0031] According to the parsing results, a directed cyclic graph (a data structure) is formed in the memory. For example, a model asset will correspond to an asset node. This model asset may reference multiple texture assets and multiple animation assets. Here, each texture asset or animation asset corresponds to an asset node. According to all asset nodes and the reference relationship between assets, a directed cyclic graph can be constructed in the memory to form an asset reference relationship database. After the asset reference relationship database is constructed, query services can be provided for various functional modules, such as querying which assets a certain asset references or querying which assets a certain asset is referenced by. With such an asset reference relationship database, it is also easy to query which assets a certain asset is referenced by.
[0032] In step 104, the file changes in the project asset folder are monitored, and if the file is moved or renamed, the asset reference relationship database is updated in real time.
[0033] In the embodiments of the present invention, the game engine, the engine editor, and the asset maintainer play their own unique roles in game development, and there is a close connection and collaborative relationship between them: Game engine: It is the core of game development. It is a collection of tools and libraries used to handle various tasks in game development, such as graphics rendering, physics simulation, audio processing, input management, etc.
[0034] Engine Editor: It is a tool closely related to the game engine, which provides developers with an intuitive working environment for creating, editing and testing game content. The functions of the engine editor include scene editing, script editing, animation editing, lighting and material editing, terrain editing, UI editing, etc., allowing developers to more conveniently build and adjust the game world without having to deeply understand the underlying code.
[0035] Asset maintainer: It is part of the game engine and editor suite and is responsible for managing various assets in the game, such as 3D models, textures, audio files, etc. The asset maintainer is responsible for analyzing the dependencies of a certain type of asset with other assets, responding to reference updates when dependent assets are moved or renamed, packaging assets that can be delivered to the game build, etc. Its purpose is to ensure effective management and fast access to game assets, thereby improving development efficiency and game performance.
[0036] The path-based asset reference database construction method of the present invention takes into account scalability and file optimization, constructs an asset reference relationship database based on file paths, can support different file formats, and third-party developers can add custom asset file formats, and supports real-time file movement and database updates after renaming.
[0037] In the embodiment of the present invention, in order to accelerate the construction of the asset reference relationship database, the above step 103 further includes steps a1 to c1, as follows: a1: Collect the project file list (including file name and last modification time).
[0038] b1: Analyze the referenced file list of each file.
[0039] c1: The analysis results are stored in memory as a directed cyclic graph of asset reference relational databases to support external queries.
[0040] Among them, step a1 and step b1 do not need to be done every time. Therefore, the asset reference relationship database can be cached to the hard disk, and the cached data can be combined to optimize the database construction at the next startup. The steps after adding this optimization are as follows: a2: Load the asset reference relationship database cache (if it exists). The asset reference relationship database cache records the results of the last build (such as the last modification time of the file and the list of referenced files).
[0041] b2: Collect the project file list (including file name and file last modified date), which may be inconsistent with the cached result of the asset reference relationship database. Compare the collected project file list with the data of the asset reference relationship database. If all the files of the project are in the asset reference relationship database cache and the last modified time of the files is consistent, the cached result can be used directly. If any file is not in the asset reference relationship database cache, or the last modified time of the file in the asset reference relationship database cache is earlier than the latest file last modified time, start the analysis routine to analyze the reference relationship.
[0042] c2: The analysis results are stored in memory as a directed cyclic graph of asset reference relational databases to support external queries.
[0043] d2: When the engine exits, the data in the asset reference relational database is saved to the hard disk for subsequent acceleration use.
[0044] In the case of a large file size or when a mechanical hard disk is used, step b2 still takes a long time. Therefore, a new optimization method is proposed in the embodiment of the present invention, which can greatly speed up the information collection process of asset files, thereby speeding up the construction of the asset reference relationship database. Figure 2 The following is a process diagram of optimizing and constructing an asset reference relationship database according to an embodiment of the present invention. Figure 2 The optimization method is described in detail.
[0045] First, a file monitoring system is implemented based on the Master File Table (MTF) of the NTFS (New Technology File System) file system and the USN journal to analyze the file list on the user's hard disk (because only a small amount of data is read, the speed is very fast). The file monitoring system runs in an independent process and is resident, and can provide cross-process query services to the outside world, such as Figure 2 shown.
[0046] In the embodiment of the present invention, the MFT (Master File Table) is a key component in the NTFS file system, which contains the metadata of all files and folders on the volume. The USN Journal (Update Sequence Number Journal), also known as the Change Journal, is used to record the information of file modifications in the NTFS volume, which can improve the efficiency of searching for files.
[0047] Continue to refer Figure 2 , the process of the engine editor is as follows: b3: Load the asset reference database cache (if it exists), which records the results of the last build (such as the last modification time of the file and the list of referenced files).
[0048] c3: Use the provided file monitoring system to query and collect the project file list (file name, file last modified date), which may be inconsistent with the cached result of the asset reference relationship database. Compare the collected project file list with the data of the asset reference relationship database. If each file exists in the asset reference relationship database cache and the file last modified time is consistent, the cached result is used directly. If the asset reference relationship database cache does not exist or the file last modified time in the cache is earlier than the latest file last modified time, start the analysis routine to analyze the reference relationship (parse the suffix of the asset file, obtain the asset maintainer corresponding to the suffix name, and call the virtual interface of the asset maintainer to obtain the referenced asset file list, and build the asset node in memory).
[0049] d3: The analysis results are stored in memory as a directed cyclic graph of asset reference databases to support external queries.
[0050] e3: When the engine exits, the data in the asset reference relational database is saved to the hard disk for subsequent acceleration use.
[0051] In the embodiments of the present invention, an accelerated optimization method is provided to solve the problems of time-consuming and low efficiency of existing solutions when facing a large number of files in the file information collection stage. Because both existing solutions will scan the project folder when the engine starts to collect file information. In the later stages of project development, the number of files will be very large, which is a very time-consuming process. Compared with the prior art, the present invention, based on the optimization method as described above, can greatly accelerate the asset file information collection process, thereby accelerating the construction of the asset reference relationship database.
[0052] Those skilled in the art can understand that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention is described in detail with reference to the aforementioned embodiments, those skilled in the art can still modify the technical solutions recorded in the aforementioned embodiments or replace some of the technical features therein by equivalents. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for constructing a path-based asset reference relation database, characterized in that: include: Start the game engine, and each functional module obtains the asset registry object and registers various suffixes; one suffix corresponds to one asset type, and any of the functional modules allows registration of multiple suffixes; Associating the suffix name registered by each functional module with the asset maintainer provided by it one by one; Start the engine editor, scan the asset file list of a game project, obtain all asset information of the project and perform reference analysis one by one, form a directed cyclic graph in the memory according to all assets and asset reference relationships, and build an asset reference relationship database; the asset reference relationship refers to the reference relationship between various assets; Monitor the status of the asset files of the project, and if the files are moved or renamed, update the asset reference relationship database in real time.
2. The method for constructing a path-based asset reference relation database according to claim 1, characterized in that: Each asset will correspond to an asset node, and the asset referenced by the asset will also correspond to an asset node. Based on all asset nodes and the reference relationship between each asset, a directed cyclic graph is formed in the memory.
3. The method for constructing a path-based asset reference relation database according to claim 1, characterized in that: The step of starting the engine editor, scanning the asset file list of a game project, obtaining all asset information of the project and performing reference analysis one by one, forming a directed cyclic graph in the memory according to the assets and asset reference relationships, and constructing an asset reference relationship database further includes: Collect project file lists, including: file name, last modified time of the file; Analyze the list of files referenced by each file; The analysis results are stored in memory as a directed cyclic graph of asset reference relational databases to support external queries; The steps of collecting the project file list and analyzing the file list referenced by each file do not need to be performed every time. By caching the asset reference relationship database to the hard disk, the construction of the asset reference relationship database is optimized in combination with the cached data at the next startup.
4. The method for constructing a path-based asset reference relation database according to claim 1, characterized in that: Also includes: The engine editor loads a cached database of asset reference relationships that records the results of the last build; Collect a list of project files; Compare the collected project file list with the data of the asset reference relationship database. If each file exists in the cached asset reference relationship database and the last modification time of the files is consistent, the cached asset reference relationship database is directly used; if any file is not in the cached asset reference relationship database, or the last modification time of the file is earlier than the latest file last modification time, start the analysis routine to analyze the reference relationship, and form a directed cyclic graph of the analysis results in the memory, and update the asset reference relationship database; when the engine editor exits, save the data of the updated asset reference relationship database to disk for subsequent acceleration.
5. The method for constructing a path-based asset reference relation database according to claim 1, characterized in that: Also includes: A file monitoring system is implemented based on the Master File Table of the NTFS file system and the USN journal to query the project file list on the user's hard disk. The file monitoring system runs in an independent process and is resident. The engine editor loads a cached database of asset reference relationships that records the results of the last build; Using the file monitoring system, collecting a list of project files; Compare the collected project file list with the data of the asset reference relationship database. If each file exists in the cached asset reference relationship database and the last modification time of the files is consistent, the cached asset reference relationship database is directly used; if any file is not in the cached asset reference relationship database, or the last modification time of the file is earlier than the latest file last modification time, start the analysis routine to analyze the reference relationship, and form a directed cyclic graph of the analysis results in the memory, and update the asset reference relationship database; when the engine editor exits, save the data of the updated asset reference relationship database to disk for subsequent acceleration.
6. The method for constructing a path-based asset reference relation database according to claim 1, characterized in that: The steps of starting the engine editor, scanning a list of asset files of a game project, obtaining asset information and performing reference resolution one by one further include: parsing the suffix of the asset file, obtaining the asset maintainer corresponding to the suffix name, and calling the virtual interface of the asset maintainer to obtain the referenced asset file list.