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

By employing a multi-threaded mechanism that combines the main thread and child threads, particle data in the 3D game is updated efficiently, solving the problems of game performance and player experience, and achieving efficient particle data updates.

CN119056060BActive Publication Date: 2025-11-11BEIJING PIXEL SOFTWARE TECH
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

In 3D games, how can we ensure that game performance does not affect the player experience when updating the reference information of a large number of particles every frame?

Method used

A multi-threaded mechanism with main thread and child thread working together is adopted. The main thread maintains the particle pool and active particle list of the current game frame, while the child thread maintains the particle pool and active particle list of the next game frame. Data synchronization is performed when the game frame is rendered to achieve efficient updating of particle data.

Benefits of technology

This improved particle data update efficiency, ensuring game performance without affecting the player experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119056060B_ABST
    Figure CN119056060B_ABST
Patent Text Reader

Abstract

This invention provides a method, apparatus, electronic device, and computer-readable storage medium for updating special effects, relating to the field of gaming. The electronic device operates with a main thread and sub-threads. During the update of special effects for the next frame, the sub-thread, upon receiving a notification from the main thread, begins updating the list of disabled particles, the list of sub-activated particles, and the sub-particle pool for the target special effect. After the current game frame is rendered, the main thread synchronizes data with the sub-threads and updates each main activated particle list and main particle pool. Then, it obtains the world reference data and rendering object address for each activated particle and writes them to the main particle pool. Finally, based on the main activated particle lists and main particle pools of each target special effect, it renders each target special effect in the next game frame. This multi-threaded mechanism for updating particle data effectively ensures game performance and does not affect the player experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of gaming, and more specifically, to a method, apparatus, electronic device, and computer-readable storage medium for updating special effects. Background Technology

[0002] In 3D games, special effects are a commonly used technique. For example, rain, snow, smoke, fire, and player skills all involve the creation of special effects. Each special effect is composed of multiple particles. In most cases, the particles need to update reference information such as life, coordinates, orientation, and scaling 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 ensure the game's performance and not affect the player's experience while updating the reference information of a large number of particles every frame is a problem that needs to be considered. Summary of the Invention

[0003] The purpose of this invention is to provide a method, apparatus, electronic device, and computer-readable storage medium for updating special effects, so as 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 effects update method applied to an electronic device, the electronic device running a main thread and sub-threads; the main thread maintains a main particle pool and a main active particle list for each special effect involved in the current game scene, the main particle pool being used to store local reference data, world reference data, and rendering object addresses of each active particle of the special effect in the current game frame; the sub-threads maintain a sub-particle pool, a sub-active particle list, a dormant particle list, and a deactivated particle list for at least one target special effect involved in the current game scene, the sub-particle pool being used to store local reference data of each active particle of the target special effect in the next game frame; the method includes:

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

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

[0008] When the current game frame is rendered, the main thread synchronizes the list of failed particles, the list of sub-activated particles, and the sub-particle pool of each target effect from the sub-thread to update the main activated particle list and the main particle pool of each target effect.

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

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

[0011] Optionally, the local reference data includes the expiration time; the step of the sub-thread updating the dormant particle list and expiration particle list of each target effect based on the sub-particle pool of each target effect when it receives the next frame update notification from the main thread, and obtaining the sub-activated particle list of each target effect in the next game frame, includes:

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

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

[0014] If the current time coincides with the expiration time of the target activated particle, the sub-thread removes the target activated particle from the sub-activated particle list of the target effect and adds the target activated particle to the dormant particle list and the expiration particle list of the target effect.

[0015] The sub-thread iterates through each active particle in the sub-activated particle list of each target effect to obtain a new dormant particle list and a deactivated particle list for each target effect.

[0016] The sub-thread determines the sub-activated particle list of each target 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 effect.

[0017] Optionally, the step of the sub-thread determining the sub-activated particle list of each target 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 effect includes:

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

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

[0020] Remove S dormant particles from the dormant particle list of the target effect and add them to the sub-activated particle list of the target effect, where S represents the number of newly activated particles.

[0021] Iterate through each of the target effects to obtain a list of sub-activated particles for each target effect in the next game frame.

[0022] Optionally, the step of the main thread synchronizing the list of disabled particles, the list of sub-activated particles, and the sub-particle pool for each target effect from the sub-thread to update the list of main activated particles and the main particle pool for each target effect when the current game frame is rendered includes:

[0023] When the current game frame is rendered, the main thread synchronizes data with the sub-thread to obtain the list of failed particles, the list of sub-activated particles, and the sub-particle pool for each target effect.

[0024] The sub-thread clears the list of each failed particle when data synchronization is complete.

[0025] The main thread performs failure processing on the rendering object address corresponding to each failed particle in the main particle pool of each target effect based on the list of failed particles of each target effect.

[0026] The main thread clears the main active particle list of each target effect and then updates it to match the sub-active particle list of each target effect.

[0027] The main thread will update the sub-particle pool of each target effect to the main particle pool of each target effect respectively.

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

[0029] The main thread performs failure processing on the rendering object address corresponding to each failed particle in the main particle pool of each target effect based on the failed particle list of each target effect, including:

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

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

[0032] The main thread iterates through each failed particle in the list of failed particles for each target effect, and updates the address field of each failed particle in the main particle pool.

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

[0034] The step of the main thread obtaining the world reference data and rendering object address of each active particle in the main active particle list of each target effect, and writing them into the main particle pool of each target effect, includes:

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

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

[0037] The main thread iterates through each target effect to obtain the main particle pool for each target effect required for rendering the next game frame.

[0038] Secondly, the present invention provides a special effects update device applied to an electronic device. The device includes a main thread and a sub-thread. The main thread maintains a main particle pool and a main active 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 addresses of each active particle of the special effect in the current game frame. The sub-thread maintains a sub-particle pool, a sub-active particle list, a dormant particle list, and a deactivated particle list for 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 active particle of the target special effect in the next game frame.

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

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

[0041] The main thread is used to synchronize the list of failed particles, the list of sub-activated particles, and the sub-particle pool of each target effect from the sub-thread when the current game frame is rendered to update the main activated particle list and the main particle pool of each target effect.

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

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

[0044] Thirdly, 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 update method as described in the first aspect above.

[0045] Fourthly, the present invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the special effects update method described in the first aspect.

[0046] Compared with existing technologies, embodiments of the present invention provide a method, apparatus, electronic device, and computer-readable storage medium for updating special effects. The electronic device operates a main thread and a sub-thread. The main thread maintains a main particle pool and a main active 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 active particle of the special effect in the current game frame. The sub-thread maintains a sub-particle pool, a sub-active particle list, a dormant particle list, and a deactivated particle list for 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 active particle of the target special effect in the next game frame. During the special effect update process of the next frame, when the sub-thread receives the next frame update notification from the main thread, it begins to update the deactivated particle list, sub-active particle list, and sub-particle pool of the target special effect. After the current game frame is rendered, the main thread synchronizes data with the sub-thread and updates each main active particle list and main particle pool. Then, it obtains the world reference data and rendering object address of each active particle and writes it into the main particle pool. Finally, it renders each target special effect in the next game frame based on the main active particle list and main particle pool of each target special effect. In this way, the main thread notifies the child thread to update the local reference data of each active particle in the next game frame. Then, after the main thread finishes rendering the current game frame, it synchronizes the data with the child thread and updates the world reference data of the active particles. This multi-threaded mechanism for particle data updates is highly efficient, thus effectively ensuring game performance and not affecting the player experience. Attached Figure Description

[0047] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

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

[0049] Figure 2 This is one of the flowcharts illustrating a special effects update method provided in an embodiment of the present invention.

[0050] Figure 3 This is a second schematic flowchart of a special effects update method provided in an embodiment of the present invention.

[0051] Figure 4 This is the third flowchart illustrating a special effects update method provided in an embodiment of the present invention.

[0052] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0053] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.

[0054] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.

[0055] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.

[0056] Furthermore, the terms "first" and "second" are used only to distinguish descriptions and should not be interpreted as indicating or implying relative importance.

[0057] It should be noted that, where there is no conflict, the features in the embodiments of the present invention can be combined with each other.

[0058] The special effects update method provided in this invention can be applied to electronic devices, including but not limited to smartphones, laptops, personal computers, servers, etc. The electronic device may have a 3D game installed. When the 3D game is running and involves particle effects in the game screen, the electronic device runs a main thread and at least one sub-thread to handle the particle data update for the special effects.

[0059] The main thread maintains a main particle pool and a main active particle list for each 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. These four fields are used to store the particle index, local reference data, world reference data, and rendering object address of each active particle of the effect in the current game frame, respectively. A sub-thread maintains a sub-particle pool, a sub-active particle list, a dormant particle list, and a deactivated particle list for at least one target 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 active particle of the target effect in the next game frame, respectively.

[0060] It is understandable that the number of particles in a special effect changes dynamically during its presentation period. In this invention, the storage capacity of the main particle pool and sub-particle pool of a target special effect depends on the maximum number of particles N that appear in the target special effect during its presentation period. Similarly, the capacity of the main active particle list, sub-active particle list, dormant particle list, and inactive particle list of the target special effect is also the maximum number of particles N that appear in the target special effect during its presentation period. Adaptively, the storage structure of the sub-particle pool and main particle pool of the target special effect is as follows: Figure 1 As shown.

[0061] Initially, the dormant particle list of the target effect includes the particle indices of N dormant particles, while the main active particle list, sub-active particle list, and inactive particle list of the target effect are all empty. Starting from the rendering of the first game frame containing the target effect, the number of particles in the dormant particle list, main active particle list, sub-active particle list, and inactive particle list of the target effect begins to change dynamically as the number of particles required to render the target effect in the game frame changes.

[0062] Before the rendering of a game frame, the process of each child thread interacting with the main thread to update special effects is consistent. The following example illustrates the special effects update method provided in this embodiment of the invention, using the example of a child thread updating at least one target special effect with the main thread.

[0063] Please refer to Figure 2 , Figure 2 This is a flowchart illustrating a special effects update method provided in an embodiment of the present invention. The method includes the following steps: S101 to S105.

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

[0065] Assuming the current game frame is the Nth game frame, after the main thread and the child thread synchronize data to obtain the local reference data of each activated particle, and 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, while 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 active particles whose survival time has been reached from the sub-particle pool of each target effect, thereby updating the dormant particle list and the invalid particle list of each target effect. Then, it updates the sub-active particle list of each target effect based on the dormant particle list. The updated sub-active particle list includes the particle index of multiple active particles in the next game frame.

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

[0068] It is understandable that particle resource data can include data such as changes in the number of particles, changes in velocity, position, size, color, orientation, and lifespan.

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

[0070] Optionally, 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 origin of the target effect, as well as the color, size, lifespan, and expiration time of the activated particle.

[0071] S103. When the main thread finishes rendering the current game frame, it synchronizes the list of disabled particles, the list of sub-activated particles, and the sub-particle pool for each target effect from the child thread to update the list of main activated particles and the main particle pool for each target effect.

[0072] In this embodiment, when the main thread finishes rendering the current game frame, it synchronizes data with the child thread to obtain the list of failed particles, the list of sub-activated particles, and the sub-particle pool for each target effect in the next game frame. This allows the main thread to update the first field and the address field corresponding to the failed particles in the main activated particle list and main particle pool for each target effect based on the data synchronized from the child thread. Furthermore, the child thread clears each failed particle list upon completion of data synchronization to avoid affecting the next 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 effect and writes them into the main particle pool of each target effect.

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

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

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

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

[0077] The special effects update method provided in this invention involves an electronic device running a main thread and sub-threads. During the special effects update process for the next frame, the sub-thread, upon receiving the next frame update notification from the main thread, begins updating the list of disabled particles, the list of sub-activated particles, and the sub-particle pool for the target special effect. The main thread, after synchronizing data with the sub-thread upon completion of the current game frame rendering, updates each main activated particle list and main particle pool. Then, it obtains the world reference data and rendering object address for each activated particle and writes it to the main particle pool. Finally, based on the main activated particle list and main particle pool for each target special effect, it renders each target special effect in the next game frame. 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. Then, after synchronizing data with the sub-thread upon completion of the current game frame rendering, the main thread updates the world reference data of the activated particles. This multi-threaded mechanism for particle data updating is highly efficient and does not affect the game frame rate, thus effectively ensuring game performance and not impacting the player experience.

[0078] In an optional implementation, the child thread checks the expiration time of each active particle in the child particle pool to determine if the active particle has reached its lifespan and needs to be re-launched. Correspondingly, in Figure 2 Based on this, please combine Figure 3 The sub-steps of step S101 above may include S1011 to S1015.

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

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

[0081] S1013. If the current time coincides with the expiration time of the target activated particle, the sub-thread removes the target activated particle from the sub-activated particle list of the target effect and adds the target activated particle to the dormant particle list and the expiration particle list of the target effect.

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

[0083] In this embodiment, for each activated particle in the sub-activated particle list of each target effect, the sub-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 needs to be removed from the sub-activated particle list. Then, the activated particle is added to the dormant particle list and the expired particle list of the corresponding target effect.

[0084] S1015: The sub-thread determines the sub-activated particle list of each target 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 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 effect, obtain the real-time frame rate and the preset particle emission speed in the particle resource data of the target effect.

[0088] S10152. Based on the real-time frame rate and particle emission speed, calculate the number of newly activated particles for the target effect in the next game frame.

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

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

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

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

[0093] In the optional implementation, after the main thread and child thread synchronize data, the main thread can update the main active particle list and the first field of the main particle pool, and handle the invalidation of the rendering object addresses of each invalidated particle in the main particle pool. Correspondingly, in Figure 2 Based on this, please refer to Figure 4 The sub-steps of step S103 above may include S1031 to S1035.

[0094] S1031. When the main thread finishes rendering the current game frame, it synchronizes data with the child thread to obtain the list of failed particles, the list of sub-activated particles, and the sub-particle pool for each target effect.

[0095] S1032. The sub-thread clears the list of each failed particle when data synchronization is complete.

[0096] In this embodiment, when the main thread finishes rendering the current game frame, it synchronizes data with the child thread to obtain the list of failed particles, the list of sub-activated particles, and the sub-particle pool for each target effect. When the data synchronization is complete, the child thread clears the list of failed particles for each target effect, so as not to affect the next effect update process for each target effect.

[0097] S1033. The main thread performs failure processing on the rendering object address corresponding to each failed particle in the main particle pool of each target effect based on the list of failed particles for each target effect.

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

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

[0100] S10332. If the address field is not 0, the main thread will delete the rendering object at the address of the rendering object in the address field and then set the address field to 0.

[0101] S10333: The main thread iterates through each failed particle in the list of failed particles for each target effect, and updates the address field of each failed particle in the main particle pool.

[0102] For each failed particle in the list of failed particles for each target effect, execute steps S10331 to S10333 above to complete the failure handling of the rendering object address corresponding to all failed particles.

[0103] S1034. The main thread clears the main active particle list of each target effect and then updates it to match the sub-active particle list of each target effect.

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

[0105] In this embodiment, the main thread will update the first field of the main particle pool of each target effect by overwriting the sub-particle pool of each target effect.

[0106] The following uses a fire effect as an example to illustrate the changes in the sub-activated particle list, dormant particle list, inactive particle list, and main activated particle list during the execution of steps S101 to S103 and their sub-steps during an effect update.

[0107] In an optional example, assuming the target effect is a fire effect with a maximum particle count N = 10, if the current game frame rendering ends, the sub-active particle list, dormant particle list, and inactive particle list of the fire effect maintained by the sub-thread, and the main active particle list of the fire effect maintained by the main thread are as shown in Table (1) below:

[0108] Table (1)

[0109] Sub-activated particle list List of dormant particles List of Failed Particles Main Activated Particle List Id0 Id5 Id0 Id1 Id6 Id1 Id2 Id7 Id2 Id3 Id8 Id3 Id4 Id9 Id4

[0110] The child thread sequentially checks the expiration times of the five active particles (Id0 to Id4) in Table (1) from the sub-particle pool of the flame effect. If it finds that the expiration times of active particles Id0, Id2, and Id3 are consistent with the current time, then the child thread will remove particles Id0, Id2, and Id3 from the sub-active particle list and add them to the dormant particle list and the expiration particle list. At this time, the four lists are as shown in Table (2) below:

[0111] Table (2)

[0112] Sub-activated particle list List of dormant particles List of Failed Particles Main Activated Particle List Id1 Id3 Id3 Id0 Id4 Id2 Id2 Id1 Id0 Id0 Id2 Id5 Id3 Id6 Id4 Id7 Id8 Id9

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

[0114] Table (3)

[0115] Sub-activated particle list List of dormant particles List of Failed Particles Main Activated Particle List Id3 Id6 Id3 Id0 Id2 Id7 Id2 Id1 Id0 Id8 Id0 Id2 Id5 Id9 Id3 Id1 Id4 Id4

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

[0117] Table (4)

[0118] Sub-activated particle list List of dormant particles List of Failed Particles Main Activated 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 row numbers in the table above represent the list capacity, which is consistent with the maximum number of particles N=10. An empty table simply means that the list is not full. The above example is for illustrative purposes only and is not intended to be limiting.

[0120] In an optional implementation, the main thread also needs to determine the world reference data and rendering object address of each active particle in the main active particle list of each target effect, and write them into the second field and address field of the main particle pool of each target effect, respectively, to ensure the successful rendering of each target 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 effect, the main thread calculates the world reference data corresponding to each active particle in the main active particle list of the target effect in the next game frame, and writes it into the main particle pool of the target effect.

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

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

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

[0125] In this embodiment, for a target effect, if there are active particles with an address field of zero in its main active 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 effect. This ensures that the main thread can identify the rendering model of each active particle through the address of the rendering object recorded in the address field during rendering.

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

[0127] It is understandable that for each target effect, the main thread executes the above steps S1041 to S1043 once, thereby updating the second field and address field of the activated particles in the main particle pool for each target effect.

[0128] It should be noted that the execution order of each step in the above method embodiments is not limited to that shown in the attached figures, and the execution order of each step shall be subject to the actual application situation.

[0129] In order to perform the corresponding steps in the above method embodiments and various possible implementations, an implementation of a special effects update device is given below.

[0130] The present invention also provides a special effects update device, which is applied to an electronic device. The device includes a main thread and a sub-thread. The main thread maintains a main particle pool and a main active 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 active particle of the special effect in the current game frame. The sub-thread maintains a sub-particle pool, a sub-active particle list, a dormant particle list, and a deactivated particle list for 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 active particle of the target special effect in the next game frame.

[0131] The child thread is used to update the dormant particle list and inactive particle list of each target effect based on the sub-particle pool of each target effect when it receives the next frame update notification from the main thread, and obtain the sub-active particle list of each target effect in the next game frame.

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

[0133] The main thread is used to synchronize the list of disabled particles, the list of sub-activated particles, and the sub-particle pool for each target effect from the child thread when the current game frame is rendered to update the main activated particle list and the main particle pool for each target effect.

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

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

[0136] Optionally, local reference data may include expiration times. When the sub-thread receives a next-frame update notification from the main thread, it updates the dormant particle list and expiration particle list of each target effect based on the sub-particle pool of each target effect, and obtains the sub-active particle list of each target effect in the next game frame. During this process, the main thread can send a next-frame update notification to the sub-thread when it completes the world reference data update for each active particle in the current game frame. Specifically, the sub-thread can: for any active particle in the sub-active particle list of each target effect, read the expiration time of the active particle from the sub-particle pool; if the current time matches the expiration time of the active particle, remove the active particle from the sub-active particle list of the target effect and add it to the dormant particle list and expiration particle list of the target effect; traverse each active particle in the sub-active particle list of each target effect to obtain a new dormant particle list and expiration particle list for each target effect; and determine the sub-active particle list of each target 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 effect.

[0137] Optionally, the sub-thread is used to determine the sub-activated particle list of each target 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 effect. Specifically, it can be used to: for any target effect, obtain the real-time frame rate and the preset particle emission speed in the particle resource data of the target effect; calculate the number of newly activated particles for the target effect in the next game frame based on the real-time frame rate and particle emission speed; remove S dormant particles from the dormant particle list of the target effect and add them to the sub-activated particle list of the target effect, where S represents the number of newly activated particles; traverse each target effect to obtain the sub-activated particle list of each target effect in the next game frame.

[0138] Optionally, the main thread is used to synchronize the list of disabled particles, the list of sub-activated particles, and the sub-particle pool for each target effect from the child thread to update the list of main activated particles and the main particle pool for each target effect when the current game frame has finished rendering:

[0139] The main thread synchronizes data with the child thread to obtain the list of failed particles, the list of sub-activated particles, and the sub-particle pool for each target effect when the current game frame is rendered. The child thread clears each failed particle list when data synchronization is complete. The main thread performs invalidation processing on the rendering object address corresponding to each failed particle in the main particle pool of each target effect based on the failed particle list of each target effect. The main thread clears the main activated particle list of each target effect and updates it to be consistent with the sub-activated particle list of each target effect. The main thread updates the sub-particle pool of each target effect to the main particle pool of each target effect.

[0140] Optionally, the main particle pool includes an address field for storing the address of the rendered object. The main thread uses this field to handle the invalidation of the rendered object address corresponding to each invalid particle in the main particle pool of each target effect based on the invalid particle list of each target effect. Specifically, this can be done as follows: for any invalid particle in the invalid particle list of any target effect, read the address field of the invalid particle from the main particle pool of the target effect; if the address field is not 0, delete the rendered object at the address in the address field and then set the address field to 0; traverse each invalid particle in the invalid particle list of each target effect to update the address field of each invalid particle in the main particle pool.

[0141] Optionally, the main particle pool includes an address field for storing the address of the rendered object. When the main thread obtains the world reference data and rendered object address of each active particle in the main active particle list for each target effect and writes them into the main particle pool of each target effect, it can specifically be used for: For any target effect, calculating the world reference data corresponding to each active particle in the main active particle list of the target effect in the next game frame and writing it into the main particle pool of the target effect; For each active particle in the main active particle list of the target effect, checking if the address field of the active particle in the main particle pool of the target effect is zero; if so, creating a new rendered object and writing its address pointer into the address field of the active particle in the main particle pool of the target effect; Traversing each target effect to obtain the main particle pool of each target effect required for rendering in the next game frame.

[0142] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working process of the special effects update device described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0143] Please see Figure 5 , Figure 5This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. The electronic device 300 includes a processor 310, a memory 320, and a bus 330, with the processor 310 connected to the memory 320 via the bus 330.

[0144] The memory 320 can be used to store software programs, such as the software program corresponding to the special effects update device provided in the embodiments of the present invention. The processor 310 executes various functional applications and data processing by running the software program stored in the memory 320 to implement the special effects update method provided in the embodiments of the present invention.

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

[0147] Understandable. Figure 5 The structure shown is for illustrative purposes only; the electronic device 300 may also include components that are more advanced than those shown. Figure 5 The more or fewer components shown, or having the same Figure 5 The different configurations shown. Figure 5 The components shown can be implemented using hardware, software, or a combination thereof.

[0148] This invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the special effects update method disclosed in the above embodiments. The computer-readable storage medium can be, but is not limited to, various media capable of storing program code, such as a USB flash drive, external hard drive, ROM, RAM, PROM, EPROM, EEPROM, FLASH disk, or optical disk.

[0149] In summary, this invention provides a method, apparatus, electronic device, and computer-readable storage medium for updating special effects. The electronic device operates a main thread and sub-threads. The main thread maintains a main particle pool and a main active particle list for each special effect involved in the current game scene. The main particle pool stores the local reference data, world reference data, and rendering object address of each active particle of the special effect in the current game frame. The sub-thread maintains a sub-particle pool, a sub-active particle list, a dormant particle list, and a deactivated particle list for at least one target special effect involved in the current game scene. The sub-particle pool stores the local reference data of each active particle of the target special effect in the next game frame. During the special effect update process for the next frame, the sub-thread starts updating the deactivated particle list, sub-active particle list, and sub-particle pool of the target special effect when it receives the next frame update notification from the main thread. After the main thread finishes rendering the current game frame, it synchronizes data with the sub-thread and updates each main active particle list and main particle pool. Then, it obtains the world reference data and rendering object address of each active particle and writes it into the main particle pool. Finally, it renders each target special effect in the next game frame based on the main active particle list and main particle pool of each target special effect. In this way, the main thread notifies the child thread to update the local reference data of each active particle in the next game frame. Then, after the main thread finishes rendering the current game frame, it synchronizes the data with the child thread and updates the world reference data of the active particles. This multi-threaded mechanism for particle data updates is highly efficient, thus effectively ensuring game performance and not affecting the player experience.

[0150] The above are merely specific embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims

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

2. The method according to claim 1, characterized in that, The local reference data includes the expiration time; the step of the sub-thread updating the dormant particle list and expiration particle list of each target effect based on the sub-particle pool of each target effect when it receives the next frame update notification from the main thread, and obtaining the sub-active particle list of each target effect in the next game frame, includes: When the main thread completes the world reference data update for each activated particle in the current game frame, it sends the next frame update notification to the child thread. For any target active particle in the sub-active particle list of each target effect, the sub-thread reads the expiration time of the target active particle from the sub-particle pool; If the current time coincides with the expiration time of the target activated particle, the sub-thread removes the target activated particle from the sub-activated particle list of the target effect and adds the target activated particle to the dormant particle list and the expiration particle list of the target effect. The sub-thread iterates through each active particle in the sub-activated particle list of each target effect to obtain a new dormant particle list and a deactivated particle list for each target effect. The sub-thread determines the sub-activated particle list of each target 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 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 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 effect includes: For any of the target effects, obtain the real-time frame rate and the preset particle emission speed in the particle resource data of the target effect; Based on the real-time frame rate and the particle emission speed, calculate the number of newly activated particles for the target effect in the next game frame; Remove S dormant particles from the dormant particle list of the target effect and add them to the sub-activated particle list of the target effect, where S represents the number of newly activated particles. Iterate through each of the target effects to obtain a list of sub-activated particles for each target effect in the next game frame.

4. The method according to claim 1, characterized in that, The main thread, upon completion of rendering the current game frame, synchronizes the list of disabled particles, the list of sub-activated particles, and the sub-particle pool for each target effect from the sub-thread to update the main activated particle list and the main particle pool for each target effect. This includes: When the current game frame is rendered, the main thread synchronizes data with the sub-thread to obtain the list of failed particles, the list of sub-activated particles, and the sub-particle pool for each target effect. The sub-thread clears the list of each failed particle when data synchronization is complete. The main thread performs failure processing on the rendering object address corresponding to each failed particle in the main particle pool of each target effect based on the list of failed particles of each target effect. The main thread clears the main active particle list of each target effect and then updates it to match the sub-active particle list of each target effect. The main thread will update the sub-particle pool of each target effect to the main particle pool of each target effect respectively.

5. The method according to claim 4, characterized in that, The main particle pool includes an address field for storing the address of the rendering object; The main thread performs failure processing on the rendering object address corresponding to each failed particle in the main particle pool of each target effect based on the failed particle list of each target effect, including: For any failed particle in the failed particle list of any target effect, the main thread reads the address field of the failed particle from the main particle pool of the target effect; If the address field is not 0, the main thread deletes the rendering object at the address of the rendering object in the address field and then sets the address field to 0; The main thread iterates through each failed particle in the list of failed particles for each target effect, and updates the address field of each failed particle 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 address of the rendering object; The step of the main thread obtaining the world reference data and rendering object address of each active particle in the main active particle list of each target effect, and writing them into the main particle pool of each target effect, includes: For any of the target effects, the main thread calculates the world reference data corresponding to each active particle in the main active particle list of the target effect in the next game frame, and writes it into the main particle pool of the target effect; For each active particle in the main active particle list of the target effect, the main thread checks whether the address field of the active particle in the main particle pool of the target effect is zero; if so, a new rendering object is created and its address pointer is written into the address field of the active particle in the main particle pool of the target effect. The main thread iterates through each target effect to obtain the main particle pool for each target effect required for rendering the next game frame.

7. A special effects update device, characterized in that, The device is applied to an electronic device, which includes a main thread and a sub-thread. The main thread maintains a main particle pool and a main active particle list for each 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 active particle of the effect in the current game frame. The sub-thread maintains a sub-particle pool, a sub-active particle list, a dormant particle list, and a deactivated particle list for at least one target effect involved in the current game scene. The sub-particle pool is used to store the local reference data of each active particle of the target effect in the next game frame. The sub-thread is used to update the dormant particle list and inactive particle list of each target effect based on the sub-particle pool of each target effect when it receives the next frame update notification from the main thread, and obtain the sub-activated particle list of each target effect in the next game frame. The sub-thread is also used to calculate the local reference data corresponding to each active particle in the sub-activated particle list of each target effect in the next game frame based on the particle resource data of each target effect, and write it into the sub-particle pool of each target effect respectively. The main thread is used to synchronize the list of failed particles, the list of sub-activated particles, and the sub-particle pool of each target effect from the sub-thread when the current game frame is rendered to update the main activated particle list and the main particle pool of each target effect. The main thread is used to obtain the world reference data and rendering object address of each active particle in the main active particle list of each target effect, and write them into the main particle pool of each target effect respectively. The main thread is also used to render each of the target effects in the next game frame based on the main active particle list and main particle pool of each target effect.

8. The apparatus according to claim 7, characterized in that, The local reference data includes the expiration time; when the sub-thread receives the next frame update notification from the main thread, it updates the dormant particle list and expiration particle list of each target effect based on the sub-particle pool of each target effect, and obtains the sub-active particle list of each target effect in the next game frame. During this process, the main thread sends the next frame update notification to the sub-thread when it completes the world reference data update for each active particle in the current game frame. The sub-thread is specifically used for: For any target activated particle in the sub-activated particle list for each target effect, read the expiration time of the target activated particle from the sub-particle pool; If the current time coincides with the expiration time of the target activated particle, then the target activated particle is removed from the sub-activated particle list of the target effect, and the target activated particle is added to the dormant particle list and the expiration particle list of the target effect. Iterate through each active particle in the sub-activated particle list of each target effect to obtain a new dormant particle list and a deactivated particle list for each target effect; Based on the real-time frame rate and the preset particle emission speed and dormant particle list of each target effect, the sub-activated particle list of each target 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 the processor executes the software program when the electronic device is running to implement the special effects update 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 that, when executed by a processor, implements the special effects update method according to any one of claims 1-7.

Citation Information

Patent Citations

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

    CN104102488A

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

    CN114387241A