Cloth simulation method and device, terminal equipment and storage medium

By using a tetrahedral-based collision constraint method, the target mesh update position in cloth simulation is calculated, which solves the safety and efficiency problems of self-collision processing in existing cloth simulation technologies and achieves efficient simulation results without self-intersection.

CN114781167BActive Publication Date: 2025-12-05MIGU CO LTD +2
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210464777.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-29
Publication Date
2025-12-05
Estimated Expiration
2042-04-29

AI Technical Summary

Technical Problem

Existing fabric simulation technology struggles to strike a balance between safety and efficiency, resulting in poor self-collision handling performance.

Method used

A tetrahedral-based collision constraint method is adopted. By obtaining the target simplex pair, the target mesh update position is calculated, and the output mesh state is determined based on the update position of the mesh to be optimized. The self-collision problem is solved by using tetrahedral collision constraints and linear complementarity problem.

Benefits of technology

The system achieves both safety and efficiency in collision handling during cloth simulation, ensuring that the final mesh state is free of self-intersections and improving simulation results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114781167B_ABST
    Figure CN114781167B_ABST
Patent Text Reader

Abstract

The application discloses a cloth simulation method and device, a terminal equipment and a storage medium. The method comprises the following steps: obtaining each target simplex pair; calculating a target grid update position according to each target simplex pair based on a tetrahedron collision constraint; obtaining an optimized grid update position in the cloth simulation according to the target grid update position, and determining an output grid state based on the optimized grid update position. The final output grid state without self-intersection is obtained through each target simplex pair, which ensures the safety of collision processing. Meanwhile, the tetrahedron collision constraint is used to provide more degrees of freedom for calculating the target grid update position, thereby accelerating the convergence and ensuring the efficiency of collision processing in the cloth simulation process. The safety and efficiency of collision processing in the cloth simulation process are considered, thereby improving the effect of cloth simulation collision processing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of animation simulation, and in particular to a cloth simulation method, apparatus, terminal device, and storage medium. Background Technology

[0002] Computer animation is a key research area in computer graphics, virtual reality, and computer vision, and it has significant application value in fields such as game entertainment, film and television animation, and computer-aided design. Cloth animation is an indispensable part of various animation scenes, and its simulation effect directly affects the realism of the image. Cloth collision is an important factor affecting the realism of cloth simulation.

[0003] Cloth simulation is typically expressed as an implicit Euler integral, discretized in the time dimension. Then, within each small time interval, the force system of the cloth is solved separately, and collisions between cloth pieces are handled to prevent self-collision (i.e., the cloth pieces interpenetrating each other). How to effectively and quickly handle self-collision is a core challenge in cloth simulation, because if the cloth engages in self-collision, the computer simulation results will significantly violate the laws of physics, severely impacting subsequent animation rendering applications.

[0004] Existing cloth simulation schemes that rely on continuous self-collision handling typically employ influence domain optimization methods or interior point methods. These methods often struggle to balance the safety and efficiency of cloth self-collision handling, thus failing to effectively address the problem of cloth collisions in simulation.

[0005] Therefore, it is necessary to propose a solution to improve the effect of fabric simulation collision handling. Summary of the Invention

[0006] The main objective of this invention is to provide a cloth simulation method, apparatus, terminal device, and storage medium, which aims to improve the effect of cloth simulation collision handling.

[0007] To achieve the above objectives, the present invention provides a fabric simulation method, the fabric simulation method comprising:

[0008] Obtain each target simplex pair;

[0009] Based on the collision constraints of tetrahedrons, the target mesh update position is calculated according to each target simplex pair;

[0010] The target mesh update position is used to obtain the mesh update position to be optimized in the cloth simulation, and the output mesh state is determined based on the mesh update position to be optimized.

[0011] Optionally, the step of obtaining the target simplex pair includes:

[0012] Get all simplexes in the triangular mesh;

[0013] Calculate the simplex pair distances between each simplex, wherein the simplex pair distances include the distances between vertices and triangles in the triangular mesh and the distances between edges;

[0014] The shape pairs whose distances are less than a preset threshold among the shape pairs are taken as the target shape pairs.

[0015] Optionally, the step of calculating the simplex pair distance between each simplex includes:

[0016] Calculate the distance between each vertex in the triangular mesh and the triangle;

[0017] Calculate the distances between each edge in the triangular mesh.

[0018] Optionally, the step of calculating the distance between each vertex in the triangular mesh and the triangle includes:

[0019] Traverse each vertex in the triangular mesh, and for each vertex, traverse each triangle in the triangular mesh to obtain the distance between each vertex and the triangle; or

[0020] The triangular mesh is spatially divided, and the distance between the vertices in each divided region and the triangles in the preset region is calculated to obtain the distance between each vertex and the triangle.

[0021] Optionally, the step of calculating the distance between each side in the triangular mesh includes:

[0022] Traverse each edge of the triangular mesh, and for each edge, traverse each edge separately to obtain the distance between each edge; or

[0023] The triangular mesh is spatially divided, and the distance between the edge in each divided region and the edge in the preset region is calculated to obtain the distance between each edge.

[0024] Optionally, the step of calculating the updated position of the target mesh based on the tetrahedral collision constraint according to each of the target simplex pairs includes:

[0025] Based on the collision constraints of tetrahedrons, collision constraint equations are constructed according to each of the target simplex pairs;

[0026] The collision constraint equations are linearized and subjected to equation substitution to calculate the updated position of the target mesh.

[0027] Optionally, the step of obtaining the update position of the mesh to be optimized in the cloth simulation based on the target mesh update position, and determining the output mesh state based on the update position of the mesh to be optimized, includes:

[0028] Calculate the safe movement distance based on the updated position of the target grid;

[0029] The update position of the mesh to be optimized in the cloth simulation is calculated based on the safe movement distance, and the output mesh state is determined based on the update position of the mesh to be optimized.

[0030] Optionally, the step of calculating the safe movement distance based on the updated position of the target grid includes:

[0031] The movement direction is determined based on the target grid update position and the position of the grid to be optimized.

[0032] Calculate the safe movement distance based on the direction of movement.

[0033] Optionally, the step of determining the movement direction based on the target mesh update position and the position of the mesh to be optimized further includes:

[0034] Obtain the input grid state;

[0035] The target mesh state is obtained by solving the elastic material based on the input mesh state;

[0036] The input grid state and the target grid state are initialized respectively to obtain the position of the grid to be optimized and the position of the target grid.

[0037] Optionally, the step of calculating the update position of the mesh to be optimized in the cloth simulation based on the safe movement distance, and determining the output mesh state based on the update position of the mesh to be optimized, includes:

[0038] Calculate the updated position of the grid to be optimized based on the grid position to be optimized and the safe movement distance;

[0039] Calculate the grid distance between the grid update position to be optimized and the target grid update position;

[0040] Determine whether the grid distance is less than a preset optimization termination threshold;

[0041] If the grid distance is less than the preset optimization termination threshold, then the update position of the grid to be optimized is taken as the output grid state.

[0042] If the mesh distance is not less than the preset optimization termination threshold, then return to the steps of performing collision constraints based on tetrahedrons, calculating the target mesh update position according to the target simplex pair, and subsequent steps.

[0043] Optionally, after the step of using the updated position of the grid to be optimized as the output grid state if the grid distance is less than the preset optimization termination threshold, the method further includes:

[0044] The output mesh state is used as the input mesh state for the next time point, and the process of obtaining each target single shape pair and subsequent steps is repeated until the fabric simulation is completed.

[0045] Furthermore, to achieve the above objectives, the present invention also provides a fabric simulation device, the fabric simulation device comprising:

[0046] The acquisition module is used to acquire each target simplex pair;

[0047] The calculation module is used to update the position of the target mesh based on the collision constraints of the tetrahedron and according to each of the target simplexes.

[0048] The output module is used to obtain the update position of the mesh to be optimized in the cloth simulation based on the target mesh update position, and to determine the output mesh state based on the update position of the mesh to be optimized.

[0049] In addition, to achieve the above objectives, the present invention also provides a terminal device, the terminal device including a memory, a processor, and a fabric simulation program stored in the memory and executable on the processor, wherein the fabric simulation program, when executed by the processor, implements the steps of the fabric simulation method as described above.

[0050] In addition, to achieve the above objectives, the present invention also provides a computer-readable storage medium storing a fabric simulation program, which, when executed by a processor, implements the steps of the fabric simulation method as described above.

[0051] This invention proposes a cloth simulation method, apparatus, terminal device, and storage medium. The method involves acquiring target simplex pairs; calculating target mesh update positions based on tetrahedral collision constraints; obtaining the mesh update position to be optimized in the cloth simulation based on the target mesh update positions; and determining the output mesh state based on the mesh update position to be optimized. By obtaining the final non-self-intersecting output mesh state through each target simplex pair, the safety of collision handling is ensured. Simultaneously, the tetrahedral collision constraints provide more degrees of freedom for calculating the target mesh update positions, thereby accelerating convergence and ensuring the efficiency of collision handling in the cloth simulation process. This approach balances the safety and efficiency of collision handling in the cloth simulation process, thus improving the effectiveness of collision handling in cloth simulation. Attached Figure Description

[0052] Figure 1This is a schematic diagram of the influence domain optimization method in related technologies;

[0053] Figure 2 This is a schematic diagram of the interior point method in related technologies;

[0054] Figure 3 This is a schematic diagram of the bidirectional interior point search method in an embodiment of the present invention;

[0055] Figure 4 This is a schematic diagram of the functional modules of the terminal equipment to which the fabric simulation device of this invention belongs;

[0056] Figure 5 This is a flowchart illustrating an exemplary embodiment of the fabric simulation method of the present invention;

[0057] Figure 6 for Figure 5 A schematic diagram of the specific process of step S10 in the embodiment;

[0058] Figure 7 for Figure 6 A schematic diagram of the specific process of step S102 in the embodiment;

[0059] Figure 8 for Figure 5 A schematic diagram of the specific process of step S20 in the embodiment;

[0060] Figure 9 This is a first schematic diagram of a tetrahedron in an embodiment of the present invention;

[0061] Figure 10 This is a second schematic diagram of a tetrahedron in an embodiment of the present invention;

[0062] Figure 11 for Figure 5 A schematic diagram of the specific process of step S30 in the embodiment;

[0063] Figure 12 This is a flowchart illustrating another exemplary embodiment of the fabric simulation method of the present invention;

[0064] Figure 13 for Figure 11 A detailed flowchart of step S302 in the embodiment is shown below;

[0065] Figure 14 This is a flowchart illustrating another exemplary embodiment of the fabric simulation method of the present invention;

[0066] Figure 15 This is a schematic diagram of the initial state of a sample cloth simulation collision processing in an embodiment of the present invention;

[0067] Figure 16 This is a schematic diagram of the output state of a sample of cloth simulation collision processing in an embodiment of the present invention;

[0068] Figure 17 This is a flowchart illustrating the bidirectional mode optimization strategy in an embodiment of the present invention.

[0069] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0070] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.

[0071] The main solution of this invention is as follows: First, obtain each target simplex pair. Second, based on tetrahedral collision constraints, calculate the target mesh update position according to each target simplex pair. Third, obtain the mesh update position to be optimized in the cloth simulation based on the target mesh update position, and determine the output mesh state based on the mesh update position to be optimized. Obtaining the final non-self-intersecting output mesh state through each target simplex pair ensures the safety of collision handling. Simultaneously, the tetrahedral collision constraints provide more degrees of freedom for calculating the target mesh update position, thereby accelerating convergence and ensuring the efficiency of collision handling in the cloth simulation process. This balances the safety and efficiency of collision handling in the cloth simulation process, thus improving the effect of collision handling in cloth simulation.

[0072] Cloth simulation is usually expressed as an implicit Euler integral, discretized in the time dimension, and then the force system of the cloth is solved in each small time interval, and the collisions between cloths are handled to prevent self-intersection (that is, the interpenetration between the cloths themselves).

[0073] Currently, in related technologies, the continuous collision processing method is commonly used. This method uses the implicit Euler equations to obtain the position of the cloth vertex / face at the next moment based on the current position of the cloth mesh vertex. The two positions form the vertex / face displacement trajectory. The continuous collision processing first detects whether there is self-intersection between the trajectories of different vertices / faces by locally solving a series of cubic equations. Then, iterative backtracking-detection-backtracking processing is performed for self-intersections until no self-intersections are detected.

[0074] Ideally, cloth self-collision handling should satisfy both safety and efficiency: safety means that self-collision never occurs during the simulation process, and efficiency means that the computation is efficient and does not introduce excessive computational complexity.

[0075] Continuous collision detection is difficult to guarantee efficiency: a large number of cubic equations need to be solved in each time interval, which is computationally expensive; furthermore, since the calculation of cubic equations is numerically unstable, continuous collision detection needs to introduce additional computational complexity to handle this numerical instability. These processes cannot be guaranteed to be effective in all cases, which means they cannot guarantee safety.

[0076] In cloth simulation techniques that rely on continuous self-collision processing, influence domain optimization methods or interior point methods are typically used.

[0077] Reference Figure 1 , Figure 1 This is a schematic diagram of the influence domain optimization method in related technologies, such as... Figure 1 As shown, the influence domain optimization method attempts to... Starting from there, the search proceeds in reverse to find the optimal solution; when These methods are efficient when close to the optimal solution, but as the time step increases, they may converge to local extrema at the boundary of the feasible region, leading to blockage and failure in finding the optimal solution; see reference. Figure 2 , Figure 2 This is a schematic diagram of the interior point method in related technologies, such as... Figure 2 As shown, the main characteristic of the interior-point method is that the optimization process starts from p [t] Starting from the feasible region k=0,1,2, the interior point method is inherently safe, but it is often inefficient: First, each search of the interior point method requires continuous collision detection, which is computationally expensive and may have numerical problems; Second, when the solution approaches the boundary of the feasible region, the convergence of the interior point method begins to slow down, which may lead to slow motion or even motion deadlock in the actual simulation process.

[0078] In conclusion, existing methods cannot simultaneously satisfy both security and efficiency.

[0079] This invention provides a novel bidirectional interior point search method, referring to... Figure 3 , Figure 3 This is a schematic diagram of the bidirectional interior point search method in an embodiment of the present invention, as shown below. Figure 3 As shown, the cloth is represented as a triangular mesh. The input of this proposal is the mesh state at the current time point and the target mesh state at the next time point obtained by using the cloth physics calculation method (which may have self-intersections). The output is the non-self-intersection mesh state at the next time point.

[0080] Here, the triangular mesh is defined as a set of triangles: F = {f i |i=0,1,...}, each triangle contains three vertices, and the position of each vertex is a coordinate in three-dimensional space: p ik =(x ik ,yik ,z ik ) T Where k = 0, 1, 2. Let the positions of all vertices of the triangular mesh be concatenated into a vector, denoted as p, and the total number of vertices be denoted as n. Any two vertices of each triangle are connected by an edge, and each triangle f... i There are three sides in total. In this invention, the triangle, sides, and vertices are collectively referred to as a simplex (this is a standard term in mathematics, expressing the most basic geometric shape), and each simplex is denoted as s. i The positional information of each simplex can be expressed as s i (p).

[0081] Here, the grid state refers to the positions of all vertices of the grid, and the grid state at the current time point is denoted as p. [t] The target grid state at the next time point is denoted as The non-self-intersecting grid state at the next time point is denoted as p. [t+1] Here, self-intersection refers to the interweaving between different triangles in a triangular mesh.

[0082] Here, the next time point refers to the new time point obtained by adding the current time point to a fixed time interval of length h. In physical simulation systems, the general calculation process is to calculate the mesh state at each time point sequentially according to the fixed time interval length.

[0083] The cloth physics calculation method refers to the implicit Euler integral method commonly used in physics simulation systems. This method takes the mesh state at the current time point as input, considers the physical material properties of the cloth (such as elasticity and rigidity), and obtains the mesh state of the cloth at the next time point. However, it does not consider self-collision between cloth pieces. Refer to the following elastic material equation:

[0084]

[0085] This elastic material equation is a commonly used equation in current physical simulation systems; where h is the time step; M∈R 3n *3n It is a mass matrix, with values ​​only in the diagonal entries, representing the mass of each vertex; The velocity at the current time point is represented by W(p); W(p) represents the internal force between adjacent vertices of the cloth, describing the physical material properties such as the cloth's elasticity, and can be calculated based on the specific cloth material. The self-collision handling method proposed in this invention is not limited to a specific physical material or a specific cloth physics calculation method, and can be selected according to the specific application scenario.

[0086] Therefore, in the implementation of this invention, a simple simulation process is used: each time interval is first based on the current grid state p [t]Solving for the elastic material yields the target mesh state at the next time point, denoted as... Then, the self-collision processing method of the present invention is used to obtain the non-self-intersecting mesh state at the next time point, denoted as p. [t+1] .

[0087] This bidirectional interior-point search method can simultaneously satisfy both security and efficiency, and has the following main advantages:

[0088] (1) Search step size that does not rely on continuous collision detection: This invention proposes a new step size strategy that can guarantee no self-intersection conditions and ensure safety by relying only on simple geometric checks and distance calculations;

[0089] (2) Efficient search direction: By constructing and solving a linear complementarity problem, an efficient search direction can be obtained with only a small amount of computation;

[0090] (3) Self-collision constraint: This invention also proposes a new tetrahedral-based collision constraint method, which provides more degrees of freedom for the solution process compared with traditional collision constraints, thereby accelerating the solution convergence.

[0091] Specifically, refer to Figure 4 , Figure 4 This is a schematic diagram of the functional modules of the terminal device to which the fabric simulation device of the present invention belongs. The fabric simulation device can be an independent device capable of fabric simulation, separate from the terminal device, and can be implemented on the terminal device in hardware or software form. The terminal device can be a smart mobile terminal with data processing capabilities, such as a mobile phone or tablet computer, or a fixed terminal device or server with data processing capabilities.

[0092] In this embodiment, the terminal device to which the fabric simulation device belongs includes at least an output module 110, a processor 120, a memory 130, and a communication module 140.

[0093] The memory 130 stores the operating system and the cloth simulation program. The cloth simulation device can store information such as the acquired target simplex pairs, tetrahedral collision constraints, target mesh update positions calculated based on the target simplex pairs, the mesh update positions to be optimized in the cloth simulation obtained based on the target mesh update positions, and the output mesh state determined based on the mesh update positions to be optimized in the memory 130. The output module 110 can be a display screen, etc. The communication module 140 can include a WIFI module, a mobile communication module, and a Bluetooth module, etc., and communicates with external devices or servers through the communication module 140.

[0094] When the fabric simulation program in memory 130 is executed by the processor, it performs the following steps:

[0095] Obtain each target simplex pair;

[0096] Based on the collision constraints of tetrahedrons, the target mesh update position is calculated according to each target simplex pair;

[0097] The target mesh update position is used to obtain the mesh update position to be optimized in the cloth simulation, and the output mesh state is determined based on the mesh update position to be optimized.

[0098] Furthermore, when the cloth simulation program in memory 130 is executed by the processor, it also performs the following steps:

[0099] Get all simplexes in the triangular mesh;

[0100] Calculate the simplex pair distances between each simplex, wherein the simplex pair distances include the distances between vertices and triangles in the triangular mesh and the distances between edges;

[0101] The shape pairs whose distances are less than a preset threshold among the shape pairs are taken as the target shape pairs.

[0102] Furthermore, when the cloth simulation program in memory 130 is executed by the processor, it also performs the following steps:

[0103] Calculate the distance between each vertex in the triangular mesh and the triangle;

[0104] Calculate the distances between each edge in the triangular mesh.

[0105] Furthermore, when the cloth simulation program in memory 130 is executed by the processor, it also performs the following steps:

[0106] Traverse each vertex in the triangular mesh, and for each vertex, traverse each triangle in the triangular mesh to obtain the distance between each vertex and the triangle; or

[0107] The triangular mesh is spatially divided, and the distance between the vertices in each divided region and the triangles in the preset region is calculated to obtain the distance between each vertex and the triangle.

[0108] Furthermore, when the cloth simulation program in memory 130 is executed by the processor, it also performs the following steps:

[0109] Traverse each edge of the triangular mesh, and for each edge, traverse each edge separately to obtain the distance between each edge; or

[0110] The triangular mesh is spatially divided, and the distance between the edge in each divided region and the edge in the preset region is calculated to obtain the distance between each edge.

[0111] Furthermore, when the cloth simulation program in memory 130 is executed by the processor, it also performs the following steps:

[0112] Based on the collision constraints of tetrahedrons, collision constraint equations are constructed according to each of the target simplex pairs;

[0113] The collision constraint equations are linearized and subjected to equation substitution to calculate the updated position of the target mesh.

[0114] Furthermore, when the cloth simulation program in memory 130 is executed by the processor, it also performs the following steps:

[0115] Calculate the safe movement distance based on the updated position of the target grid;

[0116] The update position of the mesh to be optimized in the cloth simulation is calculated based on the safe movement distance, and the output mesh state is determined based on the update position of the mesh to be optimized.

[0117] Furthermore, when the cloth simulation program in memory 130 is executed by the processor, it also performs the following steps:

[0118] The movement direction is determined based on the target grid update position and the position of the grid to be optimized.

[0119] Calculate the safe movement distance based on the direction of movement.

[0120] Furthermore, when the cloth simulation program in memory 130 is executed by the processor, it also performs the following steps:

[0121] Obtain the input grid state;

[0122] The target mesh state is obtained by solving the elastic material based on the input mesh state;

[0123] The input grid state and the target grid state are initialized respectively to obtain the position of the grid to be optimized and the position of the target grid.

[0124] Furthermore, when the cloth simulation program in memory 130 is executed by the processor, it also performs the following steps:

[0125] Calculate the updated position of the grid to be optimized based on the grid position to be optimized and the safe movement distance;

[0126] Calculate the grid distance between the grid update position to be optimized and the target grid update position;

[0127] Determine whether the grid distance is less than a preset optimization termination threshold;

[0128] If the grid distance is less than the preset optimization termination threshold, then the update position of the grid to be optimized is taken as the output grid state.

[0129] If the mesh distance is not less than the preset optimization termination threshold, then return to the steps of performing tetrahedral collision constraints, calculating the target mesh update position based on the target simplex pair, and subsequent steps.

[0130] Furthermore, when the cloth simulation program in memory 130 is executed by the processor, it also performs the following steps:

[0131] The output mesh state is used as the input mesh state for the next time point, and the process of obtaining each target single shape pair and subsequent steps is repeated until the fabric simulation is completed.

[0132] This embodiment, through the above-described scheme, specifically obtains each target simplex pair; calculates the target mesh update position based on tetrahedral collision constraints according to each target simplex pair; obtains the mesh update position to be optimized in the cloth simulation based on the target mesh update position, and determines the output mesh state based on the mesh update position to be optimized. Obtaining the final non-self-intersecting output mesh state through each target simplex pair ensures the safety of collision handling; simultaneously, the tetrahedral collision constraints provide more degrees of freedom for calculating the target mesh update position, thereby accelerating convergence and ensuring the efficiency of collision handling in the cloth simulation process. It balances the safety and efficiency of collision handling in the cloth simulation process, thus improving the effect of collision handling in cloth simulation.

[0133] Based on, but not limited to, the terminal device architecture described above, embodiments of the method of the present invention are proposed.

[0134] The subject executing the method in this embodiment can be a fabric simulation device or a terminal device, etc. This embodiment takes a fabric simulation device as an example.

[0135] Reference Figure 5 , Figure 5 This is a flowchart illustrating an exemplary embodiment of the fabric simulation method of the present invention. The fabric simulation method includes:

[0136] Step S10: Obtain each target simplex pair;

[0137] Specifically, in the triangular mesh represented by the fabric, the triangular mesh is defined as a set of triangles: F = {f i |i=0,1,...}, each triangle contains three vertices, and the position of each vertex is a coordinate in three-dimensional space: p ik =(x ik ,y ik ,z ik )T Where k = 0, 1, 2. Let the positions of all vertices of the triangular mesh be concatenated into a vector, denoted as p, and the total number of vertices be denoted as n. Any two vertices of each triangle are connected by an edge, and each triangle f... i There are three sides in total. In this embodiment of the invention, the triangle, sides, and vertices are collectively referred to as a simplex, and each simplex is denoted as s. i The positional information of each simplex can be expressed as s i (p). Among them, (s) i ,s j () represents a pair of simplexes. Based on the definitions of vertices, edges, and triangles, there may be multiple different types of simplex combinations that can form pairs. In cloth simulation, the simplex combinations that truly affect self-collision include (vertices, triangles) and (edges, edges), so this invention only calculates the distances in these two cases.

[0138] Before acquiring each target simplex pair, it is necessary to first acquire all simplexes in the triangular mesh, namely all vertices, triangles, and edges, and then calculate the distance between each simplex pair, that is, calculate the distance between the vertex and the triangle and the distance between the edges, so as to filter out simplex pairs whose distance is less than a preset threshold. In this embodiment of the invention, the preset threshold is equivalent to the thickness parameter of the fabric. Any two simplexes whose distance is less than the thickness of the fabric may cause interweaving. Therefore, the purpose of filtering out simplex pairs whose distance is less than the preset threshold is to collect all these simplex pairs that may cause interweaving.

[0139] Step S20: Based on the collision constraints of the tetrahedron, calculate the updated position of the target mesh according to each target simplex pair;

[0140] Furthermore, after obtaining each target simplex pair, collision constraint equations can be constructed based on the tetrahedral collision constraints to calculate the updated position of the target mesh, where the updated position of the target mesh is... Two conditions need to be met: (1) relative to the current position (2) The current set All simplex pairs do not intersect; this can be expressed as the following collision constraint equation:

[0141]

[0142] Wherein, c(s) i (p),s j (p))≥0 represents a set of feasible region constraints, restricting the solution results from interleaving. For each pair of simplexes in set P, whether (vertex, triangle) or (edge, edge), they all contain 4 vertices, thus forming a tetrahedron. Assume the current positions of the 4 vertices in the tetrahedron are (r) a ,r i ,r j,r k Since the distance between these simplexes is less than the fabric thickness, further compression of the tetrahedrons could lead to interpenetration. Therefore, it is only necessary to require the optimized positions to form a tetrahedron (p...). a ,p i ,p j ,p k It can be defined as follows: (No compression is required)

[0143] c(s i (p),s j (p))=|p i -p a ,p j -p a ,p k -p a |-|r i -r a ,r j -r a ,r k -r a |

[0144] Where |·| is the determinant symbol. The collision constraint equation can be found in p. (l) Linearization is as follows:

[0145]

[0146] Wherein, c(p) (l) ) is all {c(s i (p),s j (p))≥0|(s i ,s j The vectorized representation of J(p)∈P} (l) ) is the Jacobian matrix. The Lagrange form corresponding to the above linearization problem is: This Lagrangian form is convex with respect to both p and λ, so the KKT conditions for nonlinear optimization can be directly applied:

[0147]

[0148] By substitution, the above KKT conditions can be simplified to a linear complementarity problem (LCP) with only λ as the unknown: This is a linear positive definite equation, which can be solved using the standard Gauss-Seidel iteration, with the constraint λ≥0 after each iteration. After obtaining λ, substituting it into the KKT conditions yields the target mesh location.

[0149]

[0150] Step S30: Obtain the update position of the mesh to be optimized in the cloth simulation based on the target mesh update position, and determine the output mesh state based on the update position of the mesh to be optimized.

[0151] Furthermore, after calculating the target mesh update position using tetrahedral collision constraints, the movement direction can be updated and the safe movement distance calculated based on the target mesh update position. In one implementation, along a given movement direction, the movement distance of each vertex does not exceed half of the nearest distance. Therefore, for each pair of potentially intersecting simplexes, since they always move within the safe distance, they will not intersect after movement. This ensures the safety of collision handling.

[0152] After calculating the safe movement distance, the position of the mesh to be optimized can be determined based on the safe movement distance. Then, the termination condition is determined by optimizing the termination threshold to determine whether to use the obtained position of the mesh to be optimized as the output mesh state, or to return to the tetrahedral collision constraint and calculate the target mesh update position according to each target simplex pair. The final position of the mesh to be optimized is then determined, which is the output mesh state. The final position of the mesh to be optimized is then used as the position of the mesh to be optimized at the next time point, further completing the collision processing of the cloth simulation.

[0153] In this embodiment, each target simplex pair is acquired; based on tetrahedral collision constraints, the target mesh update position is calculated according to each target simplex pair; the update position of the mesh to be optimized in the cloth simulation is obtained based on the target mesh update position, and the output mesh state is determined based on the update position of the mesh to be optimized. Obtaining the final non-self-intersecting output mesh state through each target simplex pair ensures the safety of collision handling; simultaneously, the tetrahedral collision constraints provide more degrees of freedom for calculating the target mesh update position, thereby accelerating convergence and ensuring the efficiency of collision handling in the cloth simulation process. This approach balances the safety and efficiency of collision handling in the cloth simulation process, thus improving the effectiveness of collision handling in cloth simulation.

[0154] Reference Figure 6 , Figure 6 for Figure 5 A schematic flowchart of step S10 in this embodiment. This embodiment is based on the above. Figure 5 In the embodiment shown, step S10 includes:

[0155] Step S101: Obtain all simplexes in the triangular mesh;

[0156] Specifically, in the triangular mesh represented by the fabric, the triangular mesh is defined as a set of triangles: F = {f i|i=0,1,...}, each triangle contains three vertices, and the position of each vertex is a coordinate in three-dimensional space: p ik =(x ik ,y ik ,z ik ) T Where k = 0, 1, 2. Let the positions of all vertices of the triangular mesh be concatenated into a vector, denoted as p, and the total number of vertices be denoted as n. Any two vertices of each triangle are connected by an edge, and each triangle f... i There are three sides in total. In this embodiment of the invention, the triangle, sides, and vertices are collectively referred to as a simplex, and each simplex is denoted as s. i The positional information of each simplex can be expressed as s i (p). Among them, (s) i ,s j () represents a pair of simplexes. Based on the definitions of vertices, edges, and triangles, there may be multiple different types of simplex combinations that can form pairs. In cloth simulation, the simplex combinations that truly affect self-collision include (vertices, triangles) and (edges, edges), so this invention only calculates the distances in these two cases.

[0157] Obtaining all simplexes in a triangular mesh means obtaining all vertices, triangles, and edges in the triangular mesh, and then calculating the distances between simplex pairs formed by each simplex, that is, calculating the distance between a vertex and a triangle, and the distance between edges.

[0158] Step S102: Calculate the simplex pair distance between each simplex, wherein the simplex pair distance includes the distance between the vertex and the triangle in the triangular mesh and the distance between the edges;

[0159] Furthermore, after obtaining all the simplexes in the triangular mesh, the simplex pair distances between each simplex can be calculated, where the (vertex, triangle) distance represents the distance between vertex p. i With triangle f j =(p j0 ,p j1 ,p j2 The nearest distance between all points within a given area, where (edge, edge) distance represents the distance between edges. i =(p i0 ,p i1 All points and edges on the () j =(p j0 ,p j1 The nearest distance to all points on the graph can be calculated, thus allowing the selection of simplex pairs whose distances are less than a preset threshold from the calculated distances between each simplex pair.

[0160] Step S103: The simple shape pairs whose distances are less than a preset threshold among the simple shape pairs are taken as the target simple shape pairs.

[0161] Furthermore, after calculating the distance between each simplex pair, the simplex pairs whose distances are less than a preset threshold can be selected as target simplex pairs. This means collecting each pair of simplex pairs in the triangular mesh whose distance is less than the threshold d. thre simplex

[0162] P={(s i ,s j )|d(s i (p (l) ),s j (p (l) )) <d thre}

[0163] Where, d thre The physical meaning of "thickness" refers to the fabric thickness parameter. Any two simplexes with a distance less than the fabric thickness may intersect. The purpose of this step is to collect all such simplex pairs that may intersect. In this embodiment of the invention, for simplicity, 1 mm is directly used as the fabric thickness parameter. In other embodiments, any fabric thickness parameter that conforms to the physical meaning can be used.

[0164] This embodiment, through the above-described scheme, specifically obtains all simplexes in a triangular mesh; calculates the simplex pair distances between each simplex, wherein the simplex pair distances include the distances between vertices and triangles in the triangular mesh, as well as the distances between edges; and identifies the simplex pair distances less than a preset threshold as the target simplex pair. Since any two simplexes with a distance less than the fabric thickness may intersect, by filtering out simplex pairs with distances less than the preset threshold, all possible intersect pairs are collected, thereby improving the safety of fabric simulation collision handling.

[0165] Reference Figure 7 , Figure 7 for Figure 6 A schematic flowchart illustrating step S102 in this embodiment. This embodiment is based on the above. Figure 6 In the embodiment shown, step S102 includes:

[0166] Step S1021: Calculate the distance between each vertex in the triangular mesh and the triangle;

[0167] Specifically, the (vertex, triangle) distance represents vertex p. i With triangle f j =(p j0 ,p j1 ,p j2 The shortest distance between all points within a given area is calculated as follows:

[0168]

[0169] in p is inside the triangle i Closest point yes For the centroid coordinates of the triangle, k + =mod(k+1,3),k - =mod(k+2,3) represents the two vertices other than vertex k, and c = p i +[n·(p j0 -p i )]n is p i At the projection point on the plane containing the triangle, It is the normal vector of the triangle.

[0170] The steps for calculating the distance between each vertex in the triangular mesh and the triangle include:

[0171] Traverse each vertex in the triangular mesh, and for each vertex, traverse each triangle in the triangular mesh to obtain the distance between each vertex and the triangle; or

[0172] The triangular mesh is spatially divided, and the distance between the vertices in each divided region and the triangles in the preset region is calculated to obtain the distance between each vertex and the triangle.

[0173] Specifically, to calculate all (vertices, triangles) distances, one only needs to traverse all vertices, and then for each vertex, traverse all triangles and calculate the distances separately. Alternatively, a grid space partitioning method can be used to divide the triangles according to space, and then for each vertex, one only needs to calculate the triangle distances of the grids near the vertex, further reducing the amount of computation.

[0174] Step S1021: Calculate the distance between each side in the triangular mesh.

[0175] Specifically, the (edge, edge) distance represents edge e. i =(p i0 ,p i1 All points and edges on the () j =(p j0 ,p j1 The shortest distance between all points on the network is calculated as follows:

[0176]

[0177] in

[0178]

[0179]

[0180]

[0181] The steps for calculating the distances between each edge in the triangular mesh include:

[0182] Traverse each edge of the triangular mesh, and for each edge, traverse each edge separately to obtain the distance between each edge; or

[0183] The triangular mesh is spatially divided, and the distance between the edge in each divided region and the edge in the preset region is calculated to obtain the distance between each edge.

[0184] Similarly, to calculate all (edge, edge) distances, we only need to iterate through all edges, and then iterate through all edges for each edge and calculate the distances separately; alternatively, we can use a grid space partitioning method to divide all edges according to space, and then for each edge, we only need to calculate the edge-to-edge distances of the nearby grids, further reducing the amount of computation.

[0185] This embodiment, through the above-described scheme, specifically calculates the distance between each vertex of the triangular mesh and the triangle, and calculates the distance between each edge of the triangular mesh. The distance of each simplex pair can be calculated separately by traversing the mesh, or the distance of simplex pairs within a specific range can be calculated using a mesh space partitioning method, further reducing the computational load and ensuring the efficiency of the calculation process.

[0186] Reference Figure 8 , Figure 8 for Figure 5 A schematic flowchart of step S20 in this embodiment. This embodiment is based on the above. Figure 5 In the embodiment shown, step S20 includes:

[0187] Step S201: Based on the collision constraints of tetrahedrons, construct collision constraint equations according to each of the target simplex pairs;

[0188] After obtaining each target simplex pair, collision constraint equations can be constructed based on the tetrahedral collision constraints to calculate the updated position of the target mesh, where the updated position of the target mesh is... Two conditions need to be met: (1) relative to the current position (2) The current set All simplex pairs do not intersect; this can be expressed as the following collision constraint equation:

[0189]

[0190] Wherein, c(s) i (p),sj (p))≥0 represents a set of feasible region constraints, restricting the solution results from interleaving. For each pair of simplexes in set P, whether (vertex, triangle) or (edge, edge), they all contain 4 vertices, thus forming a tetrahedron; refer to Figure 9 and Figure 10 , Figure 9 This is a first schematic diagram of a tetrahedron in an embodiment of the present invention. Figure 10 This is a second schematic diagram of a tetrahedron in an embodiment of the present invention, as shown below. Figure 9 and Figure 10 As shown, assume the current positions of the four vertices are (r a ,r i ,r j ,r k Since the distance between these simplexes is less than d thre That is, the fabric thickness. If the tetrahedron is further compressed, it may interlock. Therefore, we only need to require the optimized position to form a tetrahedron (p a ,p i ,p j ,p k It can be defined as follows: (No compression is required)

[0191] c(s i (p),s j (p))=|p i -p a ,p j -p a ,p k -p a |-|r i -r a ,r j -r a ,r k -r a |

[0192] Where |·| is the determinant symbol.

[0193] Step S202: Linearize and substitute the collision constraint equations to calculate the updated position of the target mesh.

[0194] Furthermore, based on the tetrahedral collision constraint, after constructing the collision constraint equation according to each target simplex pair, the collision constraint equation can be applied to p. (l) Linearization is as follows:

[0195]

[0196] Wherein, c(p) (l) ) is all {c(s i (p),s j(p))≥0|(s i ,s j The vectorized representation of J(p)∈P} (l) ) is the Jacobian matrix. The Lagrange form corresponding to the above linearization problem is: This Lagrangian form is convex with respect to both p and λ, so the KKT conditions for nonlinear optimization can be directly applied:

[0197]

[0198] By substitution, the above KKT conditions can be simplified to a linear complementarity problem (LCP) with only λ as the unknown: This is a linear positive definite equation, which can be solved using the standard Gauss-Seidel iteration, with the constraint λ≥0 after each iteration. After obtaining λ, substituting it into the KKT conditions yields the target mesh location.

[0199]

[0200] This invention, through the above-described scheme, specifically employs tetrahedral collision constraints to construct collision constraint equations based on each target simplex pair; linearization and equation substitution are then performed on these collision constraint equations to calculate the updated position of the target mesh. Compared to traditional collision constraints, the tetrahedral-based collision constraint method provides more degrees of freedom for the solution process, thereby accelerating convergence and ensuring high efficiency in cloth simulation collision handling.

[0201] Reference Figure 11 , Figure 11 for Figure 5 A schematic flowchart of step S30 in this embodiment. This embodiment is based on the above. Figure 5 In the embodiment shown, step S30 includes:

[0202] Step S301: Calculate the safe movement distance based on the updated position of the target grid;

[0203] Specifically, this includes determining the movement direction based on the target grid update position and the position of the grid to be optimized;

[0204] Calculate the safe movement distance based on the direction of movement.

[0205] After calculating the target mesh update position, the movement direction can be determined based on the target mesh update position and the pre-determined position of the mesh to be optimized. Then, the safe movement distance of the mesh to be optimized can be calculated based on the movement direction.

[0206]

[0207] Where, d min =min{d(s i (p),s j (p))≥0|(s i ,s j )∈P}. Here, the geometric meaning of α is that along the given direction of movement d (l) The movement distance of each vertex cannot exceed the nearest distance d. min Half of it, therefore for each pair of monomorphs that may intersect, since they always move within a safe distance, they will not intersect after moving.

[0208] Step S302: Calculate the update position of the mesh to be optimized in the fabric simulation based on the safe movement distance, and determine the output mesh state based on the update position of the mesh to be optimized.

[0209] Furthermore, after calculating the safe movement distance, the position of the mesh to be optimized can be determined based on the safe movement distance. Then, the termination condition is determined by optimizing the termination threshold to determine whether to use the obtained position of the mesh to be optimized as the output mesh state, or to return to the step of calculating the target mesh update position based on the tetrahedral collision constraint according to each target simplex pair. The final position of the mesh to be optimized is then determined, which is the output mesh state. The final position of the mesh to be optimized is then used as the position of the mesh to be optimized at the next time point, thus further completing the collision processing of the cloth simulation.

[0210] This embodiment, through the above-described scheme, specifically calculates a safe movement distance based on the target mesh update position; calculates the update position of the mesh to be optimized in the cloth simulation based on the safe movement distance; and determines the output mesh state based on the update position of the mesh to be optimized. By updating the movement direction and calculating the safe movement distance, it can be ensured that each pair of potentially intersecting simplexes always moves within the safe distance, thus preventing them from intersecting after movement, avoiding the possibility of self-intersection, and ensuring the safety of collision handling in cloth simulation.

[0211] Reference Figure 12 , Figure 12 This is a flowchart illustrating another exemplary embodiment of the fabric simulation method of the present invention. Based on the above... Figure 5 In the illustrated embodiment, this embodiment can be implemented before step S10. In other embodiments, this embodiment can also be implemented between step S10 and step S20.

[0212] In this embodiment, before step S10, the fabric simulation method further includes:

[0213] Step S01: Obtain the input grid state;

[0214] In this embodiment of the invention, the grid state at the current time point is used as the input grid state, and the target grid state at the next time point can be obtained through the grid state at the current time point.

[0215] Step S02: Solve for the elastic material state based on the input mesh state to obtain the target mesh state;

[0216] Furthermore, after obtaining the input mesh state, the target mesh state at the next time point can be obtained by using the cloth physics calculation method, that is, solving the elastic material. However, the target mesh state obtained at this time may have self-intersections. Therefore, it is necessary to obtain the final output mesh state through the schemes in other embodiments of the present invention. The output mesh state is the non-self-intersection mesh state at the next time point.

[0217] Step S03: Initialize the input grid state and the target grid state respectively to obtain the position of the grid to be optimized and the position of the target grid.

[0218] After obtaining the input mesh state and the target mesh state, initializing them respectively will yield the positions of the mesh to be optimized and the target mesh, where l = 0, p (l) ←p [t] , Here, l represents the number of optimization iterations, and the superscript () (l) This represents the value of the vector at the current iteration step. The entire iterative process employs a bidirectional solution optimization strategy, p (l) and During the optimization process, it gradually approaches and eventually converges; The goal of efficient updates is to provide optimization, p (l) Then, while always maintaining the condition of not intersecting, it gradually approaches the target position.

[0219] This embodiment, through the above scheme, specifically involves obtaining the input mesh state; solving for the elastic material based on the input mesh state to obtain the target mesh state; and initializing both the input mesh state and the target mesh state to obtain the position of the mesh to be optimized and the position of the target mesh. By solving for the elastic material based on the input mesh state to obtain the target mesh state, and then initializing to obtain the position of the mesh to be optimized and the position of the target mesh, a bidirectional optimization process can be further performed.

[0220] Reference Figure 13 , Figure 13 for Figure 11 A detailed flowchart of step S302 in this embodiment. This embodiment is based on the above. Figure 11 In the embodiment shown, step S302 includes:

[0221] Step S3021: Calculate the updated position of the grid to be optimized based on the grid position to be optimized and the safe moving distance;

[0222] Based on the calculated safe movement distance and the initialized position of the grid to be optimized, the updated position of the grid to be optimized can be obtained:

[0223] p (l+1) ←p (l) +αd (l)

[0224] Step S3022: Calculate the grid distance between the grid update position to be optimized and the target grid update position;

[0225] After calculating the update position of the mesh to be optimized, the update position of the target mesh can be further calculated. Update position p of the grid to be optimized (l+1) The distance between them is used to determine whether to output the final grid update position to be optimized as the grid position at the next time point.

[0226] Step S3023: Determine whether the grid distance is less than a preset optimization termination threshold;

[0227] Determine the target mesh update position Update position p of the grid to be optimized (l+1) Whether the distance between them is less than a preset optimization termination threshold ε, in this embodiment of the invention, ε = 10. -4 As an optimization termination threshold.

[0228] Step S3024: If the grid distance is less than the preset optimization termination threshold, then the update position of the grid to be optimized is taken as the output grid state.

[0229] If the target grid updates its position Update position p of the grid to be optimized (l+1) If the distance between them is less than the preset optimization termination threshold ε, then the final grid update position to be optimized is output as the grid position at the next time point:

[0230] p [t+1] ←p (l+1)

[0231] Where, p [t+1] It outputs the grid status.

[0232] Step S3025: If the mesh distance is not less than the preset optimization termination threshold, then return to the step of performing collision constraints based on tetrahedrons, calculating the target mesh update position according to the target simplex pair, and subsequent steps.

[0233] If the target grid updates its position Update position p of the grid to be optimized (l+1) If the distance between them is not less than the preset optimization termination threshold ε, then return to the step of performing the collision constraint based on the tetrahedron, calculating the target mesh update position according to the target simplex pair and subsequent steps, in order to further determine the final output mesh state.

[0234] This embodiment, through the above scheme, specifically calculates the updated position of the mesh to be optimized based on the position of the mesh to be optimized and the safe moving distance; calculates the mesh distance between the updated position of the mesh to be optimized and the updated position of the target mesh; determines whether the mesh distance is less than a preset optimization termination threshold; if the mesh distance is less than the preset optimization termination threshold, the updated position of the mesh to be optimized is taken as the output mesh state; if the mesh distance is not less than the preset optimization termination threshold, the process returns to the steps of calculating the updated position of the target mesh based on the tetrahedral collision constraint and the target simplex pair, as well as subsequent steps. Through termination condition determination, p... (l) and During the optimization process, it gradually approaches and eventually converges; The goal of efficient updates is to provide optimization, p (l) Then, while always maintaining the condition of not intersecting, it gradually approaches the target position.

[0235] Reference Figure 14 , Figure 14 This is a flowchart illustrating another exemplary embodiment of the fabric simulation method of the present invention. Based on the above... Figure 5 The embodiment shown can be implemented after step S30. In this embodiment, after step S30, the fabric simulation method further includes:

[0236] Step S40: Use the output mesh state as the input mesh state for the next time point, and return to execute the steps of obtaining each target single shape pair and subsequent steps until the fabric simulation process is completed.

[0237] After processing the input mesh state at the current time point to obtain the non-self-intersecting mesh state at the next time point, the output mesh state can be used as the input mesh state at the next time point. The cloth collision processing process is executed cyclically until the cloth simulation collision processing at all time points is completed.

[0238] Reference Figure 15 and Figure 16 , Figure 15 This is a schematic diagram of the initial state of a fabric simulation collision processing example in an embodiment of the present invention. Figure 16 This is a schematic diagram of the example output state of the fabric simulation collision processing in an embodiment of the present invention, such as... Figure 15As shown, in the initial state of the simulation, a piece of fabric is placed on two circular discs at both ends, and then the two discs are rotated and twisted in opposite directions; as... Figure 16 As shown in the output at a certain point in the simulation, it can be seen that the fabric still does not self-interlace under this complex condition.

[0239] This embodiment, through the above-described scheme, specifically uses the output mesh state as the input mesh state for the next time point, and returns to execute the steps of obtaining each target simplex pair and subsequent steps until the cloth simulation process is completed. By employing the bidirectional mode solution optimization strategy proposed in this invention for each frame of the cloth simulation collision processing, the entire process of cloth simulation collision processing can be completed. Its application in the cloth simulation system achieves good results, ensuring that the output state has no self-intersections.

[0240] Furthermore, this invention also proposes a fabric simulation device, which includes:

[0241] The acquisition module is used to acquire each target simplex pair;

[0242] The calculation module is used to update the position of the target mesh based on the collision constraints of the tetrahedron and according to each of the target simplexes.

[0243] The output module is used to obtain the update position of the mesh to be optimized in the cloth simulation based on the target mesh update position, and to determine the output mesh state based on the update position of the mesh to be optimized.

[0244] Reference Figure 17 , Figure 17 This is a flowchart illustrating the bidirectional mode optimization strategy in an embodiment of the present invention, as shown below. Figure 17 As shown, the specific steps of this solution include:

[0245] Step 1: Initialize the position of the mesh to be optimized and the position of the target mesh;

[0246] Initialize the positions of the mesh to be optimized and the target mesh positions l = 0, p (l) ←p [t] , Here, l represents the number of optimization iterations, and the superscript () (l) This represents the value of the vector at the current iteration step. The entire iterative process employs a bidirectional solution optimization strategy, such as... Figure 3 As shown, p (l) and During the optimization process, it gradually approaches and eventually converges; The goal of efficient updates is to provide optimization, p (l) Then, while always maintaining the condition of not intersecting, it gradually approaches the target position.

[0247] Step 2: Calculate the distance between any pair of simplexes (vertex-triangle and edge-edge) in the triangular mesh, and obtain simplex pairs whose distance is less than the threshold.

[0248] Collect each pair of triangles in the grid whose distance is less than a threshold d thre simplex

[0249] P={(s i ,s j )|d(s i (p (l) ),s j (p (l) )) <d thre}

[0250] Where, d thre The physical meaning of "interlacing" refers to the thickness parameter of the fabric. Any two simplexes with a distance less than the fabric thickness may interlace. The purpose of this step is to collect all such simplex pairs that may interlace. In this invention, for simplicity, 1 mm is directly used as the fabric thickness parameter; any other fabric thickness parameter that conforms to the physical meaning can be used.

[0251] Among them, (s i ,s j () represents a pair of simplexes. Based on the definitions of vertices, edges, and triangles, there may be multiple different types of simplex combinations that can form pairs. In cloth simulation, the simplex combinations that truly affect self-collision include (vertices, triangles) and (edges, edges), so this invention only calculates the distances in these two cases.

[0252] Wherein, the (vertex, triangle) distance represents vertex p i With triangle f j =(p j0 ,p j1 ,p j2 The shortest distance between all points within a given area is calculated as follows:

[0253]

[0254] in p is inside the triangle i Closest point yes For the centroid coordinates of the triangle, k + =mod(k+1,3),k - =mod(k+2,3) represents the two vertices other than vertex k, and c = p i +[n·(p j0 -p i )]n is p i At the projection point on the plane containing the triangle, It is the normal vector of the triangle;

[0255] Specifically, to calculate all (vertices, triangles) distances, one only needs to traverse all vertices, and then for each vertex, traverse all triangles and calculate the distances separately. Alternatively, a grid space partitioning method can be used to divide the triangles according to space, and then for each vertex, one only needs to calculate the triangle distances of the grids near the vertex, further reducing the amount of computation.

[0256] Where (edge, edge) distance represents edge e i =(p i0 ,p i1 All points and edges on the () j =(p j0 ,p j1 The shortest distance between all points on the network is calculated as follows:

[0257]

[0258] in

[0259]

[0260]

[0261]

[0262] Similarly, to calculate all (edge, edge) distances, we only need to iterate through all edges, and then iterate through all edges for each edge and calculate the distances separately; alternatively, we can use a grid space partitioning method to divide all edges according to space, and then for each edge, we only need to calculate the edge-to-edge distances of the nearby grids, further reducing the amount of computation.

[0263] Step 3: Calculate the updated position of the target mesh based on tetrahedral collision constraints;

[0264] First, calculate the target grid position. Then, update the efficient movement direction of the mesh to be optimized.

[0265] Among them, the updated position of the target grid Two conditions need to be met: (1) relative to the current position (2) The current set All simplex pairs do not intersect; this can be expressed as the following collision constraint equation:

[0266]

[0267] Wherein, c(s) i (p),sj (p))≥0 represents a set of feasible region constraints, restricting the solution results from interleaving. For each simplex in set P, whether it is (vertex, triangle) or (edge, edge), it contains 4 vertices, and therefore can form a tetrahedron; assuming the current position of the 4 vertices is (r a ,r i ,r j ,r k Since the distance between these simplexes is less than d thre That is, the fabric thickness. If the tetrahedron is further compressed, it may interlock. Therefore, we only need to require the optimized position to form a tetrahedron (p). a ,p i ,p j ,p k It can be defined as follows: (No compression is required)

[0268] c(s i (p),s j (p))=|p i -p a ,p j -p a ,p k -p a |-|r i -r a ,r j -r a ,r k -r a |

[0269] Where |·| is the determinant symbol.

[0270] Among them, the collision constraint equation can be found in p (l) Linearization is as follows:

[0271]

[0272] Wherein, c(p) (l) ) is all {c(s i (p),s j (p))≥0|(s i ,s j The vectorized representation of J(p)∈P} (l) ) is the Jacobian matrix. The Lagrange form corresponding to the above linearization problem is: This Lagrangian form is convex with respect to both p and λ, so the KKT conditions for nonlinear optimization can be directly applied:

[0273]

[0274] By substitution, the above KKT conditions can be simplified to a linear complementarity problem (LCP) with only λ as the unknown: This is a linear positive definite equation, which can be solved using the standard Gauss-Seidel iteration, with the constraint λ≥0 after each iteration. After obtaining λ, substituting it into the KKT conditions yields the target mesh location.

[0275]

[0276] Step 4: Update the movement direction based on the updated position of the target grid and the initial position, and calculate the safe movement distance based on the movement direction;

[0277] Calculate the safe movement distance of the mesh to be optimized:

[0278]

[0279] Where, d min =min{d(s i (p),s j (p))≥0|(s i ,s j )∈P}. Here, the geometric meaning of α is that along the given direction of movement d (l) The movement distance of each vertex cannot exceed the nearest distance d. min Half of it, therefore for each pair of monomorphs that may intersect, since they always move within a safe distance, they will not intersect after moving.

[0280] Step 5: Based on the safe movement distance, obtain the position of the grid to be optimized, and use it as the grid position for the next time point.

[0281] Then, update the grid positions to be optimized:

[0282] p (l+1) ←p (l) +αd (l)

[0283] Termination condition determination: If the target grid position With the grid position p to be optimized (l+1) If the distance is less than the threshold ε, then the final grid position to be optimized is output as the grid position for the next time point:

[0284] p [t+1] ←p (l+1)

[0285] Where, p [t+1] It outputs the grid status.

[0286] Otherwise, return to step 3. In this invention, ε = 10.-4 This indicates the optimized termination threshold.

[0287] In this embodiment, the cloth simulation collision handling method solves the problem that related technologies cannot simultaneously achieve both safety and efficiency. In particular, it proposes a bidirectional mode solution optimization strategy to improve efficiency and meet safety requirements. Secondly, the method is simple to implement and numerically safe, requiring no additional complex numerical processing. Finally, the method is compatible with the existing cloth simulation workflow and can be directly inserted into existing cloth simulation systems, improving both safety and efficiency, thereby achieving the goal of improving the cloth simulation collision handling effect.

[0288] The principle and implementation process of fabric simulation in this embodiment are explained in the above embodiments and will not be repeated here.

[0289] Furthermore, this embodiment of the invention also proposes a terminal device, which includes a memory, a processor, and a fabric simulation program stored in the memory and executable on the processor. When the fabric simulation program is executed by the processor, it implements the steps of the fabric simulation method described above.

[0290] Since this fabric simulation program employs all the technical solutions of all the aforementioned embodiments when executed by the processor, it possesses at least all the beneficial effects brought about by all the technical solutions of all the aforementioned embodiments, which will not be elaborated upon here.

[0291] Furthermore, embodiments of the present invention also propose a computer-readable storage medium storing a fabric simulation program, which, when executed by a processor, implements the steps of the fabric simulation method described above.

[0292] Since this fabric simulation program employs all the technical solutions of all the aforementioned embodiments when executed by the processor, it possesses at least all the beneficial effects brought about by all the technical solutions of all the aforementioned embodiments, which will not be elaborated upon here.

[0293] Compared to existing technologies, the cloth simulation method, apparatus, terminal device, and storage medium proposed in this invention acquire each target simplex pair; calculate the target mesh update position based on tetrahedral collision constraints according to each target simplex pair; obtain the mesh update position to be optimized in the cloth simulation based on the target mesh update position; and determine the output mesh state based on the mesh update position to be optimized. By obtaining the final non-self-intersecting output mesh state through each target simplex pair, the safety of collision handling is ensured; simultaneously, the tetrahedral collision constraints provide more degrees of freedom for calculating the target mesh update position, thereby accelerating convergence and ensuring the efficiency of collision handling in the cloth simulation process. This approach balances the safety and efficiency of collision handling in the cloth simulation process, thus improving the effectiveness of collision handling in cloth simulation.

[0294] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.

[0295] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0296] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, controlled terminal, or network device, etc.) to execute the methods of each embodiment of this application.

[0297] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.

Claims

1. A cloth simulation method characterized by, The cloth simulation method comprises the following steps: Obtaining all simplex in a triangular mesh expressed by cloth, wherein the simplex comprises a triangle, an edge and a vertex in the triangular mesh, and combinations of the simplex are simplex pairs; Calculating a simplex pair distance between each of the simplex, wherein the simplex pair distance comprises a distance between a vertex and a triangle, and a distance between an edge and an edge in the triangular mesh; Taking a simplex pair corresponding to a simplex pair distance less than a preset threshold in each of the simplex pair distance as a target simplex pair; Calculating a target mesh update position according to each of the target simplex pair based on a tetrahedron collision constraint; Obtaining a to-be-optimized mesh update position in the cloth simulation according to the target mesh update position, and determining an output mesh state based on the to-be-optimized mesh update position.

2. The cloth simulation method of claim 1, wherein, The step of calculating the simplex pair distance between each of the simplex comprises: Calculating the distance between each vertex and triangle in the triangular mesh; Calculating the distance between each edge and edge in the triangular mesh.

3. The cloth simulation method of claim 2, wherein, The step of calculating the distance between each vertex and triangle in the triangular mesh comprises: Traversing each vertex in the triangular mesh, and traversing each triangle in the triangular mesh for each vertex to obtain the distance between each vertex and triangle; or Dividing the space of the triangular mesh, and calculating the distance between a vertex in each division region and a triangle in a preset region to obtain the distance between each vertex and triangle.

4. The cloth simulation method of claim 2, wherein, The step of calculating the distance between each edge and edge in the triangular mesh comprises: Traversing each edge in the triangular mesh, and traversing each edge for each edge to obtain the distance between each edge and edge; or Dividing the space of the triangular mesh, and calculating the distance between an edge in each division region and an edge in a preset region to obtain the distance between each edge and edge.

5. The cloth simulation method of claim 1, wherein, The step of calculating the target mesh update position according to each of the target simplex pair based on the tetrahedron collision constraint comprises: Constructing a collision constraint equation according to each of the target simplex pair based on the tetrahedron collision constraint; Linearizing and equation substituting the collision constraint equation to calculate the target mesh update position.

6. The cloth simulation method of claim 1, wherein, The step of obtaining the to-be-optimized mesh update position in the cloth simulation according to the target mesh update position, and determining the output mesh state based on the to-be-optimized mesh update position comprises: Calculating a safe moving distance according to the target mesh update position; Calculating the to-be-optimized mesh update position in the cloth simulation according to the safe moving distance, and determining the output mesh state based on the to-be-optimized mesh update position.

7. The cloth simulation method of claim 6, wherein, The step of calculating the safe moving distance according to the target mesh update position comprises: Determining a moving direction according to the target mesh update position and a to-be-optimized mesh position; Calculating the safe moving distance based on the moving direction.

8. The cloth simulation method of claim 7, wherein, The step of determining the moving direction according to the target mesh update position and the to-be-optimized mesh position further comprises: Obtaining an input mesh state; Solving an elastic material based on the input mesh state to obtain a target mesh state; The input grid state and the target grid state are initialized respectively to obtain the to-be-optimized grid position and the target grid position.

9. The cloth simulation method of claim 8, wherein, The step of calculating the to-be-optimized grid update position in the cloth simulation according to the safe moving distance and determining the output grid state based on the to-be-optimized grid update position comprises: calculating the to-be-optimized grid update position according to the to-be-optimized grid position and the safe moving distance; calculating the grid distance between the to-be-optimized grid update position and the target grid update position; judging whether the grid distance is less than a preset optimization termination threshold; if the grid distance is less than the preset optimization termination threshold, taking the to-be-optimized grid update position as the output grid state; if the grid distance is not less than the preset optimization termination threshold, returning to execute the step of calculating the target grid update position based on the tetrahedron collision constraint according to the target simplex pair and the subsequent steps.

10. The cloth simulation method of claim 9, wherein, The step of taking the to-be-optimized grid update position as the output grid state if the grid distance is less than the preset optimization termination threshold further comprises: taking the output grid state as the input grid state at the next time point and returning to execute the step of obtaining each target simplex pair and the subsequent steps until the process of the cloth simulation is completed.

11. A cloth simulation apparatus, characterized by, The cloth simulation device comprises: an obtaining module, configured to obtain all simplexes in a triangular grid of cloth expression, wherein the simplexes comprise triangles, edges and vertices in the triangular grid, and combinations of the simplexes are simplex pairs; calculate simplex pair distances between the simplexes, wherein the simplex pair distances comprise distances between vertices and triangles, distances between edges in the triangular grid; and take simplex pairs corresponding to simplex pair distances less than a preset threshold as target simplex pairs; a calculation module, configured to calculate target grid update positions based on tetrahedron collision constraints according to the target simplex pairs; an output module, configured to obtain to-be-optimized grid update positions in the cloth simulation according to the target grid update positions and determine output grid states based on the to-be-optimized grid update positions.

12. A terminal device, comprising: The terminal device comprises a memory, a processor and a cloth simulation program stored on the memory and executable on the processor, and the cloth simulation program, when executed by the processor, implements the steps of the cloth simulation method according to any one of claims 1-10.

13. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a cloth simulation program, and the cloth simulation program, when executed by a processor, implements the steps of the cloth simulation method according to any one of claims 1-10.

Citation Information

Patent Citations

  • Particle computer dynamic simulation method for 3D garment

    CN106407605A