A high-precision cloth simulation method for unreal

CN119092015BActive Publication Date: 2026-10-09ZHEJIANG UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411091598.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-09
Publication Date
2026-10-09
Estimated Expiration
2044-08-09

AI Technical Summary

Technical Problem

[0005](3)可扩展性低:UE的骨骼网格结构是高度封装的,开发者不能通过获取LOD及底层Mesh结构的信息来直接修改和计算模拟,必须通过用户界面的外部接口来调用实现,而高精度的模拟需要实时更新有关布料的底层数据

Benefits of technology

[0039] This invention improves the accuracy of cloth simulation in the UE engine, optimizes the shortcomings of general simulation methods in dealing with cloth simulation such as penetration and unrealistic performance, and provides a method in UE that can directly modify underlying data and transmit it to the rendering pipeline instead of using animation nodes and user interface operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119092015B_ABST
    Figure CN119092015B_ABST
Patent Text Reader

Abstract

The application discloses a high-precision cloth simulation method for Unreal. The application comprises the following steps: firstly, reading cloth data imported by Unreal and binding a structure body, obtaining a cloth original data set; then, acquiring vertex information and constructing a simulation data set. Then, a space hash table is constructed and the triangular face indexes of potential collision objects of the cloth in a scene are stored, which is used for acceleration in collision detection. Finally, collision processing is performed, CCD continuous collision detection is performed on the potential collision triangular faces in each hash group, accurate collision detection time is obtained to avoid the occurrence of tunneling phenomenon. The application helps to solve the limitation of using a skeleton mesh body for physical simulation of general cloth import assets in Unreal, data processing and construction are performed for high-precision collision detection of triangular faces, and a high-precision CCD and impact domain method is used in simulation to process collision, so that a high-precision non-penetrating simulation effect is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a cloth simulation method in the field of computer-aided design (CAD), and particularly to a high-precision cloth simulation method for Unreal Engine. Background Technology

[0002] Computer-aided design (CAD) technology is widely used in various design fields. Its application in game physics engines involves a great deal of specialized knowledge. Unreal Engine, as a very mature and advanced game engine, has a complete Chaos engine framework for cloth simulation, which can easily bind and simulate related structures to user-built FBX data. However, most simulations are built on skeletal mesh structures. UE itself can use Cloth components to "sprinkle points" to add simulation-related bindings to specific vertices. Some cloth plugins in the UE store simulate cloth using dynamics by combining the control points of user-imported skeletal models with UE's animation system. These methods have some shortcomings. The main problems are as follows:

[0003] (1) Low simulation accuracy: In order to improve the running efficiency of the scene, the simulation generally uses skeletal vertices and bounding boxes to reduce the computational scale during simulation, which inevitably reduces the detection accuracy compared to triangular face detection.

[0004] (2) Limited constraint types: The existing constraint types in UE are mainly concentrated on joint distance and rotation. In many scenarios, developers need to customize constraints, such as handling friction or deformation.

[0005] (3) Low scalability: The UE's skeleton mesh structure is highly encapsulated. Developers cannot directly modify and calculate the simulation by obtaining information about the LOD and the underlying Mesh structure. They must call the simulation through the external interface of the user interface. High-precision simulation requires real-time updates of the underlying data of the cloth. Summary of the Invention

[0006] To address the above problems, this invention aims to construct a cloth simulation method that can read FBX cloth data and generate cloth simulation data that can be modified and rendered in real time at each step using a high-precision cloth simulation method. This invention employs a Spatial Hashing method to accelerate collision detection, enabling rapid collision pair elimination and classification of objects within a certain range of motion space. Furthermore, this invention utilizes an Impact Zone collision optimization method, constructing a triangular facet set for continuous CCD collision detection at each time step and in the next time step, significantly reducing the number of detection pairs.

[0007] The technical solution of the present invention is as follows:

[0008] I. A High-Precision Cloth Simulation Method for Unreal Engine

[0009] Step 1: After reading the cloth data imported from Unreal and binding it to a structure, obtain the original cloth dataset;

[0010] Step 2: Extract the vertices and their positions of the fabric facets from the original fabric dataset to construct the simulation dataset;

[0011] Step 3: Add corresponding AABB bounding boxes to each fabric triangle in the simulation dataset; and construct a spatial hash table and set an index value for each fabric triangle, while storing the fabric triangle corresponding to the spatial location in each hash cell of the spatial hash table;

[0012] Step 4: Based on AABB bounding boxes and combined with spatial hash tables, collision detection is performed on the fabric triangular facets in the simulation dataset to obtain the collision impact domain.

[0013] Step 5: Construct vertex position optimization equations based on the collision impact domain, and use the gradient descent method to iteratively solve the vertex position optimization equations to ensure that there is no collision or penetration between all cloth triangles, obtain the mesh model data and render it into the scene.

[0014] The simulation method further includes the following steps:

[0015] Step 6: Repeat steps 2-5 to render the cloth data for the next time step, thus achieving continuous rendering of the cloth data.

[0016] In step 3, corresponding AABB bounding boxes are added to each fabric triangular facet in the simulation dataset, specifically as follows:

[0017] First, obtain the position of each vertex from the vertex position buffer and construct the corresponding vertex structure object; then, obtain the index from the vertex index buffer and determine the connection relationship between each vertex position, thereby constructing edge, face, and triangle structure objects; then, construct the corresponding AABB bounding box and normal cone from the triangle structure based on the three vertices it contains.

[0018] Step 4 specifically involves:

[0019] First, wide-stage AABB bounding box collision detection is performed on the fabric triangles in the simulation dataset to obtain a wide-stage collision fabric triangle set. Based on the wide-stage collision fabric triangle set, narrow-stage CCD continuous collision detection is performed to obtain the final collision fabric triangle set and store it in the impact domain, denoted as the collision impact domain.

[0020] The collision detection results based on the wide-stage collision detection are used to perform continuous CCD collision detection in the narrow stage to obtain the final set of collision fabric triangles, specifically:

[0021] The set of fabric triangles other than the collision triangle set Td of the wide phase is denoted as the safe fabric triangle set Ts. The triangles in the collision triangle set Td of the wide phase are subjected to CCD continuous collision detection in pairs, and the triangles between the collision triangle set Td of the wide phase and the safe fabric triangle set Ts are subjected to CCD continuous collision detection in pairs, to obtain the final collision fabric triangle set.

[0022] In step 5, the formula for the vertex position optimization equation is as follows:

[0023] min{g(X)+λ T c^(X,s)+μ 2 ||c^(X,s)||2}

[0024] Where g(X) is the momentum difference between the modified vertex position and the original vertex position, c^(X,s) represents the constraint equation containing the slack variable s, λ is the Lagrange multiplier, μ is the penalty function coefficient, T represents the transpose, and ||||2 represents the spectral norm.

[0025] In step 5, the mesh model data is passed to the executable mesh component in Unreal Engine, where it is rendered and displayed in the user's visual interface.

[0026] II. A computer device

[0027] The device includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the steps of the high-precision cloth simulation method for Unreal Engine.

[0028] III. A computer-readable storage medium

[0029] The medium stores a computer program, which, when executed by a processor, implements the steps of the high-precision cloth simulation method for Unreal Engine.

[0030] IV. A computer program product

[0031] The product includes a computer program / instructions that, when executed by a processor, implement the steps of the high-precision cloth simulation method for Unreal Engine.

[0032] V. A High-Precision Cloth Simulation System for Unreal Engine

[0033] The raw fabric dataset generation module is used to read fabric data imported from Unreal and generate the raw fabric dataset after binding it to a structure.

[0034] The simulation dataset construction module is used to extract the vertices and their position information of the fabric facets in the original fabric dataset to obtain the simulation dataset;

[0035] A spatial hash table generator is used to generate spatial hash tables and store the fabric triangles in the simulation dataset.

[0036] The collision impact domain generation module is used to perform collision detection on the fabric triangular facets in the simulation dataset based on AABB bounding boxes and combined with a spatial hash table to obtain the collision impact domain.

[0037] The optimizer and renderer are used to construct vertex position optimization equations based on the collision impact domain. The gradient descent method is used to iteratively solve the vertex position optimization equations to ensure that there is no collision or penetration between all cloth triangles, thereby obtaining the mesh model data and rendering it into the scene.

[0038] The beneficial effects of this invention are as follows:

[0039] This invention improves the accuracy of cloth simulation in the UE engine, optimizes the shortcomings of general simulation methods in dealing with cloth simulation such as penetration and unrealistic performance, and provides a method in UE that can directly modify underlying data and transmit it to the rendering pipeline instead of using animation nodes and user interface operations. Attached Figure Description

[0040] Figure 1 This is a flowchart illustrating the fabric simulation process in an embodiment of the present invention.

[0041] Figure 2 This is a schematic diagram of the spatial hash structure in an embodiment of the present invention;

[0042] Figure 3 This is a schematic diagram of the two stages of collision detection in an embodiment of the present invention. Detailed Implementation

[0043] The present invention will now be described in further detail with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are for illustrative and explanatory purposes only and are not intended to limit the scope of the invention.

[0044] This invention proposes a high-precision cloth simulation method for Unreal Engine, such as... Figure 1 and Figure 3 As shown, the simulation method includes the following steps:

[0045] Step 1: After reading the cloth data imported from Unreal and binding it to the structure, the original cloth dataset is obtained. The structure is usually a skeletal mesh.

[0046] The Cloth class was custom-created based on the method used to create C++ classes in UE. In its constructor, it first uses CreateDefaultSubobject. <uproceduralmeshcomponent>The method defines a component of an executable mesh that stores the actual vertex positions of the mesh calculated in the algorithm and passes it to the UE's rendering pipeline every frame to display the cloth movement effect in real time on the Play interface.

[0047] In this step, the Cloth class retrieves the skeletal mesh of the cloth object instance in Play space from the user-imported data using the UE's component retrieval method. This is the object structure used in typical cloth simulations in UE. Then, it retrieves its rendering data using the rendering resource retrieval method. The rendering data includes its LOD level data. It is necessary to retrieve its vertex index buffer and vertex position buffer to build the basic data of the executable mesh body used for simulation rendering. This includes the actual position and sequence index of all vertices involved in the cloth mesh in geometric space. UE has corresponding Get methods for this data, but they are all read-only. For developers, it is generally necessary to modify them through the corresponding user interface of the UE interface.

[0048] The basic simulation structures required include vertices, edges, faces, and triangular patches:

[0049] The code is illustrated below (using a vertex as an example):

[0050]

[0051]

[0052] Step 2: Extract the vertices and their positions of the fabric facets from the original fabric dataset, construct the simulation dataset, and add simulation attributes including mass and elasticity coefficient.

[0053] Step 3: Add corresponding AABB bounding boxes to each fabric triangle in the simulation dataset obtained by Unreal Engine;

[0054] Add corresponding AABB bounding boxes to each cloth triangle in the simulation dataset obtained by Unreal Engine, specifically:

[0055] First, obtain the position of each vertex from the vertex position buffer and construct the corresponding vertex structure object. Then, obtain the index from the vertex index buffer and determine the connection relationship between each vertex position, thereby constructing edge, face, and triangle structure objects. Then, construct the corresponding AABB bounding box and normal cone from the triangle structure based on the three vertices it contains.

[0056] Brief analysis of the AABB structure:

[0057] Struct AABB{

[0058] Double Xmin;

[0059] Double Xmax;

[0060] Double Ymin;

[0061] Double Ymax;

[0062] Double Zmin;

[0063] Double Zmax;

[0064] It can be seen that we only need to compare the XYZ values ​​of each vertex and calculate the maximum and minimum values.

[0065] At each time step, the bounding box data of the triangle is calculated and modified in real time based on the vertex position.

[0066] The specific structure of the spatial hash table is as follows:

[0067] All colliding entities in space have their triangular faces defined by hash lattices covered by their AABB bounding boxes. These hash lattices can be directly indexed based on spatial coordinates, and pointers to all contained triangular faces are stored. The node addresses of the spatial hash are stored in a hash table, with the key Key=<xAxis,yAxis,zAxis> (Location of the spatial coordinate grid), Value = vector <triangle>(The way to store an array of triangular data structures).

[0068] After the basic structural operations are completed, a spatial hash table is constructed, and an index value is assigned to each fabric triangle. Simultaneously, based on the bounding box's X, Y, and Z coordinates, the fabric triangle corresponding to its spatial location is stored in each hash cell of the spatial hash table, such as... Figure 2 As shown;

[0069] The specific process for this step is as follows:

[0070] 1. Determine the size of the hash grid based on the range of motion of all objects in space and the number of triangular faces in the grid. For example, a 20*20*20 grid will have a maximum of 800 hash grids. The grid is divided into 20 parts along each coordinate axis. Then, all hash grids involved in the AABB bounding box of a certain triangular face can be calculated and placed into each hash grid.

[0071] 2. In a hash cell containing multiple triangular facets, potential triangle pairs that may collide are considered. Of course, before this, some adjacent triangular facets on the mesh can be removed using a normal cone.

[0072] Step 4: Based on AABB bounding boxes and combined with spatial hash tables, collision detection is performed on the fabric triangular facets in the simulation dataset to obtain the collision impact domain.

[0073] Step 4 is as follows:

[0074] First, wide-stage AABB bounding box collision detection is performed on the cloth triangles in the simulation dataset to obtain a wide-stage collision cloth triangle set. Then, narrow-stage CCD continuous collision detection is performed based on this wide-stage collision cloth triangle set to obtain the final collision cloth triangle set, which is stored in the impact zone, denoted as the impact zone. The impact zone structure includes a vertex array storing pointers to all vertex objects related to the collision triangles, an `impacts` array storing each impact instance (this structure will be shown later), and an `active` variable indicating whether this region is activated for collision detection. Point-face constraints and edge constraints are then constructed for all colliding triangles.

[0075] Based on the collision detection results of the wide-stage phase, continuous CCD collision detection of the narrow-stage phase is performed to obtain the final set of collision fabric triangles, specifically:

[0076] The set of cloth triangles, excluding the collision triangle set Td of the wide-stage collision set, is denoted as the safe cloth triangle set Ts. Triangles in the wide-stage collision set Td are subjected to CCD continuous collision detection in pairs, and triangles between the wide-stage collision set Td and the safe cloth triangle set Ts are subjected to CCD continuous collision detection in pairs, resulting in the final collision cloth triangle set. The result of one collision is stored as an impact. An impact domain contains multiple impacts, and each impact stores the constraint type, the index of the involved vertices, and the collision time.

[0077] The code for the impact structure is shown below:

[0078]

[0079] Step 5: Construct vertex position optimization equations based on the collision impact domain, and iteratively solve the vertex position optimization equations using the gradient descent method to ensure that there are no collisions or penetrations between all cloth triangles, thereby obtaining the mesh model data. The formula for the vertex position optimization equations is as follows:

[0080] min{g(X)+λ T c^(X,s)+μ 2 ||c^(X,s)||2}

[0081] Where g(X) is the momentum difference between the modified vertex position and the original vertex position, c(X) is the constraint equation to be solved, and if the sum of all the point-face constraints and edge-edge constraints to be calculated is set as c*(X), then c(X) = -c*(X), c^(X,s) represents the constraint equation containing the slack variable s, λ is the Lagrange multiplier, μ is the penalty function coefficient, T represents the transpose, and ||A||2 represents the spectral norm, which is the square root of the largest eigenvalue λi in AH*A, where AH is the transpose conjugate matrix of A.

[0082] The results of iterative solutions can be divided into the following two cases:

[0083] 1. A solution with a residual less than a certain value is obtained within the specified maximum number of iterations. The position of this solution is applied to modify the vertices of the impact domain where the collision occurs. The velocity change is deduced based on the difference between the previous and previous positions. Then, these data are applied to all relevant vertices involved in modifying the cloth to complete the collision processing.

[0084] 2. If the equation converges within the maximum number of iterations specified by the equation, the solution fails. In this case, the solution reverts to the state before the previous iteration failed.

[0085] Finally, a set of vertex position and velocity data is obtained, which forms the mesh model data and is passed to the executable mesh component in Unreal Engine. After being processed in the rendering pipeline of Unreal Engine, the executable mesh component displays the simulation results in the game operation interface.

[0086] On the other hand, this invention also proposes a high-precision cloth simulation system for Unreal Engine.

[0087] The raw fabric dataset generation module is used to read fabric data imported from Unreal and generate the raw fabric dataset after binding it to a structure.

[0088] The simulation dataset construction module is used to extract the vertices and their position information of the fabric facets in the original fabric dataset to obtain the simulation dataset;

[0089] A spatial hash table generator is used to generate spatial hash tables and store the fabric triangles in the simulation dataset.

[0090] The collision impact domain generation module is used to perform collision detection on the fabric triangular facets in the simulation dataset based on AABB bounding boxes and combined with a spatial hash table to obtain the collision impact domain.

[0091] The optimizer and renderer are used to construct vertex position optimization equations based on the collision impact domain. The gradient descent method is used to iteratively solve the vertex position optimization equations to ensure that there is no collision or penetration between all cloth triangles, thereby obtaining the mesh model data and rendering it into the scene.

[0092] Finally, it should be noted that the above embodiments and descriptions are only used to illustrate the technical solutions of the present invention and not to limit it. Those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the disclosure of the technical solutions of the present invention, and all such modifications and substitutions should be covered within the protection scope of the claims of the present invention.< / triangle> < / uproceduralmeshcomponent>

Claims

1. A high-precision cloth simulation method for Unreal Engine, characterized in that, Includes the following steps: Step 1: After reading the cloth data imported from Unreal and binding it to a structure, obtain the original cloth dataset; Step 2: Extract the vertices and their positions of the fabric facets from the original fabric dataset to construct the simulation dataset; Step 3: Add the corresponding AABB bounding box to each fabric triangle in the simulation dataset; And construct a spatial hash table and set an index value for each fabric triangle, while storing the fabric triangle corresponding to the spatial location in each hash cell of the spatial hash table; Step 4: Based on AABB bounding boxes and combined with spatial hash tables, collision detection is performed on the fabric triangular facets in the simulation dataset to obtain the collision impact domain. Step 4 specifically involves: First, wide-stage AABB bounding box collision detection is performed on the fabric triangles in the simulation dataset to obtain a wide-stage collision fabric triangle set; based on the wide-stage collision fabric triangle set, narrow-stage CCD continuous collision detection is performed to obtain the final collision fabric triangle set and store it in the impact domain, denoted as the collision impact domain. Step 5: Construct vertex position optimization equations based on the collision impact domain, and use the gradient descent method to iteratively solve the vertex position optimization equations to ensure that there is no collision or penetration between all cloth triangles, obtain the mesh model data and render it into the scene; The formula for the vertex position optimization equation is as follows: in, It is the momentum difference between the modified vertex position and the original vertex position. Let represent the constraint equations that include the slack variable s. These are Lagrange multipliers, and μ is the coefficient of the penalty function. Indicates transpose. Represents the spectral norm.

2. The high-precision cloth simulation method for Unreal Engine according to claim 1, characterized in that, The simulation method further includes the following steps: Step 6: Repeat steps 2-5 to render the cloth data for the next time step, thus achieving continuous rendering of the cloth data.

3. The high-precision cloth simulation method for Unreal Engine according to claim 1, characterized in that, In step 3, corresponding AABB bounding boxes are added to each fabric triangular facet in the simulation dataset, specifically as follows: First, obtain the position of each vertex from the vertex position buffer and construct the corresponding vertex structure object; then, obtain the index from the vertex index buffer and determine the connection relationship between each vertex position, thereby constructing edge, face, and triangle structure objects; then, construct the corresponding AABB bounding box and normal cone from the triangle structure based on the three vertices it contains.

4. The high-precision cloth simulation method for Unreal Engine according to claim 1, characterized in that, The collision detection results based on the wide-stage collision detection are used to perform continuous CCD collision detection in the narrow stage to obtain the final set of collision fabric triangles, specifically: The set of fabric triangles other than the collision triangle set Td of the wide phase is denoted as the safe fabric triangle set Ts. The triangles in the collision triangle set Td of the wide phase are subjected to CCD continuous collision detection in pairs, and the triangles between the collision triangle set Td of the wide phase and the safe fabric triangle set Ts are subjected to CCD continuous collision detection in pairs, to obtain the final collision fabric triangle set.

5. The high-precision cloth simulation method for Unreal Engine according to claim 1, characterized in that, In step 5, the mesh model data is passed to the executable mesh component in Unreal Engine, where it is rendered and displayed in the user's visual interface.

6. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 5.

7. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.

8. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, they implement the steps of the method described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Three-dimensional garment and human model collision detection method and device

    CN106354959A

  • Feature-based spatial hash continuous collision detection method

    CN112802203A