Special effect updating method and device, electronic equipment and computer readable storage medium

A multi-threaded mechanism for updating particle data in 3D games efficiently manages particle pools and lists across threads, addressing the challenge of maintaining game performance and player experience during complex special effect rendering.

CN119056060AActive Publication Date: 2024-12-03BEIJING PIXEL SOFTWARE TECH
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411134215.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-19
Publication Date
2024-12-03
Estimated Expiration
2044-08-19

AI Technical Summary

Technical Problem

In 3D games, updating the reference information of a large number of particles in each frame while maintaining game performance and player experience is challenging due to the computational demands of rendering multiple special effects.

Method used

A multi-threaded mechanism is employed, where a main thread maintains a main particle pool for current frame data and a sub-thread manages sub-particle pools for next frame data, including activated, dormant, and invalid particle lists, allowing efficient synchronization and updating of particle data without affecting game performance.

Benefits of technology

This approach enhances update efficiency, ensuring high game performance and maintaining player experience by offloading computational tasks across threads, thereby optimizing the updating process for complex special effects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119056060A_ABST
    Figure CN119056060A_ABST
Patent Text Reader

Abstract

The invention provides a special effect updating method and device, electronic equipment and a computer readable storage medium, and relates to the field of games. The electronic equipment runs a main thread and a sub-thread, and in the process of updating the special effect of the next frame, the sub-thread begins to update the invalid particle list, the sub-activated particle list and the sub-particle pool of the target special effect when receiving the updating notification of the next frame of the main thread; after the main thread performs data synchronization with the sub-thread after the rendering of the current game frame is finished, updating each main activated particle list and the main particle pool, and then obtaining world reference data and a rendering object address of each activated particle and writing the world reference data and the rendering object address into the main particle pool; and finally, rendering each target special effect in the next game frame based on the main activated particle list and the main particle pool of each target special effect. In this way, particle data updating is conducted through a multi-thread mechanism, the game operation performance is effectively guaranteed, and the experience of players is not affected.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of games, and in particular to a special effect updating method, device, electronic device and computer-readable storage medium. Background Art

[0002] In 3D games, special effects are a commonly used technology. For example, rain, snow, smoke, fire, player skills, etc. all involve special effects production. Each special effect is composed of multiple particles. In most cases, the particles need to update life, coordinates, orientation, scaling and other reference information every frame. When multiple special effects are presented, a large number of particles will exist in the game screen at the same time. Therefore, how to update the reference information of a large number of particles in each frame while ensuring the game running performance and not affecting the player experience is a problem that needs to be considered. Summary of the invention

[0003] The purpose of the present invention is to provide a special effect updating method, device, electronic device and computer-readable storage medium to improve the problems existing in the prior art.

[0004] The embodiments of the present invention can be implemented as follows:

[0005] In a first aspect, the present invention provides a special effect update method, which is applied to an electronic device, wherein the electronic device runs a main thread and a sub-thread; the main thread maintains a main particle pool and a main activated particle list for each special effect involved in a current game scene, and the main particle pool is used to store local reference data, world reference data, and rendering object addresses of each activated particle of the special effect in the current game frame; the sub-thread maintains a sub-particle pool, a sub-activated particle list, a dormant particle list, and an invalid particle list of at least one target special effect involved in the current game scene, and the sub-particle pool is used to store local reference data of each activated particle of the target special effect in the next game frame; the method comprises:

[0006] When the sub-thread receives the next frame update notification from the main thread, it updates the dormant particle list and the invalid particle list of each target special effect based on the sub-particle pool of each target special effect, and obtains the sub-activated particle list of each target special effect in the next game frame;

[0007] The sub-thread respectively calculates the local reference data corresponding to each activated particle in the sub-activated particle list of each target special effect in the next game frame based on the particle resource data of each target special effect, and writes them into the sub-particle pool of each target special effect respectively;

[0008] When the rendering of the current game frame is completed, the main thread synchronizes the invalid particle list, the sub-activated particle list and the sub-particle pool of each target special effect from the sub-thread to update the main activated particle list and the main particle pool of each target special effect;

[0009] The main thread obtains the world reference data and rendering object address of each activated particle in the main activated particle list of each target special effect, and writes them into the main particle pool of each target special effect respectively;

[0010] The main thread renders each of the target special effects in the next game frame based on the main activated particle list and the main particle pool of each of the target special effects.

[0011] Optionally, the local reference data includes an expiration time; when the sub-thread receives the next frame update notification from the main thread, the sub-thread updates the dormant particle list and the invalid particle list of each target special effect based on the sub-particle pool of each target special effect, and obtains the sub-activated particle list of each target special effect in the next game frame, comprising:

[0012] When the main thread completes the update of the world reference data of each activated particle in the current game frame, the main thread sends the next frame update notification to the sub-thread;

[0013] For any target activation particle in the sub-activation particle list of each target special effect, the sub-thread reads the expiration time of the target activation particle from the sub-particle pool;

[0014] If the current time is consistent with the expiration time of the target activation particle, the sub-thread removes the target activation particle from the sub-activation particle list of the target special effect, and adds the target activation particle to the dormant particle list and the invalid particle list of the target special effect;

[0015] The sub-thread traverses each activated particle in the sub-activated particle list of each target special effect to obtain a new dormant particle list and an invalid particle list for each target special effect;

[0016] The sub-thread determines the sub-activated particle list of each target special effect in the next game frame based on the real-time frame rate and the preset particle emission speed and dormant particle list of each target special effect.

[0017] Optionally, the sub-thread determines the sub-activated particle list of each target special effect in the next game frame based on the real-time frame rate and the preset particle emission speed and dormant particle list of each target special effect, respectively, including:

[0018] For any of the target special effects, obtaining the real-time frame rate and the particle emission speed preset in the particle resource data of the target special effect;

[0019] Based on the real-time frame rate and the particle emission speed, the number of newly activated particles of the target special effect in the next game frame is calculated;

[0020] Remove S dormant particles from the dormant particle list of the target special effect and put them into the sub-activated particle list of the target special effect, where S represents the number of newly added activated particles;

[0021] Traverse each of the target special effects to obtain a list of sub-activated particles of each of the target special effects in the next game frame.

[0022] Optionally, when the rendering of the current game frame is completed, the main thread synchronizes the invalid particle list, the sub-activated particle list and the sub-particle pool of each target special effect from the sub-thread to update the main activated particle list and the main particle pool of each target special effect, including:

[0023] When the rendering of the current game frame is completed, the main thread synchronizes data with the sub-thread to obtain a list of invalid particles, a list of sub-activated particles, and a sub-particle pool for each target special effect;

[0024] The subthread clears each invalid particle list when data synchronization is completed;

[0025] The main thread performs invalidation processing on the rendering object address corresponding to each invalid particle in the main particle pool of each target special effect based on the invalid particle list of each target special effect;

[0026] The main thread clears the main activation particle list of each target special effect and updates it to be consistent with the sub-activation particle list of each target special effect;

[0027] The main thread updates the sub-particle pool of each target special effect to the main particle pool of each target special effect.

[0028] Optionally, the main particle pool includes an address field for storing the rendering object address;

[0029] The main thread performs a step of invalidating the rendering object address corresponding to each invalid particle in the main particle pool of each target special effect based on the invalid particle list of each target special effect, including:

[0030] For any invalid particle in the invalid particle list of any target special effect, the main thread reads the address field of the invalid particle from the main particle pool of the target special effect;

[0031] If the address field is not 0, the main thread deletes the rendering object at the rendering object address in the address field and sets the address field to 0;

[0032] The main thread traverses each invalid particle in the invalid particle list of each target special effect, and completes the update of the address field of the invalid particle of each target special effect in the main particle pool.

[0033] Optionally, the main particle pool includes an address field for storing the rendering object address;

[0034] The main thread obtains the world reference data and rendering object address of each activated particle in the main activated particle list of each target special effect, and writes them into the main particle pool of each target special effect respectively, including:

[0035] For any of the target special effects, the main thread calculates the world reference data corresponding to each activated particle in the main activated particle list of the target special effect in the next game frame, and writes the world reference data into the main particle pool of the target special effect;

[0036] For each activated particle in the main activated particle list of the target special effect, the main thread checks whether the address field of the activated particle in the main particle pool of the target special effect is zero; if so, creates a new rendering object and writes the address pointer thereof into the address field of the activated particle in the main particle pool of the target special effect;

[0037] The main thread traverses each of the target special effects to obtain the main particle pool of each target special effect required for rendering the next game frame.

[0038] In a second aspect, the present invention provides a special effect updating device, which is applied to an electronic device, and the device includes a main thread and a sub-thread, wherein the main thread maintains a main particle pool and a main activated particle list for each special effect involved in a current game scene, and the main particle pool is used to store local reference data, world reference data, and a rendering object address of each activated particle of the special effect in the current game frame; the sub-thread maintains a sub-particle pool, a sub-activated particle list, a dormant particle list, and an invalid particle list of at least one target special effect involved in the current game scene, and the sub-particle pool is used to store local reference data of each activated particle of the target special effect in the next game frame;

[0039] The sub-thread is used to update the dormant particle list and the invalid particle list of each target special effect based on the sub-particle pool of each target special effect when receiving the next frame update notification from the main thread, and obtain the sub-activated particle list of each target special effect in the next game frame;

[0040] The sub-thread is also used to calculate the local reference data corresponding to each activated particle in the sub-activated particle list of each target special effect in the next game frame based on the particle resource data of each target special effect, and write them into the sub-particle pool of each target special effect respectively;

[0041] The main thread is used to synchronize the invalid particle list, sub-activated particle list and sub-particle pool of each target special effect from the sub-thread to update the main activated particle list and main particle pool of each target special effect when the rendering of the current game frame is completed;

[0042] The main thread is used to obtain the world reference data and rendering object address of each activated particle in the main activated particle list of each target special effect, and write them into the main particle pool of each target special effect respectively;

[0043] The main thread is also used to render each of the target special effects in the next game frame based on the main activated particle list and the main particle pool of each of the target special effects.

[0044] In a third aspect, the present invention provides an electronic device, comprising: a memory and a processor, wherein the memory stores a software program, and when the electronic device is running, the processor executes the software program to implement the special effects updating method as described in the first aspect above.

[0045] In a fourth aspect, the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the special effects updating method described in the first aspect is implemented.

[0046] Compared with the prior art, the embodiment of the present invention provides a special effect update method, device, electronic device and computer-readable storage medium, wherein the electronic device runs a main thread and a sub-thread; the main thread maintains a main particle pool and a main activated particle list for each special effect involved in the current game scene, and the main particle pool is used to store the local reference data, world reference data and rendering object address of each activated particle of the special effect in the current game frame; the sub-thread maintains a sub-particle pool, a sub-activated particle list, a dormant particle list and a failed particle list of at least one target special effect involved in the current game scene, and the sub-particle pool is used to store the local reference data of each activated particle of the target special effect in the next game frame. In the process of updating the special effect of the next frame, the sub-thread starts to update the failed particle list, the sub-activated particle list and the sub-particle pool of the target special effect when receiving the next frame update notification from the main thread; the main thread synchronizes data with the sub-thread when the current game frame is rendered, updates each main activated particle list and the main particle pool, then obtains the world reference data and the rendering object address of each activated particle and writes them into the main particle pool, and finally renders each target special effect in the next game frame based on the main activated particle list and the main particle pool of each target special effect. In this way, the main thread notifies the child thread to first update the local reference data of each activated particle in the next game frame, and then the main thread synchronizes data with the child thread when the current game frame is rendered, and then updates the world reference data of the activated particles. In this way, a multi-threaded mechanism is used to update particle data, and the update efficiency is high, thereby effectively ensuring the game running performance without affecting the player experience. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0048] Figure 1 A schematic diagram of a storage structure of a sub-particle pool and a main particle pool for a target special effect provided in an embodiment of the present invention.

[0049] Figure 2 One of the flow charts of a special effect updating method provided in an embodiment of the present invention.

[0050] Figure 3 The second flowchart of a special effect updating method provided in an embodiment of the present invention.

[0051] Figure 4 The third flowchart of a special effect updating method provided in an embodiment of the present invention.

[0052] Figure 5 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0053] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.

[0054] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0055] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.

[0056] In addition, the terms “first”, “second”, etc., if used, are merely used to distinguish between the descriptions and should not be understood as indicating or implying relative importance.

[0057] It should be noted that, in the absence of conflict, the features in the embodiments of the present invention may be combined with each other.

[0058] The special effect updating method provided in the embodiment of the present invention can be applied to an electronic device, which can be, but is not limited to, a smart phone, a smart notebook, a personal computer, a server, etc. The electronic device can be installed with a 3D game, and when the 3D game is running and involves a game screen particle special effect, the electronic device runs a main thread and at least one sub-thread to be responsible for updating the particle data of the special effect.

[0059] Among them, the main thread can maintain the main particle pool and main activated particle list of each special effect involved in the current game scene. The main particle pool includes an index field, a first field, a second field, and an address field. The four fields are used to store the particle index, local reference data, world reference data, and rendering object address of each activated particle of the special effect in the current game frame. A sub-thread maintains a sub-particle pool, a sub-activated particle list, a dormant particle list, and an invalid particle list of at least one target special effect involved in the current game scene. The sub-particle pool includes an index field and a first field, which are used to store the particle index and local reference data of each activated particle of the target special effect in the next game frame.

[0060] It can be understood that the number of particles of a special effect in a rendering cycle changes dynamically. In the present invention, the storage capacity of the main particle pool and the sub-particle pool of a target special effect depends on the maximum number of particles N that appear in the rendering cycle of the target special effect. Similarly, the capacity of the main activated particle list, the sub-activated particle list, the dormant particle list and the invalid particle list of the target special effect is also the maximum number of particles N that appear in the rendering cycle of the target special effect. Adaptively, the storage structure of the sub-particle pool and the main particle pool of the target special effect is as follows: Figure 1 shown.

[0061] Among them, at the initial moment, the dormant particle list of the target special effect includes the particle indexes of N dormant particles, while the main activated particle list, sub-activated particle list and invalid particle list of the target special effect are all empty. Starting from the rendering of the first game frame with the target special effect, the number of particles between the dormant particle list, main activated particle list, sub-activated particle list and invalid particle list of the target special effect begins to change dynamically with the number of particles required to present the target special effect in the game frame.

[0062] Before rendering a game frame, the process of interacting with the main thread to implement special effect update is consistent. The following takes the special effect update of at least one target special effect between a sub-thread and the main thread as an example to introduce the special effect update method provided by the embodiment of the present invention.

[0063] Please refer to Figure 2 , Figure 2 A flowchart of a special effect updating method provided by an embodiment of the present invention is provided. The method includes the following steps S101 to S105.

[0064] S101. When the sub-thread receives the next frame update notification from the main thread, it updates the dormant particle list and invalid particle list of each target special effect based on the sub-particle pool of each target special effect, and obtains the sub-activated particle list of each target special effect in the next game frame.

[0065] Assuming that the current game frame is the Nth game frame, the main thread and the child thread synchronize data to obtain the local reference data of each activated particle. Then, after updating the world reference data of each activated particle, the child thread can be notified to prepare the local reference data of the N+1th game frame. At the same time, the main thread continues to render the Nth game frame.

[0066] In this embodiment, when the child thread receives the next frame update notification, it first finds the activated particles whose survival time has arrived from the sub-particle pool of each target special effect, so as to update the dormant particle list and invalid particle list of each target special effect, and then updates the sub-activated particle list of each target special effect based on the dormant particle list. The updated sub-activated particle list includes the particle indexes of multiple activated particles in the next game frame.

[0067] S102. The sub-thread calculates the local reference data corresponding to each activated particle in the sub-activated particle list of each target special effect in the next game frame based on the particle resource data of each target special effect, and writes them into the sub-particle pool of each target special effect.

[0068] It can be understood that the particle resource data may include data such as changes in the number, speed, position, size, color, direction, and survival time of particles.

[0069] In this embodiment, for each target special effect, the child thread needs to calculate the local reference data corresponding to each activated particle in the sub-activated particle list of the target special effect in the next game frame based on the particle resource data of the target special effect, and write it into the sub-particle pool of the target special effect, so that the child thread completes the update of the invalid particle list, sub-activated particle list and sub-particle pool of each target special effect involved in the next game frame.

[0070] Optionally, the local reference data may include, but is not limited to: the relative position, relative rotation and relative scaling of the activated particle relative to the special effect origin of the target special effect, as well as the color, size, lifetime, expiration time, etc. of the activated particle.

[0071] S103. When the main thread completes rendering of the current game frame, the sub-thread synchronizes the invalid particle list, sub-activated particle list, and sub-particle pool of each target special effect to update the main activated particle list and main particle pool of each target special effect.

[0072] In this embodiment, when the current game frame is rendered, the main thread synchronizes data with the child thread to obtain the invalid particle list, sub-activated particle list and sub-particle pool of each target special effect in the next game frame, so that the main thread can update the first field in the main activated particle list and the main particle pool of each target special effect and the address field corresponding to the invalid particle based on the data synchronized from the child thread. And the child thread will clear each invalid particle list when the data synchronization is completed so as not to affect the next special effect update. S104, the main thread obtains the world reference data and rendering object address of each activated particle in the main activated particle list of each target special effect, and writes them into the main particle pool of each target special effect respectively.

[0073] In this embodiment, the main thread obtains the world reference data and rendering object address of each activated particle in the main activated particle list of each target special effect, and writes them into the main particle pool of each target special effect respectively, thereby completing the update of the second field and address field in each main particle pool.

[0074] It can be understood that, assuming that the current game frame is the Nth game frame, the next game frame is the N+1th game frame, and when the main thread confirms the world reference data of each target special effect in the N+1th game frame, it can send a next frame update notification to the child thread, so that the child thread can start updating the invalid particle list, sub-activated particle list and sub-particle pool of each target special effect involved in the N+2th game frame.

[0075] S105. The main thread renders each target special effect in the next game frame based on the main activated particle list and the main particle pool of each target special effect.

[0076] In this embodiment, the main thread can render each target special effect in the next game frame based on the main activated particle list and the main particle pool of each target special effect.

[0077] The special effect updating method provided by the embodiment of the present invention is that the electronic device runs a main thread and a sub-thread. During the special effect updating process of the next frame, the sub-thread starts to update the invalid particle list, sub-activated particle list and sub-particle pool of the target special effect when receiving the next frame update notification of the main thread; the main thread updates each main activated particle list and the main particle pool after data synchronization with the sub-thread when the current game frame rendering is completed, and then obtains the world reference data and the rendering object address of each activated particle and writes them into the main particle pool, and finally renders each target special effect in the next game frame based on the main activated particle list and the main particle pool of each target special effect. In this way, the main thread notifies the sub-thread to first update the local reference data of each activated particle in the next game frame, and then the main thread synchronizes the data with the sub-thread when the current game frame rendering is completed to update the world reference data of the activated particle. In this way, the multi-thread mechanism is used to update the particle data, and the update efficiency is high without affecting the game frame rate, thereby effectively ensuring the game running performance and not affecting the player experience.

[0078] In an optional implementation, the child thread checks the expiration time of each activated particle in the child particle pool to confirm whether the activated particle has reached its life span and needs to be re-emitted. Figure 2 Based on Figure 3 The sub-steps of the above step S101 may include S1011 to S1015.

[0079] S1011. When the main thread completes the update of the world reference data of each activated particle in the current game frame, it sends a next frame update notification to the child thread.

[0080] S1012. For any target activation particle in the sub-activation particle list of each target special effect, the sub-thread reads the expiration time of the target activation particle from the sub-particle pool.

[0081] S1013. If the current time is consistent with the expiration time of the target activation particle, the child thread removes the target activation particle from the sub-activation particle list of the target special effect, and adds the target activation particle to the dormant particle list and the invalid particle list of the target special effect.

[0082] S1014. The child thread traverses each activated particle in the sub-activated particle list of each target special effect to obtain a new dormant particle list and an invalid particle list for each target special effect.

[0083] In this embodiment, for each activated particle in the sub-activated particle list of each target special effect, the child thread needs to read the expiration time of the activated particle from the first field of the corresponding sub-particle pool. If the current time is consistent with the expiration time, it means that the activated particle has expired, and the activated particle needs to be removed from the sub-activated particle list, and then the activated particle is added to the dormant particle list and the invalid particle list of the corresponding target special effect.

[0084] S1015. The sub-thread determines the sub-activated particle list of each target special effect in the next game frame based on the real-time frame rate and the preset particle emission speed and dormant particle list of each target special effect.

[0085] In this embodiment, the preset particle emission speed represents the change in the number of particles defined in the particle resource data.

[0086] Optionally, the sub-thread of S1015 may include the following steps S10151 to S10154:

[0087] S10151. For any target special effect, obtain the real-time frame rate and the particle emission speed preset in the particle resource data of the target special effect;

[0088] S10152. Calculate the number of newly activated particles of the target special effect in the next game frame based on the real-time frame rate and the particle emission speed;

[0089] S10153. Remove S dormant particles from the dormant particle list of the target special effect and put them into the sub-activated particle list of the target special effect, where S represents the number of newly activated particles.

[0090] S10154. Traverse each target special effect to obtain a list of sub-activated particles for each target special effect in the next game frame.

[0091] In this embodiment, assuming that the real-time frame rate is fps and the particle emission speed is v, the number of newly added activated particles S=v / fps.

[0092] During each special effect update, the child thread is responsible for updating and maintaining activated particles, insomnia particles, and invalid particles, as well as calculating the local reference data of each activated particle, which reduces the workload of the main thread and increases the update efficiency.

[0093] In an optional implementation, after the main thread and the child thread synchronize data, the main thread can update the main active particle list and the first field of the main particle pool and invalidate the rendering object address of each invalid particle in the main particle pool. Figure 2 Based on Figure 4 The sub-steps of the above step S103 may include S1031 to S1035.

[0094] S1031. When the current game frame is rendered, the main thread synchronizes data with the child thread to obtain a list of invalid particles, a list of sub-activated particles, and a sub-particle pool for each target special effect.

[0095] S1032. The child thread clears each invalid particle list when data synchronization is completed.

[0096] In this embodiment, when the current game frame is rendered, the main thread synchronizes data with the child thread to obtain the invalid particle list, sub-activated particle list and sub-particle pool of each target special effect, and the child thread clears the invalid particle list of each target special effect when the data synchronization is completed, which does not affect the next special effect update process for each target special effect.

[0097] S1033. The main thread performs invalidation processing on the rendering object address corresponding to each invalid particle in the main particle pool of each target special effect based on the invalid particle list of each target special effect.

[0098] Optionally, sub-steps of step S1033 may include S10331 to S10333:

[0099] S10331. For any invalid particle in the invalid particle list of any target special effect, the main thread reads the address field of the invalid particle from the main particle pool of the target special effect;

[0100] S10332, if the address field is not 0, the main thread deletes the rendering object at the rendering object address in the address field and sets the address field to 0;

[0101] S10333. The main thread traverses each invalid particle in the invalid particle list of each target special effect, and completes updating the address field of the invalid particle of each target special effect in the main particle pool.

[0102] For each invalid particle in the invalid particle list of each target special effect, the above steps S10331 to S10333 are executed to complete the invalidation processing of the rendering object addresses corresponding to all invalid particles.

[0103] S1034: The main thread clears the main activated particle list of each target special effect and updates it to be consistent with the sub-activated particle list of each target special effect.

[0104] S1035. The main thread updates the sub-particle pool of each target special effect to the main particle pool of each target special effect.

[0105] In this embodiment, the main thread will overwrite and update the sub-particle pool of each target special effect to the first field part of the main particle pool of each target special effect.

[0106] Taking a flame special effect as an example, the following describes the changes of the sub-activated particle list, the dormant particle list, the invalid particle list and the main activated particle list during the execution of the above steps S101 to S103 and their sub-steps during a special effect update process.

[0107] In the optional example, assuming that the target special effect is a flame special effect, and its maximum number of particles N=10, when the current game frame rendering ends, the sub-activated particle list, dormant particle list and invalid particle list of the flame special effect maintained by the child thread and the main activated particle list of the flame special effect maintained by the main thread are shown in the following table (1):

[0108] Table (1)

[0109] Sub-activated particle list Sleeping particle list Dead Particle List Main active particle list Id0 Id5 Id0 Id1 Id6 Id1 Id2 Id7 Id2 Id3 Id8 Id3 Id4 Id9 Id4

[0110] The child thread checks the expiration time of the five activated particles (Id0 to Id4) in Table (1) from the sub-particle pool of the flame special effect. If it is found that the expiration time of the activated particles Id0, Id2, and Id3 is consistent with the current time, the child thread will remove particles Id0, Id2, and Id3 from the sub-activated particle list and add them to the dormant particle list and the invalid particle list. At this time, the four lists are shown in the following table (2):

[0111] Table (2)

[0112] Sub-activated particle list Sleeping particle list Dead Particle List Main active particle list Id1 Id3 Id3 Id0 Id4 Id2 Id2 Id1 Id0 Id0 Id2 Id5 Id3 Id6 Id4 Id7 Id8 Id9

[0113] If the child thread calculates that the number of newly activated particles S=4, then the child thread will remove 4 particles from the dormant particle list to the sub-activated particle list. At this time, the four lists are shown in the following table (3):

[0114] Table (3)

[0115] Sub-activated particle list Sleeping particle list Dead Particle List Main active particle list Id3 Id6 Id3 Id0 Id2 Id7 Id2 Id1 Id0 Id8 Id0 Id2 Id5 Id9 Id3 Id1 Id4 Id4

[0116] After the child thread calculates the local reference data of each activated particle in the sub-activated particle list in Table (3) and writes it to the sub-particle pool of the flame special effect, it will synchronize the sub-particle pool of the flame special effect and the sub-activated particle list and invalid particle list in Table (3) to the main thread, and then the child thread will clear the invalid particle list in Table (3). The main thread will update the main activated particle list of the flame special effect to be consistent with its sub-activated particle list, and based on the invalid particle list, set the rendering object address corresponding to each invalid particle in the main particle pool of the flame special effect to 0, and update the sub-particle pool of the flame special effect to the first field part of the main particle pool of the flame special effect. At this time, the four lists are shown in the following table (4):

[0117] Table (4)

[0118] Sub-activated particle list Sleeping particle list Dead Particle List Main active particle list Id3 Id6 Id3 Id2 Id7 Id2 Id0 Id8 Id0 Id5 Id9 Id5 Id1 Id1 Id4 Id4

[0119] It should be noted that the number of rows under the list in the above table represents that the list capacity is consistent with the maximum number of particles N=10, and an empty table only means that the list is not full. The above examples are only examples and are not limited here.

[0120] In an optional implementation, the main thread also needs to determine the world reference data and rendering object address of each activated particle in the main activated particle list of each target special effect, and write them into the second field and address field of the main particle pool of each target special effect, respectively, so as to ensure the successful rendering of each target special effect in the next game frame. Correspondingly, the sub-steps of the above step S104 may include S1041 to S1043.

[0121] S1041. For any target special effect, the main thread calculates the world reference data corresponding to each activated particle in the main activated particle list of the target special effect in the next game frame, and writes it into the main particle pool of the target special effect.

[0122] Optionally, the world reference data may include, but is not limited to: coordinates, rotation, displacement, scaling, etc. of the world coordinate system of the activated particles in the game scene.

[0123] In this embodiment, for each target special effect, the main thread calculates the world reference data corresponding to each activated particle in the main activated particle list of the target special effect in the next game frame, and writes it into the second field part of the main particle pool of the target special effect.

[0124] S1042. For each activated particle in the main activated particle list of the target special effect, the main thread checks whether the address field of the activated particle in the main particle pool of the target special effect is zero; if so, a new rendering object is created and the address pointer thereof is written into the address field of the activated particle in the main particle pool of the target special effect.

[0125] In this embodiment, for a target special effect, if there is an activated particle with an address field of zero in its main activated particle list, the main thread can create a rendering object based on the rendering model, and then write the address pointer of the rendering object to the address field of the main particle pool of the target special effect. This ensures that the main thread can confirm the rendering model of each activated particle through the rendering object address recorded in the address field during rendering.

[0126] S1043. The main thread traverses each target special effect to obtain the main particle pool of each target special effect required for rendering the next game frame.

[0127] It can be understood that for each target special effect, the main thread executes the above steps S1041 to S1043 once, thereby completing the update of the second field and the address field of the main particle pool for the activated particles of each target special effect.

[0128] It should be noted that the execution order of each step in the above method embodiment is not limited to that shown in the drawings, and the execution order of each step shall be based on the actual application situation.

[0129] In order to execute the corresponding steps in the above method embodiment and each possible implementation mode, a method for implementing a special effect updating device is provided below.

[0130] The present invention also provides a special effect updating device, which is applied to electronic equipment. The device includes a main thread and a sub-thread. The main thread maintains a main particle pool and a main activated particle list for each special effect involved in the current game scene. The main particle pool is used to store local reference data, world reference data and rendering object address of each activated particle of the special effect in the current game frame; the sub-thread maintains a sub-particle pool, a sub-activated particle list, a dormant particle list and an invalid particle list of at least one target special effect involved in the current game scene. The sub-particle pool is used to store local reference data of each activated particle of the target special effect in the next game frame.

[0131] The child thread is used to update the dormant particle list and invalid particle list of each target special effect based on the sub-particle pool of each target special effect when receiving the next frame update notification from the main thread, and obtain the sub-activated particle list of each target special effect in the next game frame;

[0132] The sub-thread is also used to calculate the local reference data corresponding to each activated particle in the sub-activated particle list of each target special effect in the next game frame based on the particle resource data of each target special effect, and write them into the sub-particle pool of each target special effect respectively;

[0133] The main thread is used to synchronize the invalid particle list, sub-activated particle list and sub-particle pool of each target special effect from the sub-thread when the current game frame is rendered, so as to update the main activated particle list and main particle pool of each target special effect;

[0134] The main thread is used to obtain the world reference data and rendering object address of each activated particle in the main activated particle list of each target special effect, and write them into the main particle pool of each target special effect respectively;

[0135] The main thread is also used to render each target special effect in the next game frame based on the main activated particle list and main particle pool of each target special effect.

[0136] Optionally, the local reference data may include an expiration time. The subthread is used to update the dormant particle list and the invalid particle list of each target special effect based on the sub-particle pool of each target special effect respectively when receiving the next frame update notification from the main thread, and in the process of obtaining the sub-activated particle list of each target special effect in the next game frame, the main thread can be used to send the next frame update notification to the subthread when completing the world reference data update of each activated particle in the current game frame; the subthread can be specifically used to: for any target activated particle in the sub-activated particle list of each target special effect, read the expiration time of the target activated particle from the sub-particle pool; if the current moment is consistent with the expiration time of the target activated particle, remove the target activated particle from the sub-activated particle list of the target special effect, and add the target activated particle to the dormant particle list and invalid particle list of the target special effect; traverse each activated particle in the sub-activated particle list of each target special effect to obtain a new dormant particle list and invalid particle list for each target special effect; based on the real-time frame rate, the preset particle emission speed and the dormant particle list of each target special effect, determine the sub-activated particle list of each target special effect in the next game frame.

[0137] Optionally, the sub-thread is used to determine the sub-activated particle list of each target special effect in the next game frame based on the real-time frame rate, the preset particle emission speed and the dormant particle list of each target special effect. Specifically, it can be used for: for any target special effect, obtaining the real-time frame rate and the particle emission speed preset in the particle resource data of the target special effect; based on the real-time frame rate and the particle emission speed, calculating the number of newly added activated particles of the target special effect in the next game frame; removing S dormant particles from the dormant particle list of the target special effect and putting them into the sub-activated particle list of the target special effect, where S represents the number of newly added activated particles; traversing each target special effect to obtain the sub-activated particle list of each target special effect in the next game frame.

[0138] Optionally, the main thread is used to synchronize the invalid particle list, sub-activated particle list, and sub-particle pool of each target effect from the child thread to update the main activated particle list and main particle pool of each target effect when the current game frame is rendered:

[0139] The main thread is used to synchronize data with the child thread to obtain the invalid particle list, sub-activated particle list and sub-particle pool of each target special effect when the current game frame is rendered; the child thread is used to clear each invalid particle list when data synchronization is completed; the main thread is used to invalidate the rendering object address corresponding to each invalid particle in the main particle pool of each target special effect based on the invalid particle list of each target special effect; the main thread is used to update the main activated particle list of each target special effect to be consistent with the sub-activated particle list of each target special effect; the main thread is used to overwrite and update the sub-particle pool of each target special effect to the main particle pool of each target special effect.

[0140] Optionally, the main particle pool includes an address field for storing the address of the rendering object. The main thread is used to perform invalidation processing on the rendering object address corresponding to each invalid particle in the main particle pool of each target special effect based on the invalid particle list of each target special effect. Specifically, it can be used to: for any invalid particle in the invalid particle list of any target special effect, read the address field of the invalid particle from the main particle pool of the target special effect; if the address field is not 0, delete the rendering object at the rendering object address in the address field and set the address field to 0; traverse each invalid particle in the invalid particle list of each target special effect, and complete the update of the address field of the invalid particle of each target special effect in the main particle pool.

[0141] Optionally, the main particle pool includes an address field for storing the address of the rendering object. When the main thread is used to obtain the world reference data and rendering object address of each activated particle in the main activation particle list of each target special effect, and write them into the main particle pool of each target special effect respectively, it can be used specifically to: for any target special effect, calculate the world reference data corresponding to each activated particle in the main activation particle list of the target special effect in the next game frame, and write it into the main particle pool of the target special effect; for each activated particle in the main activation particle list of the target special effect, check whether the address field of the activated particle in the main particle pool of the target special effect is zero; if so, create a new rendering object and write its address pointer into the address field of the activated particle in the main particle pool of the target special effect; traverse each target special effect to obtain the main particle pool of each target special effect required for rendering the next game frame.

[0142] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the special effect updating device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.

[0143] See also Figure 5 , Figure 5The electronic device 300 includes a processor 310 , a memory 320 , and a bus 330 , wherein the processor 310 is connected to the memory 320 via the bus 330 .

[0144] The memory 320 can be used to store software programs, for example, software programs corresponding to the special effect updating device provided in the embodiment of the present invention. The processor 310 executes various functional applications and data processing to implement the special effect updating method provided in the embodiment of the present invention by running the software programs stored in the memory 320.

[0145] Among them, the memory 320 can be but is not limited to: RAM (Random Access Memory), ROM (Read Only Memory), FLASH (Flash Memory), PROM (Programmable Read-Only Memory), EPROM (Erasable Programmable Read-Only Memory), EEPROM (Electric Erasable Programmable Read-Only Memory), etc.

[0146] The processor 310 may be an integrated circuit chip with signal processing capability. The processor 310 may be a general-purpose processor, including: CPU (Central Processing Unit), NP (Network Processor), etc.; it may also be: DSP (Digital Signal Processing), ASIC (Application Specific Integrated Circuit), FPGA (Field-Programmable Gate Array) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0147] Understandably, Figure 5 The structure shown is for illustration only. The electronic device 300 may also include Figure 5 More or fewer components as shown, or with Figure 5 Different configurations are shown. Figure 5 Each component shown in the figure can be implemented by hardware, software or a combination thereof.

[0148] The embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the special effect update method disclosed in the above embodiment is implemented. The computer-readable storage medium can be, but is not limited to, various media that can store program codes, such as a USB flash drive, a mobile hard disk, a ROM, a RAM, a PROM, an EPROM, an EEPROM, a FLASH disk, or an optical disk.

[0149] In summary, the embodiment of the present invention provides a special effect update method, device, electronic device and computer-readable storage medium, the electronic device runs a main thread and a sub-thread; the main thread maintains a main particle pool and a main activated particle list for each special effect involved in the current game scene, the main particle pool is used to store the local reference data, world reference data and rendering object address of each activated particle of the special effect in the current game frame; the sub-thread maintains a sub-particle pool, a sub-activated particle list, a dormant particle list and a failed particle list of at least one target special effect involved in the current game scene, the sub-particle pool is used to store the local reference data of each activated particle of the target special effect in the next game frame. In the process of updating the special effect of the next frame, the sub-thread starts to update the failed particle list, the sub-activated particle list and the sub-particle pool of the target special effect when receiving the next frame update notification from the main thread; the main thread synchronizes data with the sub-thread when the current game frame is rendered, updates each main activated particle list and the main particle pool, then obtains the world reference data and the rendering object address of each activated particle and writes them into the main particle pool, and finally renders each target special effect in the next game frame based on the main activated particle list and the main particle pool of each target special effect. In this way, the main thread notifies the child thread to first update the local reference data of each activated particle in the next game frame, and then the main thread synchronizes data with the child thread when the current game frame is rendered, and then updates the world reference data of the activated particles. In this way, a multi-threaded mechanism is used to update particle data, and the update efficiency is high, thereby effectively ensuring the game running performance without affecting the player experience.

[0150] The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims

1. A special effect updating method, characterized in that: Applied to an electronic device, the electronic device runs a main thread and a sub-thread; the main thread maintains a main particle pool and a main activated particle list for each special effect involved in the current game scene, the main particle pool is used to store local reference data, world reference data and rendering object address of each activated particle of the special effect in the current game frame; the sub-thread maintains a sub-particle pool, a sub-activated particle list, a dormant particle list and a failed particle list of at least one target special effect involved in the current game scene, the sub-particle pool is used to store local reference data of each activated particle of the target special effect in the next game frame; the method comprises: When the sub-thread receives the next frame update notification from the main thread, it updates the dormant particle list and the invalid particle list of each target special effect based on the sub-particle pool of each target special effect, and obtains the sub-activated particle list of each target special effect in the next game frame; The sub-thread respectively calculates the local reference data corresponding to each activated particle in the sub-activated particle list of each target special effect in the next game frame based on the particle resource data of each target special effect, and writes them into the sub-particle pool of each target special effect respectively; When the rendering of the current game frame is completed, the main thread synchronizes the invalid particle list, the sub-activated particle list and the sub-particle pool of each target special effect from the sub-thread to update the main activated particle list and the main particle pool of each target special effect; The main thread obtains the world reference data and rendering object address of each activated particle in the main activated particle list of each target special effect, and writes them into the main particle pool of each target special effect respectively; The main thread renders each of the target special effects in the next game frame based on the main activated particle list and the main particle pool of each of the target special effects.

2. The method according to claim 1, characterized in that The local reference data includes an expiration time; when the sub-thread receives the next frame update notification from the main thread, the sub-thread updates the dormant particle list and the invalid particle list of each target special effect based on the sub-particle pool of each target special effect, and obtains the sub-activated particle list of each target special effect in the next game frame, including: When the main thread completes the update of the world reference data of each activated particle in the current game frame, the main thread sends the next frame update notification to the sub-thread; For any target activation particle in the sub-activation particle list of each target special effect, the sub-thread reads the expiration time of the target activation particle from the sub-particle pool; If the current time is consistent with the expiration time of the target activation particle, the sub-thread removes the target activation particle from the sub-activation particle list of the target special effect, and adds the target activation particle to the dormant particle list and the invalid particle list of the target special effect; The sub-thread traverses each activated particle in the sub-activated particle list of each target special effect to obtain a new dormant particle list and an invalid particle list for each target special effect; The sub-thread determines the sub-activated particle list of each target special effect in the next game frame based on the real-time frame rate and the preset particle emission speed and dormant particle list of each target special effect.

3. The method according to claim 2, characterized in that The step of the sub-thread determining the sub-activated particle list of each target special effect in the next game frame based on the real-time frame rate and the preset particle emission speed and dormant particle list of each target special effect includes: For any of the target special effects, obtaining the real-time frame rate and the particle emission speed preset in the particle resource data of the target special effect; Based on the real-time frame rate and the particle emission speed, the number of newly activated particles of the target special effect in the next game frame is calculated; Remove S dormant particles from the dormant particle list of the target special effect and put them into the sub-activated particle list of the target special effect, where S represents the number of newly added activated particles; Traverse each of the target special effects to obtain a list of sub-activated particles of each of the target special effects in the next game frame.

4. The method according to claim 1, characterized in that: When the rendering of the current game frame is completed, the main thread synchronizes the invalid particle list, the sub-activated particle list and the sub-particle pool of each target special effect from the sub-thread to update the main activated particle list and the main particle pool of each target special effect, including: When the rendering of the current game frame is completed, the main thread synchronizes data with the sub-thread to obtain a list of invalid particles, a list of sub-activated particles, and a sub-particle pool for each target special effect; The subthread clears each invalid particle list when data synchronization is completed; The main thread performs invalidation processing on the rendering object address corresponding to each invalid particle in the main particle pool of each target special effect based on the invalid particle list of each target special effect; The main thread clears the main activation particle list of each target special effect and updates it to be consistent with the sub-activation particle list of each target special effect; The main thread updates the sub-particle pool of each target special effect to the main particle pool of each target special effect.

5. The method according to claim 4, characterized in that The main particle pool includes an address field for storing the rendering object address; The main thread performs a step of invalidating the rendering object address corresponding to each invalid particle in the main particle pool of each target special effect based on the invalid particle list of each target special effect, including: For any invalid particle in the invalid particle list of any target special effect, the main thread reads the address field of the invalid particle from the main particle pool of the target special effect; If the address field is not 0, the main thread deletes the rendering object at the rendering object address in the address field and sets the address field to 0; The main thread traverses each invalid particle in the invalid particle list of each target special effect, and completes the update of the address field of the invalid particle of each target special effect in the main particle pool.

6. The method according to claim 1, characterized in that The main particle pool includes an address field for storing the rendering object address; The main thread obtains the world reference data and rendering object address of each activated particle in the main activated particle list of each target special effect, and writes them into the main particle pool of each target special effect respectively, including: For any of the target special effects, the main thread calculates the world reference data corresponding to each activated particle in the main activated particle list of the target special effect in the next game frame, and writes the world reference data into the main particle pool of the target special effect; For each activated particle in the main activated particle list of the target special effect, the main thread checks whether the address field of the activated particle in the main particle pool of the target special effect is zero; if so, creates a new rendering object and writes the address pointer thereof into the address field of the activated particle in the main particle pool of the target special effect; The main thread traverses each of the target special effects to obtain the main particle pool of each target special effect required for rendering the next game frame.

7. A special effect updating device, characterized in that: Applied to electronic devices, the device includes a main thread and a sub-thread, the main thread maintains a main particle pool and a main activated particle list for each special effect involved in the current game scene, the main particle pool is used to store local reference data, world reference data and rendering object address of each activated particle of the special effect in the current game frame; the sub-thread maintains a sub-particle pool, a sub-activated particle list, a dormant particle list and an invalid particle list of at least one target special effect involved in the current game scene, the sub-particle pool is used to store local reference data of each activated particle of the target special effect in the next game frame; The sub-thread is used to update the dormant particle list and the invalid particle list of each target special effect based on the sub-particle pool of each target special effect when receiving the next frame update notification from the main thread, and obtain the sub-activated particle list of each target special effect in the next game frame; The sub-thread is also used to calculate the local reference data corresponding to each activated particle in the sub-activated particle list of each target special effect in the next game frame based on the particle resource data of each target special effect, and write them into the sub-particle pool of each target special effect respectively; The main thread is used to synchronize the invalid particle list, sub-activated particle list and sub-particle pool of each target special effect from the sub-thread to update the main activated particle list and main particle pool of each target special effect when the rendering of the current game frame is completed; The main thread is used to obtain the world reference data and rendering object address of each activated particle in the main activated particle list of each target special effect, and write them into the main particle pool of each target special effect respectively; The main thread is also used to render each of the target special effects in the next game frame based on the main activated particle list and the main particle pool of each of the target special effects.

8. The device according to claim 7, characterized in that The local reference data includes an expiration time; the sub-thread is used to update the dormant particle list and the invalid particle list of each target special effect based on the sub-particle pool of each target special effect respectively when receiving the next frame update notification from the main thread, and in the process of obtaining the sub-activated particle list of each target special effect in the next game frame, the main thread is used to send the next frame update notification to the sub-thread when completing the world reference data update of each activated particle in the current game frame; The sub-thread is specifically used for: For any target activation particle in the sub-activation particle list of each target special effect, read the expiration time of the target activation particle from the sub-particle pool; If the current time is consistent with the expiration time of the target activation particle, the target activation particle is removed from the sub-activation particle list of the target special effect, and the target activation particle is added to the dormant particle list and the invalid particle list of the target special effect; Traversing each activated particle in the sub-activated particle list of each target special effect to obtain a new dormant particle list and an invalid particle list for each target special effect; Based on the real-time frame rate and the preset particle emission speed and dormant particle list of each target special effect, the sub-activated particle list of each target special effect in the next game frame is determined respectively.

9. An electronic device, characterized in that: include: A memory and a processor, wherein the memory stores a software program, and when the electronic device is running, the processor executes the software program to implement the special effect updating method as described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the special effect updating method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Multithread parallelization based 3D (three dimensional) engine system

    CN104102488A

  • Method and apparatus for performing graphic processing by using particle system

    CN106157234A

  • Animation effect detection method and device, electronic equipment and storage medium

    CN114387241A

  • Method and device for processing performance data in game engine, equipment and medium

    CN116755967A

  • Particle effect processing method and device, electronic equipment and readable storage medium

    CN117173311A