Dynamic Fluid Effect Processing Method, Apparatus, Electronic Device, and Readable Medium
By processing the positions of fluid particles in parallel on the mobile terminal, the problem of large amount of fluid simulation calculation in the prior art is solved, and real-time display of fluid movement is realized.
Patent Information
- Application Number
- CN202010796955.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-08-10
- Publication Date
- 2025-06-24
- Estimated Expiration
- 2040-12-10
AI Technical Summary
In the prior art, the fluid simulation method has a large amount of calculation and is difficult to realize real-time display on a mobile terminal.
By starting at least two threads, each thread corresponds to some fluid particles of the fluid. When the fluid is subjected to external forces, the position of the fluid particles corresponding to each thread is adjusted in parallel through at least two threads to dynamically display the movement changes of the fluid.
The calculation speed is improved, allowing the mobile terminal to display the movement changes of the fluid in real time.
Smart Images

Figure CN114078177B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technologies, and more particularly, to a method, an apparatus, an electronic device, and a readable medium for processing dynamic fluid effects. Background Art
[0002] Computer Graphics (CG) is a science that uses mathematical algorithms to convert two-dimensional or three-dimensional graphics into a raster form for a computer monitor. Simply put, the main research content of computer graphics is to study how to represent graphics in a computer and the related principles and algorithms for performing graphics calculations, processing, and display using a computer.
[0003] Fluid simulation based on physical animation is an important research area in computer graphics. With the development of mobile communication and computer technologies, mobile terminals have been widely used. Since the fluid simulation method in the prior art requires a very large amount of computation, if this method is applied to a mobile terminal, due to the very limited computing and storage resources on the mobile terminal, the computing speed is slow using the method in the prior art and cannot meet the real-time requirement. Summary of the Invention
[0004] The present disclosure provides a method, an apparatus, an electronic device, and a readable medium for processing dynamic fluid effects to solve the problems existing in the prior art.
[0005] In a first aspect, a method for processing dynamic fluid effects is provided. The method includes:
[0006] Start at least two threads, where each thread corresponds to a part of the fluid particles of the fluid, and the fluid particles corresponding to different threads are different;
[0007] When the fluid is subjected to an external force, parallelly adjust the positions of the fluid particles corresponding to each thread through at least two threads to dynamically display the movement and change of the fluid on a user display interface.
[0008] In a second aspect, an apparatus for processing dynamic fluid effects is provided. The apparatus includes:
[0009] A start module for starting at least two threads, where each thread corresponds to a part of the fluid particles of the fluid, and the fluid particles corresponding to different threads are different;
[0010] An adjustment module for, when the fluid is subjected to an external force, parallelly adjusting the positions of the fluid particles corresponding to each thread through at least two threads to dynamically display the movement and change of the fluid on a user display interface.
[0011] In a third aspect, the present disclosure provides an electronic device, which includes:
[0012] One or more processors;
[0013] A memory storing one or more applications, wherein when the one or more applications are executed by the one or more processors, the electronic device is caused to perform operations corresponding to the dynamic fluid effect processing method as shown in the first aspect of the present disclosure.
[0014] In a fourth aspect, the present disclosure provides a computer-readable medium for storing computer instructions, which when executed by a computer, cause the computer to execute the dynamic fluid effect processing method as shown in the first aspect of the present disclosure.
[0015] The beneficial effects brought by the technical solutions provided by the present disclosure may include:
[0016] In the dynamic fluid effect processing method, device, electronic device, and readable medium provided by the embodiments of the present disclosure, at least two threads are started, and each thread corresponds to a part of the fluid particles of the fluid, and the fluid particles corresponding to different threads are different; when the fluid is subjected to an external force, the positions of the fluid particles corresponding to each thread are adjusted in parallel through at least two threads to dynamically display the movement change of the fluid on the user display interface. The technical solution provided by the present disclosure improves the calculation speed by calculating the positions of the fluid particles in parallel through at least two threads, enabling the mobile terminal to display the movement change of the fluid in real time. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure, the following will briefly introduce the drawings required for the description of the embodiments of the present disclosure.
[0018] Figure 1 A flowchart showing a dynamic fluid effect processing method provided by an embodiment of the present disclosure;
[0019] Figure 2 A schematic diagram showing the execution process of the dynamic fluid effect processing method provided by an embodiment of the present disclosure;
[0020] Figure 3 A schematic diagram showing the structure of a dynamic fluid effect processing device provided by an embodiment of the present disclosure;
[0021] Figure 4 A schematic diagram showing the structure of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0022] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although some embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Instead, these embodiments are provided to more thoroughly and completely understand the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for illustrative purposes and are not used to limit the protection scope of the present disclosure.
[0023] It should be understood that the various steps recited in the method embodiments of the present disclosure can be executed in a different order and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this regard.
[0024] As used herein, the term "including" and its variations are open-ended, that is, "including but not limited to". The term "based on" is "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0025] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish devices, modules or units, and are not used to limit that these devices, modules or units must be different devices, modules or units, nor are they used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0026] It should be noted that the modifications of "one" and "multiple" mentioned in the present disclosure are illustrative rather than restrictive. Those skilled in the art should understand that unless clearly specified otherwise in the context, it should be understood as "one or more".
[0027] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only for illustrative purposes and are not used to limit the scope of these messages or information.
[0028] The technical solutions of the present disclosure and how the technical solutions of the present disclosure solve the above technical problems will be described in detail below with specific embodiments. These several specific embodiments below can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present disclosure will be described below with reference to the accompanying drawings.
[0029] The technical solution of the present disclosure can be applied to application programs related to the production, application, and use of dynamic fluid effects. The technical solution of the present disclosure can be applied to terminal devices, which can include mobile terminals or computer devices. Among them, mobile terminals can include, for example, smart phones, personal digital assistants, tablet computers, wearable devices with display screens, etc.; computer devices can include, for example, desktop computers, laptop computers, all-in-one computers, smart TVs, etc. By modeling the fluid in three-dimensional space through the technical solution of the present disclosure, the effect image after rendering the fluid model is displayed in a two-dimensional user display interface. (For the sake of simplicity, hereinafter, the model rendering effect image of the fluid displayed in the user display interface is simply referred to as "fluid"). When displaying the dynamic effect of the fluid, it can be displayed in the form of a video or a dynamic picture.
[0030] Figure 1 It is a schematic flowchart of a method for processing dynamic fluid effects provided by an embodiment of the present disclosure. As Figure 1 shown, the method may include:
[0031] Step S101, start at least two threads, each thread corresponding to a part of the fluid particles of the fluid, and the fluid particles corresponding to different threads are different;
[0032] The technical solution of the present disclosure can be implemented by a Graphics Processing Unit (GPU) in a terminal device. The GPU can include multiple cores, and each core can be a computing unit corresponding to a thread. The terminal device starts the threads corresponding to at least two cores of the GPU, and distributes the fluid particles to at least two threads. Each thread corresponds to a part of the fluid particles of the fluid, and different threads correspond to different fluid particles.
[0033] Step S102, when the fluid is subjected to an external force, parallelly adjust the positions of the fluid particles corresponding to each thread through at least two threads, so as to dynamically display the movement change of the fluid in the user display interface.
[0034] When the fluid is subjected to an external force, each fluid particle will change its position according to the external force. Through each thread in at least two threads, the position of the fluid particles corresponding to the thread is adjusted, so that the terminal device can control the fluid particles to move from the position before the external force acts to the adjusted position, and dynamically display the movement change of the fluid in the user display interface.
[0035] In the technical solution of the present disclosure, the positions of the fluid particles are calculated in parallel through at least two threads, which improves the computing speed of the terminal device, so that the terminal device can display the movement change of the fluid in real time.
[0036] Adjust the positions of the corresponding fluid particles through each thread. The specific implementation method is shown in the following embodiments.
[0037] In a possible implementation, each thread adjusts the positions of its corresponding fluid particles in the following manner:
[0038] Determine the respective positions p′ of each fluid particle according to the magnitude of the external force.
[0039] Determine the respective neighbor particles corresponding to each fluid particle according to the positions of the fluid particles.
[0040] For each fluid particle, adjust the position of the fluid particle according to the positions of the neighbor particles of the fluid particle.
[0041] In practical applications, first, the terminal device obtains the current positions and current velocities of the fluid particles of the fluid. When the fluid is under the action of an external force (e.g., gravity), the terminal device determines the acceleration of each fluid particle according to the magnitude of the external force. According to the current velocity, acceleration, and movement time of each fluid particle, the distance and direction of movement of each fluid particle can be determined. The terminal device can determine the positions of each fluid particle after being under the action of the external force as the respective positions p′ of each fluid particle.
[0042] The terminal device determines the respective neighbor particles corresponding to each fluid particle according to the positions of the fluid particles. The neighbor particles can be the fluid particles within a preset distance range from the current fluid particle. Each fluid particle may have no neighbor particles or at least one neighbor particle. The terminal device adjusts the position of the fluid particle according to the position p′ of the fluid particle and the positions of the neighbor particles of the fluid particle. In one embodiment, a fluid particle may also have no neighbor particles. In this case, the position of the fluid particle will not be affected by the neighbor particles. Therefore, the terminal device may not adjust the position of this particle.
[0043] In the embodiments of the present disclosure, when adjusting the positions of the fluid particles, by considering the positions of the neighbor particles, it is possible to ensure that the density of the fluid remains unchanged after movement as much as possible, thereby ensuring the incompressibility of the fluid during movement and making the simulated fluid dynamic effect closer to the movement state of the fluid in reality.
[0044] For the specific method of obtaining the neighbor particles of the fluid particles, see the following embodiments.
[0045] In a possible implementation, determining the respective neighbor particles corresponding to each fluid particle according to the positions of the fluid particles includes:
[0046] Obtain the respective action radii corresponding to each fluid particle.
[0047] Determine the neighbor particles corresponding to each fluid particle according to the position of each fluid particle and the corresponding action radius of each fluid particle.
[0048] In practical applications, the corresponding action radius of each fluid particle is pre-configured, and the specific value of the action radius can be configured according to specific needs or actual applications. When determining the neighbor particles of each fluid particle, obtain the corresponding action radius of each fluid particle pre-configured. For each fluid particle, the fluid particles whose distance from the fluid particle is less than or equal to the action radius are determined as the neighbor particles of the fluid particle.
[0049] In an example, when obtaining the neighbor particles of any fluid particle O, the terminal device calculates the distances between each fluid particle and the fluid particle O, and determines the fluid particles whose distance from the fluid particle O is less than or equal to the action radius as the neighbor particles of the fluid particle O. That is to say, the terminal device uses the fluid particle O as the center of the circle, and determines the fluid particles A, B, C, D within the sphere with the action radius of h as the neighbor particles of the fluid particle O. It can be understood that when determining the neighbor particles of other fluid particles, the fluid particles within the sphere with other fluid particles as the center of the circle and h as the radius can be used as the neighbor particles of the fluid particle. For the sake of simplicity, it will not be elaborated here.
[0050] When determining the neighbor particles of the fluid particle, the terminal device can also divide the entire space into cubic grids, and the grid side length is greater than the action radius. The terminal device can use a hash table to record the fluid particles contained in each grid. When the terminal device calculates the neighbor particles of the current fluid particle O, it only needs to calculate the distances between the fluid particle O and the fluid particles in the grid where the fluid particle O is located and the adjacent grids, without calculating the distances between the fluid particle O and all particles, thereby reducing the calculation amount and improving the calculation performance.
[0051] After the terminal device determines the neighbor particles of each fluid particle, the specific implementation method for adjusting the position of the fluid particle according to the position p' of the fluid particle and the positions of the neighbor particles of the fluid particle is shown in the following embodiments.
[0052] In a possible implementation manner, for each fluid particle, adjusting the position of the fluid particle according to the positions of the neighbor particles of the fluid particle includes:
[0053] Determine the position correction amount of the fluid particle according to the position of the fluid particle and the positions of the neighbor particles of the fluid particle; and
[0054] Adjust the position of the fluid particle according to the position correction amount.
[0055] In practical applications, the position p′ of a fluid particle and the positions of the respective neighbor particles of the fluid particle can each be a vector in a three-dimensional space. The terminal device can calculate a position correction amount based on these vectors. Moreover, the terminal device adjusts the position of the fluid particle according to the position correction amount and uses the adjusted position as the position of the fluid particle. The terminal device displays, in a user display interface, the movement of the fluid particle from its position before being subjected to an external force to the adjusted position, thereby presenting a dynamic change effect of the fluid in the user display interface.
[0056] In the technical solution of the present disclosure, the position correction amount of the fluid particle is determined through the following specific implementation manner:
[0057] In a possible implementation manner, for each fluid particle, determining the position correction amount of the fluid particle according to the position of the fluid particle and the positions of the respective neighbor particles of the fluid particle includes:
[0058] Obtaining the average density of the fluid, the constraint factor corresponding to the fluid particle, and the constraint factors respectively corresponding to the respective neighbor particles of the fluid particle;
[0059] Determining the position correction amount of the fluid particle according to the position of the fluid particle, the positions of the respective neighbor particles of the fluid particle, the action radius corresponding to the fluid particle, the constraint factor corresponding to the fluid particle, the constraint factors respectively corresponding to the respective neighbor particles of the fluid particle, and the average density of the fluid.
[0060] Among them, the average density of the fluid is a pre-configured value. For each fluid particle, the distance between the fluid particle and its respective neighbor particles can be determined according to the position of the fluid particle and the positions of the respective neighbor particles of the fluid particle.
[0061] In one example, the position correction amount corresponding to the fluid particle can be calculated by the following formula (1):
[0062]
[0063] where Δp i represents the position correction amount corresponding to the i-th fluid particle; ρ0 represents the average density of the fluid; λ i represents the constraint factor corresponding to the i-th fluid particle; λ j represents the constraint factor corresponding to the j-th neighbor particle of the i-th fluid particle; p i represents the position of the i-th fluid particle; p j represents the position of the j-th neighbor particle of the i-th fluid particle; h represents the action radius corresponding to the i-th fluid particle; w() represents a kernel function and can be calculated according to the following formulas (2)-(3):
[0064]
[0065]
[0066] where r = p i -p j ; h represents the action radius corresponding to the i-th fluid particle.
[0067] After obtaining the position correction amounts corresponding to each fluid particle, for each fluid particle, the position of the fluid particle can be adjusted by the following formula (4):
[0068] p = p′ + Δp (4)
[0069] where Δp represents the position correction amount corresponding to the fluid particle; p′ represents the position of the fluid particle; p represents the position of the fluid particle after adjustment.
[0070] In addition, in the technical solution of the present disclosure, the velocity of the fluid particle after being subjected to an external force and having its position adjusted can be determined according to the position p of the fluid particle after adjustment, the position p0 of the fluid particle before being subjected to the external force, and the pre-configured time interval for calculating the position after adjustment. The velocity of the fluid particle can be calculated by the following formula (5):
[0071]
[0072] where p represents the position of the fluid particle after adjustment; p0 represents the position of the fluid particle before being subjected to the external force, Δt represents the time interval for calculating the position after adjustment, which can be a pre-configured value. For example, Δt can be 0.006 seconds. Since the velocity of the fluid particle is calculated within a short time, the velocity of the fluid particle can be determined in the manner of uniform motion; v represents the velocity of the fluid particle after being subjected to the external force, having its position adjusted, and after a time interval of Δt.
[0073] When calculating the adjusted position and velocity of the fluid particle, the terminal device can also obtain the final output result through multiple iterative calculations. The specific number of iterations can be pre-configured according to specific needs. When displaying the movement process of the fluid particle, the terminal device moves the fluid particle from the position before being subjected to the external force to the finally output adjusted position, so as to present the dynamic change effect of the fluid in the user display interface.
[0074] For the specific implementation manner of obtaining the constraint factor, see the following embodiments:
[0075] In a possible implementation manner, for each fluid particle, obtaining the constraint factor corresponding to the fluid particle includes:
[0076] Obtain the estimated density value corresponding to the fluid particle;
[0077] Determine the density constraint value corresponding to the fluid particle according to the estimated density value corresponding to the fluid particle and the average density of the fluid;
[0078] Determine the constraint factor corresponding to the fluid particle according to the density constraint value corresponding to the fluid particle, the position of the fluid particle, the positions of the respective neighbor particles of the fluid particle, and the action radius corresponding to the fluid particle.
[0079] Among them, the average density of the fluid is a pre-configured value. According to the estimated density value corresponding to the fluid particle and the average density of the fluid, the density constraint value corresponding to the fluid particle can be determined.
[0080] In one example, the density constraint value corresponding to the fluid particle can be calculated by the following formula (6):
[0081]
[0082] Among them, C i (p1,...,p n ) represents the density constraint value corresponding to the i-th fluid particle; ρ i represents the estimated density value corresponding to the i-th fluid particle; ρ0 represents the average density of the fluid.
[0083] In addition, the constraint factor corresponding to the fluid particle can be determined according to the density constraint value corresponding to the fluid particle, the position of the fluid particle, the positions of the respective neighbor particles of the fluid particle, and the action radius corresponding to the fluid particle.
[0084] In one example, the constraint factor corresponding to the fluid particle can be calculated by the following formula (7):
[0085]
[0086] Among them, λ i represents the constraint factor corresponding to the i-th fluid particle; p k represents the position of the k-th neighbor particle corresponding to the i-th fluid particle; ε represents the relaxation parameter, which is a pre-configured constant; represents the gradient of C i (p1,...,p n ) with respect to the position of the k-th neighbor particle, and can be calculated by formula (8):
[0087]
[0088] Among them, w() represents the kernel function, which can be calculated according to formulas (2)-(3); when k = i, it represents the case where the fluid particle itself is its own neighbor particle. Otherwise, for the case of k = j, it means that the fluid particle also has other neighbor particles.
[0089] Among them, for the specific implementation of obtaining the density prediction value, see the following embodiments for details:
[0090] In a possible implementation manner, for each fluid particle, obtaining the density prediction value corresponding to the fluid particle includes:
[0091] Obtaining the masses of the respective neighbor particles of the fluid particle;
[0092] Determining the density prediction value corresponding to the fluid particle according to the masses of the respective neighbor particles of the fluid particle, the position of the fluid particle, the positions of the respective neighbor particles of the fluid particle, and the action radius corresponding to the fluid particle.
[0093] Among them, the masses of the respective neighbor particles of the fluid particle are pre-configured values, and the fluid particles in the fluid can be configured with the same mass. For each fluid particle, according to the masses of the respective neighbor particles of the fluid particle, the position of the fluid particle, the positions of the respective neighbor particles of the fluid particle, and the action radius corresponding to the fluid particle, the density prediction value corresponding to the fluid particle can be determined.
[0094] In an example, the density prediction value corresponding to the fluid particle can be calculated by the following formula (9):
[0095]
[0096] Among them, ρ i represents the density prediction value corresponding to the i-th fluid particle; m j represents the mass of the j-th neighbor particle of the i-th fluid particle; p i represents the position of the i-th fluid particle; p j represents the position of the j-th neighbor particle of the i-th fluid particle; h represents the action radius corresponding to the i-th fluid particle; w() represents the kernel function, which can be calculated according to formulas (2)-(3).
[0097] Based on the above technical solution provided by the present disclosure, the following uses a specific embodiment to explain the technical solution. This specific embodiment and its content are only for explaining a possible implementation manner of the present disclosure solution, and do not represent all implementation manners of the present disclosure solution.
[0098] As Figure 2 shown, perform step S201, and the terminal device obtains the initial velocities and positions of the respective fluid particles (as shown as "Initialization" in the figure);
[0099] When the fluid is subjected to an external force, the terminal device executes step S202 to determine the respective positions of each fluid particle according to the magnitude of the external force (as shown in "Processing External Force" in the figure);
[0100] Execute step S203 to determine the respective neighbor particles corresponding to each fluid particle according to the respective positions of the fluid particles (as shown in "Finding Neighbor Particles" in the figure);
[0101] Execute step S204 to adjust the positions of each fluid particle according to the positions of each fluid particle and the positions of the neighbor particles of each fluid particle, specifically including:
[0102] Step S2041, calculate the estimated density of each fluid particle (as shown in "Calculating ρ i ");
[0103] Step S2042, calculate the constraint factor of each fluid particle (as shown in "Calculating λ i ");
[0104] Step S2043, calculate the position offset of each fluid particle (as shown in "Calculating Δp");
[0105] Step S2044, adjust the positions of each fluid particle according to the position offsets of each fluid particle;
[0106] Among them, steps S2041 - S2044 can be calculated through N iterations to obtain the final output value. Here, N times can be a pre-set value, and the number of iterations can also be adjusted according to the actual situation and application.
[0107] Execute step S205 to output the adjusted positions of each fluid particle (as shown in "Outputting Particle Positions" in the figure).
[0108] The dynamic fluid effect processing method provided by the embodiments of the present disclosure starts at least two threads, and each thread corresponds to a part of the fluid particles of the fluid. The fluid particles corresponding to different threads are different; when the fluid is subjected to an external force, through at least two threads, the positions of the fluid particles corresponding to each thread are adjusted in parallel to dynamically display the movement changes of the fluid on the user display interface. The technical solution provided by the present disclosure improves the calculation speed by calculating the positions of fluid particles in parallel through at least two threads, enabling the mobile terminal to display the movement changes of the fluid in real time.
[0109] Based on the same principle as the method shown in Figure 1 In the embodiments of the present disclosure, a dynamic fluid effect processing device 30 is also provided, as shown in Figure 3 shown, the dynamic fluid effect processing device 30 may include:
[0110] A startup module 31 for starting at least two threads, each thread corresponding to a part of the fluid particles, and the fluid particles corresponding to different threads being different;
[0111] An adjustment module 32 for, when the fluid is subjected to an external force, parallelly adjusting the positions of the fluid particles corresponding to each thread through at least two threads, so as to dynamically display the movement and change of the fluid on the user display interface.
[0112] In a possible implementation manner, when the adjustment module 32 parallelly adjusts the positions of the fluid particles corresponding to each thread through at least two threads, each thread adjusts the positions of the fluid particles corresponding to it in the following manner:
[0113] Determine the positions of the respective fluid particles according to the magnitude of the external force;
[0114] Determine the respective neighbor particles corresponding to the respective fluid particles according to the positions of the respective fluid particles;
[0115] For each fluid particle, adjust the position of the fluid particle according to the positions of the neighbor particles of the fluid particle.
[0116] In a possible implementation manner, when the adjustment module 32 determines the respective neighbor particles corresponding to the respective fluid particles according to the positions of the respective fluid particles, it is used for:
[0117] Obtain the action radius corresponding to each fluid particle;
[0118] Determine the respective neighbor particles corresponding to the respective fluid particles according to the positions of the respective fluid particles and the action radius corresponding to each fluid particle.
[0119] In a possible implementation manner, for each fluid particle, when the adjustment module 32 adjusts the position of the fluid particle according to the positions of the neighbor particles of the fluid particle, it is used for:
[0120] Determine the position correction amount of the fluid particle according to the position of the fluid particle and the positions of the neighbor particles of the fluid particle;
[0121] Adjust the position of the fluid particle according to the position correction amount.
[0122] In a possible implementation manner, for each fluid particle, when the adjustment module 32 determines the position correction amount of the fluid particle according to the position of the fluid particle and the positions of the neighbor particles of the fluid particle, it is used for:
[0123] Obtain the average density of the fluid, the constraint factor corresponding to the fluid particle, and the constraint factors corresponding to the respective neighbor particles of the fluid particle;
[0124] Determine the position correction amount of the fluid particle based on the position of the fluid particle, the positions of the respective neighbor particles of the fluid particle, the action radius corresponding to the fluid particle, the constraint factor corresponding to the fluid particle, the respective constraint factors corresponding to the respective neighbor particles of the fluid particle, and the average density of the fluid.
[0125] In a possible implementation manner, for each fluid particle, when the adjustment module 32 obtains the constraint factor corresponding to the fluid particle, it is used to:
[0126] Obtain the estimated density value corresponding to the fluid particle;
[0127] Determine the density constraint value corresponding to the fluid particle according to the estimated density value corresponding to the fluid particle and the average density of the fluid;
[0128] Determine the constraint factor corresponding to the fluid particle according to the density constraint value corresponding to the fluid particle, the position of the fluid particle, the positions of the respective neighbor particles of the fluid particle, and the action radius corresponding to the fluid particle.
[0129] In a possible implementation manner, for each fluid particle, when the adjustment module 32 obtains the estimated density value corresponding to the fluid particle, it is used to:
[0130] Obtain the respective masses of the respective neighbor particles of the fluid particle;
[0131] Determine the estimated density value corresponding to the fluid particle according to the respective masses of the respective neighbor particles of the fluid particle, the position of the fluid particle, the positions of the respective neighbor particles of the fluid particle, and the action radius corresponding to the fluid particle.
[0132] The dynamic fluid effect processing device of the embodiments of the present disclosure can execute the dynamic fluid effect processing method provided by the embodiments of the present disclosure, and the implementation principles are similar. The actions performed by the respective modules in the dynamic fluid effect processing device in the embodiments of the present disclosure correspond to the steps in the dynamic fluid effect processing method in the embodiments of the present disclosure. For the detailed function descriptions of the respective modules of the dynamic fluid effect processing device, reference can specifically be made to the descriptions in the corresponding dynamic fluid effect processing method shown above, and details are not described herein again.
[0133] The dynamic fluid effect processing device provided by the embodiments of the present disclosure starts at least two threads, and each thread corresponds to a part of the fluid particles of the fluid, and the fluid particles corresponding to different threads are different; when the fluid is subjected to an external force, the positions of the fluid particles corresponding to each thread are adjusted in parallel through at least two threads to dynamically display the movement change of the fluid on the user display interface. The technical solution provided by the present disclosure improves the calculation speed by calculating the positions of the fluid particles in parallel through at least two threads, so that the mobile terminal can display the movement change of the fluid in real time.
[0134] Reference is made below to Figure 4 , which shows a schematic structural diagram of an electronic device 600 suitable for implementing the embodiments of the present disclosure. The execution subject of the technical solutions of the embodiments of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Tablet Computers), PMPs (Portable Multimedia Players), vehicle terminals (such as vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 4 The electronic device shown is merely an example and should not impose any limitations on the functions and usage scope of the embodiments of the present disclosure.
[0135] The electronic device includes: a memory and a processor. Here, the processor may be referred to as the processing device 601 described below. The memory may include at least one of the read-only memory (ROM) 602, random access memory (RAM) 603, and storage device 608 described below, as specifically shown below:
[0136] As Figure 4 shown, the electronic device 600 may include a processing device (such as a central processing unit, a graphics processing unit, etc.) 601, which may perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 602 or the program loaded from the storage device 608 into the random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, ROM 602, and RAM 603 are connected to each other through a bus 604. The input / output (I / O) interface 605 is also connected to the bus 604.
[0137] Generally, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or wiredly to exchange data. Although Figure 4 the electronic device 600 with various devices is shown, it should be understood that it is not required to implement or have all the shown devices. Instead, more or fewer devices may be implemented or had.
[0138] In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, an embodiment of the present disclosure includes a computer program product that includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes program code for performing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network via the communication device 609, or installed from the storage device 608, or installed from the ROM 602. When the computer program is executed by the processing device 601, the above-described functions defined in the method of the embodiment of the present disclosure are performed.
[0139] It should be noted that the above-mentioned computer-readable medium in the present disclosure can be a computer-readable signal medium or a computer-readable storage medium or any combination of the two. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium can include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, the computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. And in the present disclosure, a computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, in which computer-readable program code is carried. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, and the computer-readable signal medium can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted by any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0140] In some embodiments, the client and the server can communicate using any currently known or future-developed network protocol such as HTTP (HyperText Transfer Protocol), and can be interconnected with digital data communication in any form or medium (e.g., a communication network). Examples of communication networks include local area networks ("LAN"), wide area networks ("WAN"), the Internet (e.g., the Internet), and end-to-end networks (e.g., ad hoc end-to-end networks), as well as any currently known or future-developed network.
[0141] The above computer-readable medium can be included in the above electronic device; or can exist separately without being assembled into the electronic device.
[0142] The above computer-readable medium carries one or more programs, which when executed by the electronic device, cause the electronic device to: start at least two threads, each thread corresponding to a part of the fluid particles of the fluid, and the fluid particles corresponding to different threads are different; when the fluid is subjected to an external force, through at least two threads, parallelly adjust the positions of the fluid particles corresponding to each thread respectively, so as to dynamically display the movement and change of the fluid on the user display interface.
[0143] Computer program code for performing the operations of the present disclosure can be written in one or more programming languages or combinations thereof. The above programming languages include, but are not limited to, object-oriented programming languages - such as Java, Smalltalk, C++; and also include conventional procedural programming languages - such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, executed as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network - including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., by using an Internet service provider to connect through the Internet).
[0144] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagram may represent a module, a segment of a program, or a portion of code that contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions noted in the blocks may occur in a different order than noted in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, or they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowchart, and combinations of blocks in the block diagrams and / or flowchart, can be implemented by a dedicated hardware-based system that performs the specified functions or operations, or by a combination of dedicated hardware and computer instructions.
[0145] The modules or units described in the embodiments of the present disclosure can be implemented in software or in hardware. In some cases, the name of the module or unit does not constitute a limitation on the unit itself.
[0146] The functions described above herein can be performed, at least in part, by one or more hardware logic components. By way of example, and without limitation, the types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on a chip (SOCs), complex programmable logic devices (CPLDs), and the like.
[0147] In the context of the present disclosure, a machine-readable medium may be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0148] According to one or more embodiments of the present disclosure, the present disclosure provides a method for processing dynamic fluid effects, the method comprising:
[0149] Start at least two threads, with each thread corresponding to a part of the fluid particles of the fluid, and the fluid particles corresponding to different threads being different;
[0150] When the fluid is subjected to an external force, through the at least two threads, the positions of the fluid particles corresponding to each thread are adjusted in parallel to dynamically display the movement and change of the fluid on the user display interface.
[0151] In a possible implementation, each thread adjusts the positions of the fluid particles corresponding to it in the following manner:
[0152] Determine the positions of the respective fluid particles according to the magnitude of the external force;
[0153] Determine the respective neighbor particles corresponding to the respective fluid particles according to the positions of the respective fluid particles;
[0154] For each fluid particle, adjust the position of the fluid particle according to the positions of the neighbor particles of the fluid particle.
[0155] In a possible implementation, the determining the respective neighbor particles corresponding to the respective fluid particles according to the positions of the respective fluid particles includes:
[0156] Obtain the action radius corresponding to each of the fluid particles;
[0157] Determine the respective neighbor particles corresponding to the respective fluid particles according to the positions of the respective fluid particles and the action radius corresponding to each of the fluid particles.
[0158] In a possible implementation, for each fluid particle, the adjusting the position of the fluid particle according to the positions of the neighbor particles of the fluid particle includes:
[0159] Determine the position correction amount of the fluid particle according to the position of the fluid particle and the positions of the neighbor particles of the fluid particle;
[0160] Adjust the position of the fluid particle according to the position correction amount.
[0161] In a possible implementation, for each fluid particle, the determining the position correction amount of the fluid particle according to the position of the fluid particle and the positions of the neighbor particles of the fluid particle includes:
[0162] Obtain the average density of the fluid, the constraint factor corresponding to the fluid particle, and the constraint factors corresponding to the respective neighbor particles of the fluid particle;
[0163] Determine the position correction amount of the fluid particle according to the position of the fluid particle, the positions of the respective neighbor particles of the fluid particle, the action radius corresponding to the fluid particle, the constraint factor corresponding to the fluid particle, the respective constraint factors corresponding to the respective neighbor particles of the fluid particle, and the average density of the fluid.
[0164] In a possible implementation, for each fluid particle, obtaining the constraint factor corresponding to the fluid particle includes:
[0165] Obtain the estimated density value corresponding to the fluid particle;
[0166] Determine the density constraint value corresponding to the fluid particle according to the estimated density value corresponding to the fluid particle and the average density of the fluid;
[0167] Determine the constraint factor corresponding to the fluid particle according to the density constraint value corresponding to the fluid particle, the position of the fluid particle, the positions of the respective neighbor particles of the fluid particle, and the action radius corresponding to the fluid particle.
[0168] In a possible implementation, for each fluid particle, obtaining the estimated density value corresponding to the fluid particle includes:
[0169] Obtain the respective masses of the respective neighbor particles of the fluid particle;
[0170] Determine the estimated density value corresponding to the fluid particle according to the respective masses of the respective neighbor particles of the fluid particle, the position of the fluid particle, the positions of the respective neighbor particles of the fluid particle, and the action radius corresponding to the fluid particle.
[0171] According to one or more embodiments of the present disclosure, the present disclosure provides a dynamic fluid effect processing device, and the device includes:
[0172] A start module, configured to start at least two threads, each of the threads corresponding to a part of the fluid particles of the fluid, and the fluid particles corresponding to different threads are different;
[0173] An adjustment module, configured to, when the fluid is subjected to an external force, parallelly adjust the positions of the fluid particles corresponding to each thread through the at least two threads, so as to dynamically display the movement change of the fluid on a user display interface.
[0174] In a possible implementation, when the adjustment module parallelly adjusts the positions of the fluid particles corresponding to each thread through at least two threads, each thread adjusts the positions of the fluid particles corresponding to it in the following manner:
[0175] Determine the positions of the respective fluid particles according to the magnitudes of the external forces applied;
[0176] Determine the respective neighbor particles corresponding to the respective fluid particles according to the positions of the respective fluid particles;
[0177] For each fluid particle, adjust the position of the fluid particle according to the positions of the neighbor particles of the fluid particle.
[0178] In a possible implementation manner, when the adjustment module determines the respective neighbor particles corresponding to the respective fluid particles according to the positions of the respective fluid particles, it is configured to:
[0179] Obtain the respective action radii corresponding to the respective fluid particles;
[0180] Determine the respective neighbor particles corresponding to the respective fluid particles according to the positions of the respective fluid particles and the respective action radii corresponding to the respective fluid particles.
[0181] In a possible implementation manner, for each fluid particle, when the adjustment module adjusts the position of the fluid particle according to the positions of the neighbor particles of the fluid particle, it is configured to:
[0182] Determine the position correction amount of the fluid particle according to the position of the fluid particle and the positions of the neighbor particles of the fluid particle;
[0183] Adjust the position of the fluid particle according to the position correction amount.
[0184] In a possible implementation manner, for each fluid particle, when the adjustment module determines the position correction amount of the fluid particle according to the position of the fluid particle and the positions of the neighbor particles of the fluid particle, it is configured to:
[0185] Obtain the average density of the fluid, the constraint factor corresponding to the fluid particle, and the constraint factors corresponding to the respective neighbor particles of the fluid particle;
[0186] Determine the position correction amount of the fluid particle according to the position of the fluid particle, the positions of the neighbor particles of the fluid particle, the action radius corresponding to the fluid particle, the constraint factor corresponding to the fluid particle, the constraint factors corresponding to the respective neighbor particles of the fluid particle, and the average density of the fluid.
[0187] In a possible implementation manner, for each fluid particle, when the adjustment module obtains the constraint factor corresponding to the fluid particle, it is configured to:
[0188] Obtain the estimated density value corresponding to the fluid particle;
[0189] Determine a density constraint value corresponding to the fluid particle according to the estimated density value corresponding to the fluid particle and the average density of the fluid.
[0190] Determine a constraint factor corresponding to the fluid particle according to the density constraint value corresponding to the fluid particle, the position of the fluid particle, the positions of the respective neighbor particles of the fluid particle, and the action radius corresponding to the fluid particle.
[0191] In a possible implementation manner, for each fluid particle, when the adjustment module obtains the estimated density value corresponding to the fluid particle, it is configured to:
[0192] Obtain the respective masses of the respective neighbor particles of the fluid particle;
[0193] Determine the estimated density value corresponding to the fluid particle according to the respective masses of the respective neighbor particles of the fluid particle, the position of the fluid particle, the positions of the respective neighbor particles of the fluid particle, and the action radius corresponding to the fluid particle.
[0194] According to one or more embodiments of the present disclosure, the present disclosure provides an electronic device, including:
[0195] One or more processors;
[0196] A memory storing one or more application programs, wherein when the one or more application programs are executed by the one or more processors, the electronic device is caused to execute the dynamic fluid effect processing method.
[0197] According to one or more embodiments of the present disclosure, the present disclosure provides a computer-readable medium for storing computer instructions, which when executed by a computer, cause the computer to execute the above-mentioned dynamic fluid effect processing method.
[0198] The above description is only a preferred embodiment of the present disclosure and an explanation of the applied technical principles. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by the specific combination of the above technical features, and should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosure concept. For example, the technical solutions formed by mutually replacing the above features with the technical features (but not limited to) having similar functions disclosed in the present disclosure.
[0199] Moreover, although the operations are depicted in a particular order, this should not be construed as requiring that the operations be performed in the particular order shown or in sequential order. In certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although several specific implementation details are included in the foregoing discussion, these should not be construed as limitations on the scope of the present disclosure. Certain features that are described in the context of separate embodiments may also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment may also be implemented separately or in any suitable sub-combination in multiple embodiments.
[0200] Although the subject matter has been described in language specific to structural features and / or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms of implementing the claims.
Claims
1. A method for processing dynamic fluid effects, characterized in that, The method includes: Starting at least two threads, each thread corresponding to a part of the fluid particles of the fluid, and the fluid particles corresponding to different threads being different; When the fluid is subjected to an external force, through the at least two threads, the positions of the fluid particles corresponding to each thread are adjusted in parallel to dynamically display the movement change of the fluid on the user display interface; Wherein, each thread adjusts the positions of the fluid particles corresponding to it in the following manner: Determine the positions of the respective fluid particles according to the magnitude of the external force; Determine the respective neighbor particles corresponding to the respective fluid particles according to the positions of the respective fluid particles; Obtain the average density of the fluid, the constraint factor corresponding to the fluid particle, and the constraint factors corresponding to the respective neighbor particles of the fluid particle; Determine the position correction amount of the fluid particle according to the position of the fluid particle, the positions of the respective neighbor particles of the fluid particle, the action radius corresponding to the fluid particle, the constraint factor corresponding to the fluid particle, the constraint factors corresponding to the respective neighbor particles of the fluid particle, and the average density of the fluid; Adjust the position of the fluid particle according to the position correction amount.
2. The dynamic fluid effect processing method according to claim 1, wherein, The determining the respective neighbor particles corresponding to the respective fluid particles according to the positions of the respective fluid particles includes: Obtaining the action radius corresponding to each of the fluid particles; Determining the respective neighbor particles corresponding to the respective fluid particles according to the positions of the respective fluid particles and the action radius corresponding to each of the fluid particles.
3. The dynamic fluid effect processing method according to claim 1, wherein For each fluid particle, the obtaining the constraint factor corresponding to the fluid particle includes: Obtaining the estimated density value corresponding to the fluid particle; Determining the density constraint value corresponding to the fluid particle according to the estimated density value corresponding to the fluid particle and the average density of the fluid; Determining the constraint factor corresponding to the fluid particle according to the density constraint value corresponding to the fluid particle, the position of the fluid particle, the positions of the respective neighbor particles of the fluid particle, and the action radius corresponding to the fluid particle.
4. The dynamic fluid effect processing method according to claim 3, wherein, For each fluid particle, the obtaining the estimated density value corresponding to the fluid particle includes: Obtaining the masses of the respective neighbor particles of the fluid particle; Determining the estimated density value corresponding to the fluid particle according to the masses of the respective neighbor particles of the fluid particle, the position of the fluid particle, the positions of the respective neighbor particles of the fluid particle, and the action radius corresponding to the fluid particle.
5. A dynamic fluid effect processing device, characterized in that, The device includes: A starting module, configured to start at least two threads, each thread corresponding to a part of the fluid particles of the fluid, and the fluid particles corresponding to different threads being different; An adjusting module, configured to, when the fluid is subjected to an external force, through the at least two threads, adjust the positions of the fluid particles corresponding to each thread in parallel to dynamically display the movement change of the fluid on the user display interface; Wherein, each thread adjusts the positions of the fluid particles corresponding to it in the following manner: Determine the positions of the respective fluid particles according to the magnitude of the external force; Determine the respective neighbor particles corresponding to each of the fluid particles according to the respective positions of the fluid particles; Obtain the average density of the fluid, the constraint factor corresponding to the fluid particle, and the constraint factors corresponding to the respective neighbor particles of the fluid particle; Determine the position correction amount of the fluid particle according to the position of the fluid particle, the positions of the respective neighbor particles of the fluid particle, the action radius corresponding to the fluid particle, the constraint factor corresponding to the fluid particle, the constraint factors corresponding to the respective neighbor particles of the fluid particle, and the average density of the fluid; Adjust the position of the fluid particle according to the position correction amount.
6. An electronic device, characterized in that, Comprising: One or more processors; A memory storing one or more application programs, wherein when the one or more application programs are executed by the one or more processors, the electronic device is caused to execute the dynamic fluid effect processing method according to any one of claims 1-4.
7. A computer-readable medium, characterized in that, The computer-readable medium is used to store computer instructions, which when executed by a computer cause the computer to execute the dynamic fluid effect processing method according to any one of claims 1-4 above.
Citation Information
Patent Citations
Third-dimensional fluid simulation method referring to heat conduction and dynamic viscosity
CN106096215A
GPGPU (General Purpose Graphics Processing Unit) parallel computing method oriented to SPH (Smoothed Particle Hydrodynamics) fluid simulation
CN106484532A