Particle system storage and reading method, device, electronic device and storage medium
By obtaining and processing the node array of the particle tree in the particle system storage method and storing it in an appropriate file, the problem of waste of storage space in the prior art is solved, and more efficient storage space utilization is achieved.
Patent Information
- Application Number
- CN202111646024.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-30
- Publication Date
- 2025-04-22
- Estimated Expiration
- 2041-12-30
AI Technical Summary
The existing particle system storage method fails to effectively utilize the common relationship between each node, resulting in wasted storage space.
By obtaining the particle system set to be stored, the node array corresponding to each node in each particle tree is obtained in a preset order, and the number of nodes, content data and node array are stored in the corresponding file. According to the order of the node array, node attributes are written to caches of different data types and stored in the second file in binary form.
It effectively saves the space share of the particle system, eliminates small-scoped data through multi-type array cache, and stores particle nodes of type in different files.
Smart Images

Figure CN114416732B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data storage, and in particular to a particle system storage and reading method, device, electronic equipment and storage medium. Background Art
[0002] The particle system is a tree structure composed of particle objects and particle update strategy objects. The existing technology takes objects as units, starting from the root node of the particle tree and going down to the leaf nodes. Each node stores its own attributes and child node relationships in binary.
[0003] The existing particle system storage method does not store the common relationship between nodes, but stores the same mode for each particle, which takes up a lot of storage space and causes space waste. Summary of the invention
[0004] In order to solve the above technical problems, the embodiments of the present application provide a particle system storage and reading method, device, electronic device and storage medium, and the specific scheme is as follows:
[0005] In a first aspect, an embodiment of the present application provides a particle system storage method, the particle system storage method comprising:
[0006] Acquire a particle system set to be stored, wherein the particle system set to be stored includes a preset number of particle trees;
[0007] Obtaining a node array corresponding to each node in each particle tree in a preset order, wherein the node array includes a node type and a parent node index, and the node is a particle object or an update strategy object;
[0008] The number of nodes, content data of the nodes and node array corresponding to each particle tree are stored in a corresponding first file;
[0009] According to the relationship between the actual scopes of different attributes and the caches of different data types, the attributes of the nodes are sequentially written into the caches of different data types according to the order of the node array;
[0010] The attributes of all nodes corresponding to a particle tree in each cache are stored in a corresponding second file in binary form.
[0011] According to a specific implementation of the embodiment of the present application, the step of obtaining a node array corresponding to each node in each particle tree in a preset order includes:
[0012] Traversing the particle tree from the root node of the particle tree, and numbering each node in the particle tree according to a preset order, wherein the preset order is from the root node to the leaf node, and from the left leaf node to the right leaf node;
[0013] Get the node type and parent node index of each node to combine and generate the node array corresponding to each node.
[0014] According to a specific implementation of the embodiment of the present application, the update policy object includes a first update policy and a second update policy, wherein the first update policy is an update policy with a time series, and the second update policy is an update policy without a time series;
[0015] After the step of obtaining the node array corresponding to each node in each particle tree in a preset order, the method further includes:
[0016] The time series of all first update strategies of the particle system set to be stored are stored in a data pool, and the time series in the content data of each first update strategy is replaced by the corresponding time series index in the data pool;
[0017] The data pool is stored in a third file in binary form.
[0018] According to a specific implementation of the embodiment of the present application, the data pool manages all first update strategies in the data pool based on a vector container.
[0019] In a second aspect, an embodiment of the present application provides a particle system reading method, the particle system reading method comprising:
[0020] Get the identification information of the particle tree to be read;
[0021] Obtaining all nodes and all node arrays having an order from a first file corresponding to the identification information of the particle tree to be read;
[0022] Acquire a preset number of caches from a second file of identification information corresponding to the particle tree to be read;
[0023] The attributes corresponding to each node array are extracted from different types of caches according to the order of the node arrays, so as to form a target particle tree according to all the nodes, all the node arrays with order and the attributes corresponding to each node array.
[0024] According to a specific implementation of the embodiment of the present application, after extracting the attributes corresponding to each node array from different types of caches in the order of the node arrays, and forming a target particle tree according to all the nodes, all the node arrays in order, and the attributes corresponding to each node array, the method further includes:
[0025] Obtain a data pool storing time series from a third file;
[0026] The time series in the data pool is accessed according to the time series index in the node.
[0027] In a third aspect, an embodiment of the present application provides a particle system storage device, the particle system storage device comprising:
[0028] A first acquisition module is used to acquire a particle system set to be stored, wherein the particle system set to be stored includes a preset number of particle trees;
[0029] A second acquisition module is used to acquire a node array corresponding to each node in each particle tree in a preset order, wherein the node array includes a node type and a parent node index, and the node is a particle object or an update strategy object;
[0030] A first storage module is used to store the number of nodes, content data of the nodes and the node array corresponding to each particle tree in a corresponding first file;
[0031] A writing module, used for writing the attributes of the nodes into the caches of different data types in sequence according to the order of the node array according to the relationship between the actual scopes of the different attributes and the caches of different data types;
[0032] The second storage module is used to store the attributes of all nodes corresponding to a particle tree in each cache in a binary form in a corresponding second file.
[0033] In a fourth aspect, an embodiment of the present application provides a particle system reading device, the particle system reading device comprising:
[0034] An acquisition module is used to acquire identification information of a particle tree to be read;
[0035] A first reading module, used for acquiring all nodes and all node arrays having an order from a first file corresponding to the identification information of the particle tree to be read;
[0036] A second reading module is used to obtain a preset number of caches from a second file of identification information corresponding to the particle tree to be read;
[0037] The composition module is used to extract the attributes corresponding to each node array from different types of caches according to the order of the node arrays, so as to compose a target particle tree according to all the nodes, all the node arrays with order and the attributes corresponding to each node array.
[0038] In a fifth aspect, an embodiment of the present application provides an electronic device, comprising a processor and a memory, wherein the memory stores a computer program, and when the computer program runs on the processor, it executes the particle system storage method described in the first aspect and the particle system reading method described in the second aspect.
[0039] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer program is run on a processor, the particle system storage method described in the first aspect and the particle system reading method described in the second aspect are executed.
[0040] The embodiment of the present application provides a particle system storage and reading method, device, electronic device and storage medium, the particle system storage method includes: obtaining a particle system set to be stored, the particle system set to be stored includes a preset number of particle trees; obtaining a node array corresponding to each node in each particle tree in a preset order, wherein the node array includes a node type and a parent node index, and the node is a particle object or an update strategy object; storing the number of nodes corresponding to each particle tree, the content data of the node and the node array in a corresponding first file; according to the relationship between the actual scope of different attributes and the cache of different data types, the attributes of the node are sequentially written into the cache of different data types according to the order of the node array; the attributes of all nodes corresponding to a particle tree in each cache are stored in binary form in a corresponding second file. The particle system storage and reading method in the embodiment of the present application eliminates small scope data based on multi-type array cache, and stores particle nodes in different files by type, thereby effectively saving the space share of storing particle systems. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solution of the present invention, the following is a brief introduction to the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and should not be regarded as limiting the scope of protection of the present invention. In each of the drawings, similar components are numbered similarly.
[0042] Figure 1 A schematic diagram of a method flow of a particle system storage method provided by an embodiment of the present application is shown;
[0043] Figure 2 A schematic diagram showing the structure of a particle tree of a particle system storage method provided in an embodiment of the present application is shown;
[0044] Figure 3 A schematic diagram of a method flow of a particle system reading method provided by an embodiment of the present application is shown;
[0045] Figure 4 A schematic diagram of a device module of a particle system storage device provided by an embodiment of the present application is shown;
[0046] Figure 5 A schematic diagram of a device module of a particle system reading device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0047] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments.
[0048] The components of the embodiments of the present invention generally described and shown in the drawings herein may be arranged and designed in a variety of different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0049] Hereinafter, the terms "including", "having" and their cognates, which may be used in various embodiments of the present invention, are intended only to indicate specific features, numbers, steps, operations, elements, components or combinations of the foregoing items, and should not be understood as first excluding the existence of one or more other features, numbers, steps, operations, elements, components or combinations of the foregoing items or adding the possibility of one or more features, numbers, steps, operations, elements, components or combinations of the foregoing items.
[0050] Furthermore, the terms “first”, “second”, “third”, etc. are merely used for distinguishing descriptions and are not to be understood as indicating or implying relative importance.
[0051] Unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meanings as those generally understood by those skilled in the art to which the various embodiments of the present invention belong. The terms (such as those defined in generally used dictionaries) will be interpreted as having the same meanings as the contextual meanings in the relevant technical field and will not be interpreted as having idealized meanings or overly formal meanings unless clearly defined in the various embodiments of the present invention.
[0052] refer to Figure 1 , is a schematic diagram of a method flow of a particle system storage method provided in an embodiment of the present application. The particle system storage method provided in an embodiment of the present application is as follows: Figure 1 As shown, the particle system storage method includes:
[0053] Step S101, obtaining a particle system set to be stored, wherein the particle system set to be stored includes a preset number of particle trees;
[0054] In a specific embodiment, a large number of particle systems are required to work together to achieve the rendering of an element effect, wherein the element effect includes flames, water flow, falling leaves, clouds, etc.
[0055] The particle system set to be stored includes all particle systems required to realize one or more element effects, specifically, Figure 2 As shown, the particle system includes a preset number of particle objects and a preset number of update strategy objects, and the particle objects and the update strategy objects form a tree structure.
[0056] In this embodiment, each particle system corresponds to a particle tree.
[0057] Step S102, obtaining a node array corresponding to each node in each particle tree in a preset order, wherein the node array includes a node type and a parent node index, and the node is a particle object or an update strategy object;
[0058] In a specific embodiment, after obtaining the particle system set to be stored, a traversal operation is performed for each particle system in the particle system set to determine the node type and parent node index of each node in the corresponding particle system. The node type and parent node index of the corresponding node are combined into a node array, and the node array is stored in the data content of the node. Among them, the field indicating the node type occupies 2 bytes, the field indicating the parent node index occupies 2 bytes, and a complete node array occupies 4 bytes.
[0059] Specifically, in the process of traversing each particle system, the number of nodes detected after traversing a complete particle system is recorded, and the number of nodes is stored in the data content of the corresponding node, wherein the field indicating the number of nodes occupies 4 bytes.
[0060] Each particle system set to be stored includes multiple particle systems, that is, multiple particle tree structures. When traversing each particle tree structure, the root node of each particle tree structure is marked to indicate the particle system composition of the particle system set to be stored. When reading the stored particle system set, the corresponding particle tree structure can be identified according to the pre-marked root node serial number and the number of nodes of the particle tree.
[0061] According to a specific implementation of the embodiment of the present application, the step of obtaining a node array corresponding to each node in each particle tree in a preset order includes:
[0062] Traversing the particle tree from the root node of the particle tree, and numbering each node in the particle tree according to a preset order, wherein the preset order is from the root node to the leaf node, and from the left leaf node to the right leaf node;
[0063] Get the node type and parent node index of each node to combine and generate the node array corresponding to each node.
[0064] In a specific embodiment, Figure 2 As shown, when traversing the particle tree, the traversal starts from the root node, and each traversed node is labeled, so as to obtain the labeling order of each particle tree node.
[0065] During the specific traversal process, the node type and parent node index of each node will be obtained. For example, when the storage device traverses to node 13, the node type of the 13th node will be obtained as particle 13, and the parent node index will be the 9th node; when traversing to node 14, the node type of the 14th node will be obtained as update strategy 14, and the parent node index will be the 9th node.
[0066] After obtaining the node type and parent node index of node 13, the node type and parent node index are combined to form a corresponding node array (particle 13, node 9). Specifically, the node type will be converted into a corresponding enumeration variable for storage during actual use.
[0067] Specifically, during the traversal process, the traversal is performed according to the extension direction of the leaf nodes of the particle tree structure, that is, the traversal is performed from the root node to the leaf node, and for the leaf nodes of the same layer, the traversal is performed from the left leaf node to the right leaf node.
[0068] According to a specific implementation of the embodiment of the present application, the update policy object includes a first update policy and a second update policy, wherein the first update policy is an update policy with a time series, and the second update policy is an update policy without a time series;
[0069] After the step of obtaining the node array corresponding to each node in each particle tree in a preset order, the method further includes:
[0070] The time series of all first update strategies of the particle system set to be stored are stored in a data pool, and the time series in the content data of each first update strategy is replaced by the corresponding time series index in the data pool;
[0071] The data pool is stored in a third file in binary form.
[0072] In a specific embodiment, the update strategy includes two types of data, namely a first update strategy with a time series and a second update strategy without a time series. The storage space range occupied by the second update strategy is fixed, and the storage space range occupied by the first update strategy changes according to the set time series.
[0073] The time series is set by corresponding technicians, has a large amount of repetitive time and occupies a large amount of space.
[0074] When storing the particle tree structure in the particle system set to be stored, the particle system storage device will store the time series of all first update strategies in a unified data pool during the process of traversing each particle tree structure, and store the time series index provided by the corresponding data pool in the content data of the original node.
[0075] By replacing the time series in each first update strategy with a time series index, the storage space occupied by the node content data corresponding to the first update strategy can be greatly reduced. For example, the storage space occupied by the time series is 64 bytes, and the storage space occupied by the time series index is 2 bytes.
[0076] In addition, according to a specific implementation of the embodiment of the present application, the data pool manages all first update strategies in the data pool based on a vector container.
[0077] In a specific embodiment, the vector container can store all time series in the particle system set to be stored, and can record multiple time nodes in the time series corresponding to each first update strategy. For the same parts between different time series, the vector can only store one same time file.
[0078] When calling the corresponding target time series from the vector container, the same time series part may be obtained first, and then the corresponding time nodes may be obtained to form a completed target time series.
[0079] After storing the time series of all first update strategies in the particle system set to be stored in the data pool, the data pool is written into a separate third file in binary form, thereby completing the space saving for the data content of each node and the space saving for the data pool.
[0080] Step S103, storing the number of nodes, content data of the nodes and the node array corresponding to each particle tree in a corresponding first file;
[0081] In a specific embodiment, the number of the first files may be one or more. The number of the first files is determined according to the number of particle trees in the particle system set to be stored, and each particle tree is stored in a corresponding first file.
[0082] After executing the traversal action for each particle tree in the above embodiment, the obtained number of nodes of the particle tree, the content data of the nodes and the node array of all nodes in the corresponding particle tree are stored in a first file.
[0083] Step S104, according to the relationship between the actual scopes of different attributes and the caches of different data types, the attributes of the nodes are sequentially written into the caches of different data types according to the order of the node array;
[0084] In a specific embodiment, arrays of different data types are set in advance as caches for storing node attributes, such as 11-bit Buffer, 4-bit Buffer, 8-bit Buffer, 16-bit Buffer, and 32-bit Buffer.
[0085] When storing the attributes of each node in the same particle tree, the attributes of the nodes are written into the corresponding cache according to the order of the node arrays according to the relationship between the actual scope and the caches of different data types.
[0086] Specifically, the program code for writing the attributes of the node into the corresponding cache according to the actual scope can be:
[0087]
[0088]
[0089]
[0090] It should be noted that the above codes are used to indicate that the attribute data corresponding to the node is written into different types of caches according to the actual scope of the attribute. Different codes may be used in actual operation, which is not limited here.
[0091] Step S105: Store the attributes of all nodes corresponding to a particle tree in each cache in a binary form in a corresponding second file.
[0092] In a specific embodiment, the number of the second files may be one or more. The number of the second files is determined according to the number of particle trees in the particle system set to be stored, and is not limited here.
[0093] All node attributes corresponding to each particle tree in the particle system data set to be stored are respectively stored in a separate second file.
[0094] The data space occupied by all node attributes of each cache and a particle tree in the cache is compactly stored in binary form, thereby preventing waste of data space.
[0095] Through the particle system storage method of this embodiment, the storage space occupied by the particle system can be reduced to the greatest extent, so that when using the particle system for rendering, as many particle systems as possible can be read to improve the rendering efficiency of the particle effect.
[0096] refer to Figure 3 , is a method flow diagram of a particle system reading method provided in an embodiment of the present application. The particle system reading method provided in an embodiment of the present application is as follows: Figure 3 As shown, the particle system reading includes:
[0097] Step S301, obtaining identification information of the particle tree to be read;
[0098] In a specific embodiment, when it is necessary to use the particle system data set stored in the above embodiment to perform particle effect rendering, the identification information of the particle tree to be read corresponding to the particle effect to be realized can be obtained from the particle effect to be realized.
[0099] Specifically, the identification information of the particle tree to be read includes the label sequence of the root nodes of the particle tree and the node quantity information of the corresponding particle tree. It should be noted that the setting of the identification information can also be adaptively set according to the existing particle system calling method, which will not be described in detail here.
[0100] Step S302, obtaining all nodes and all node arrays in order from a first file corresponding to the identification information of the particle tree to be read;
[0101] In a specific embodiment, when reading the corresponding particle tree, the corresponding first file is first searched according to the identification information, and all nodes and all node arrays with order are obtained from the first file. Among them, all nodes include content data of the nodes, and the content data includes a time series index.
[0102] According to the order of the node array, the particle system can be rearranged according to the tree structure of the particle tree, thereby restoring the stored particle tree structure.
[0103] Step S303, obtaining a preset number of caches from a second file of identification information corresponding to the particle tree to be read;
[0104] In a specific embodiment, after reading the tree structure of the particle tree, the corresponding second file is searched according to the identification information, and different types of cache are extracted from the second file.
[0105] Step S304, extracting the attributes corresponding to each node array from different types of caches according to the order of the node arrays, so as to form a target particle tree according to all the nodes, all the node arrays with order and the attributes corresponding to each node array.
[0106] In a specific embodiment, after extracting different types of cache from the second file, it is necessary to extract the attributes corresponding to each node from the different types of cache according to the order of the node array obtained in the above embodiment, and combine the node attributes with each node in the particle tree structure to obtain the particle tree stored in the first file and the second file.
[0107] According to a specific implementation of the embodiment of the present application, in the process of restoring the content data of each node in the particle tree, the corresponding time series can also be found from the third file in the above embodiment according to the time series index stored in each node in the particle tree, thereby restoring the content data of the particle tree with the update strategy of the time series.
[0108] According to a specific implementation of the embodiment of the present application, after extracting the attributes corresponding to each node array from different types of caches in the order of the node arrays, and forming a target particle tree according to all the nodes, all the node arrays in order, and the attributes corresponding to each node array, the method further includes:
[0109] Obtain a data pool storing time series from a third file;
[0110] The time series in the data pool is accessed according to the time series index in the node.
[0111] In a specific embodiment, according to the time series in the content data of each node of the particle tree, the corresponding data pool can be called from the third file in real time, and the pre-stored time series can be restored from the data pool.
[0112] Through the above-mentioned particle system reading method, it is possible to achieve the maximum saving of particle system storage space while ensuring the reversibility of the storage content, thereby ensuring the stability of particle effect rendering according to the particle system stored in the above-mentioned embodiment and improving the efficiency of particle system rendering.
[0113] refer to Figure 4 , is a module diagram of a particle system storage device 400 provided in an embodiment of the present application, a particle system storage device 400 provided in an embodiment of the present application, such as Figure 4 As shown, the particle system storage device 400 includes:
[0114] A first acquisition module 401 is used to acquire a particle system set to be stored, wherein the particle system set to be stored includes a preset number of particle trees;
[0115] The second acquisition module 402 is used to acquire a node array corresponding to each node in each particle tree according to a preset order, wherein the node array includes a node type and a parent node index, and the node is a particle object or an update strategy object;
[0116] The first storage module 403 is used to store the number of nodes, content data of the nodes and the node array corresponding to each particle tree in a corresponding first file;
[0117] A writing module 404 is used to write the attributes of the nodes into the caches of different data types in sequence according to the order of the node array according to the relationship between the actual scopes of the different attributes and the caches of different data types;
[0118] The second storage module 405 is used to store the attributes of all nodes corresponding to a particle tree in each cache in a binary form in a corresponding second file.
[0119] refer to Figure 5 , is a module diagram of a particle system reading device 500 provided in an embodiment of the present application, a particle system reading device 500 provided in an embodiment of the present application, such as Figure 5 As shown, the particle system reading device 500 includes:
[0120] An acquisition module 501 is used to acquire identification information of a particle tree to be read;
[0121] A first reading module 502 is used to obtain all nodes and all node arrays with order from a first file corresponding to the identification information of the particle tree to be read;
[0122] A second reading module 503 is used to obtain a preset number of caches from a second file of identification information corresponding to the particle tree to be read;
[0123] The composition module 504 is used to extract the attributes corresponding to each node array from different types of caches according to the order of the node arrays, so as to compose a target particle tree according to all the nodes, all the node arrays with order and the attributes corresponding to each node array.
[0124] In addition, an embodiment of the present application further provides an electronic device, which includes a processor and a memory, wherein the memory stores a computer program, and when the computer program runs on the processor, the particle system storage method and the particle system reading method in the above embodiments are executed.
[0125] An embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer program is run on a processor, the particle system storage method and the particle system reading method in the above embodiment are executed.
[0126] In summary, the embodiments of the present application provide a particle system storage and reading method, device, electronic device and storage medium. Through the particle system storage method and particle system reading method provided by the present application, the original binary particle system data of tens of megabytes can be compressed to less than ten megabytes, thereby greatly saving the storage space for storing the particle system. Through the setting of the first file, the second file and the third file, large space duplicate data is eliminated, and small scope data is also eliminated at the same time, thereby ensuring the storage effect of the particle system. Through the reversible particle system reading method, more particle systems can be rendered as much as possible when rendering particle effects, thereby improving the rendering efficiency of particle effects. In addition, the specific implementation process of the particle system storage device, particle system reading device, electronic device and computer-readable storage medium mentioned in the above embodiments can refer to the specific implementation process of the above method embodiment, which will not be repeated here.
[0127] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and structure diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in an alternative implementation, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the structure diagram and / or the flow chart, and the combination of boxes in the structure diagram and / or the flow chart, can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0128] In addition, the functional modules or units in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.
[0129] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a smart phone, a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0130] The above description is only a specific implementation mode of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.
Claims
1. A particle system storage method, characterized in that: The particle system storage method comprises: Acquire a particle system set to be stored, wherein the particle system set to be stored includes a preset number of particle trees; Obtaining a node array corresponding to each node in each particle tree in a preset order, wherein the node array includes a node type and a parent node index, the node is a particle object or an update strategy object, the update strategy object includes a first update strategy and a second update strategy, the first update strategy is an update strategy with a time series, and the second update strategy is an update strategy without a time series; The number of nodes, content data of the nodes and node array corresponding to each particle tree are stored in a corresponding first file; According to the relationship between the actual scopes of different attributes and the caches of different data types, the attributes of the nodes are sequentially written into the caches of different data types according to the order of the node array; The attributes of all nodes corresponding to a particle tree in each cache are stored in a corresponding second file in binary form.
2. The particle system storage method according to claim 1, characterized in that: The step of obtaining the node array corresponding to each node in each particle tree according to a preset order includes: Traversing the particle tree from the root node of the particle tree, and numbering each node in the particle tree according to a preset order, wherein the preset order is from the root node to the leaf node, and from the left leaf node to the right leaf node; Get the node type and parent node index of each node to combine and generate the node array corresponding to each node.
3. The particle system storage method according to claim 1, characterized in that: After the step of obtaining the node array corresponding to each node in each particle tree in a preset order, the method further includes: The time series of all first update strategies of the particle system set to be stored are stored in a data pool, and the time series in the content data of each first update strategy is replaced by the corresponding time series index in the data pool; The data pool is stored in a third file in binary form.
4. The particle system storage method according to claim 3, characterized in that: The data pool manages all first update strategies in the data pool based on a vector container.
5. A particle system reading method, characterized in that: The particle system reading method comprises: Get the identification information of the particle tree to be read; Obtaining all nodes and all node arrays with order from a first file corresponding to the identification information of the particle tree to be read, wherein the node array includes a node type and a parent node index, the node is a particle object or an update strategy object, the update strategy object includes a first update strategy and a second update strategy, the first update strategy is an update strategy with a time series, and the second update strategy is an update strategy without a time series; Acquire a preset number of caches from a second file of identification information corresponding to the particle tree to be read; The attributes corresponding to each node are extracted from different types of caches according to the order of the node arrays, so as to form a target particle tree according to all the nodes, all the node arrays with order and the attributes corresponding to each node.
6. The particle system reading method according to claim 5, characterized in that: After extracting the attributes corresponding to each node from different types of caches in the order of the node arrays, and forming a target particle tree according to all the nodes, the ordered arrays of all nodes, and the attributes corresponding to each node, the method further comprises: Obtain a data pool storing time series from a third file; The time series in the data pool is accessed according to the time series index in the node.
7. A particle system storage device, characterized in that: The particle system storage device comprises: A first acquisition module is used to acquire a particle system set to be stored, wherein the particle system set to be stored includes a preset number of particle trees; A second acquisition module is used to acquire a node array corresponding to each node in each particle tree in a preset order, wherein the node array includes a node type and a parent node index, the node is a particle object or an update strategy object, the update strategy object includes a first update strategy and a second update strategy, the first update strategy is an update strategy with a time series, and the second update strategy is an update strategy without a time series; A first storage module is used to store the number of nodes, content data of the nodes and the node array corresponding to each particle tree in a corresponding first file; A writing module, used for writing the attributes of the nodes into the caches of different data types in sequence according to the order of the node array according to the relationship between the actual scopes of the different attributes and the caches of different data types; The second storage module is used to store the attributes of all nodes corresponding to a particle tree in each cache in a binary form in a corresponding second file.
8. A particle system reading device, characterized in that: The particle system reading device comprises: An acquisition module is used to acquire identification information of a particle tree to be read; A first reading module is used to obtain all nodes and all node arrays with order from a first file corresponding to the identification information of the particle tree to be read, wherein the node array includes a node type and a parent node index, the node is a particle object or an update strategy object, the update strategy object includes a first update strategy and a second update strategy, the first update strategy is an update strategy with a time series, and the second update strategy is an update strategy without a time series; A second reading module is used to obtain a preset number of caches from a second file of identification information corresponding to the particle tree to be read; The composition module is used to extract the attributes corresponding to each node from different types of caches according to the order of the node array, so as to form a target particle tree according to all the nodes, the ordered array of all nodes and the attributes corresponding to each node.
9. An electronic device, characterized in that: The electronic device comprises a processor and a memory, wherein the memory stores a computer program, and when the computer program is run on the processor, the particle system storage method according to any one of claims 1 to 4 and the particle system reading method according to any one of claims 5 and 6 are executed.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is run on a processor, the computer program executes the particle system storage method according to any one of claims 1 to 4 and the particle system reading method according to any one of claims 5 and 6.
Citation Information
Patent Citations
Super-large-scale weather effect rendering method
CN102855654A
Rendering system, rendering method and device, electronic device and storage medium
CN110675466A