Collision detection method and device, computer equipment, computer readable storage medium and computer program product
By pre-generating the reference collision set of virtual clothing offline and performing collision detection based on the set during operation, the problem of inefficient collision detection in the prior art is solved, and a more efficient and accurate collision detection effect is achieved.
Patent Information
- Application Number
- CN202510112326.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-22
- Publication Date
- 2025-05-27
AI Technical Summary
In the prior art, the collision detection algorithm has high complexity, resulting in low efficiency, low accuracy and even negative optimization.
By obtaining a reference collision set for virtual clothing, the collection is pre-generated offline and contains collision data for each virtual cloth pair in virtual clothing. Then, when the virtual object performs an action, collision detection is performed based on the collision data of the first morphological data and the virtual cloth pair.
It reduces the complexity of collision detection and the consumption of computing resources, and improves the performance and accuracy of collision detection.
Smart Images

Figure CN120046443A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical fields of computer graphics and physical simulation, and particularly to a collision detection method, apparatus, computer device, computer-readable storage medium, and computer program product. Background Art
[0002] In a virtual environment, by detecting the contact, collision, or penetration between virtual clothing and a virtual model, other clothing, or objects in the environment, and making corresponding adjustments to the position and shape of the clothing according to the detection results, it is possible to prevent the clothing from passing through the virtual model, improve the realism and immersion of the virtual environment, and ensure its authenticity and rationality in terms of visual effects.
[0003] In related technologies, due to the high complexity of the collision algorithm itself or the need for additional computing resources for collision detection, it increases the power consumption or introduces the risk of lag, ultimately resulting in problems such as low collision detection efficiency, low accuracy, or even negative optimization. Summary of the Invention
[0004] Embodiments of this application provide a collision detection method, apparatus, computer device, computer-readable storage medium, and computer program product, which can improve the efficiency of collision detection.
[0005] The technical solution of the embodiments of this application is implemented as follows:
[0006] Embodiments of this application provide a collision detection method, the method includes:
[0007] Obtain a reference collision set of virtual clothing, the virtual clothing includes at least two layers of virtual fabric, the reference collision set is pre-generated in an offline manner, the reference collision set includes collision data of each pair of virtual fabrics in the virtual clothing, and the pair of virtual fabrics includes two adjacent layers of virtual fabric;
[0008] Obtain the first form data of the virtual clothing when the virtual object wearing the virtual clothing is performing a first action;
[0009] For each pair of virtual fabrics, obtain the collision data of the pair of virtual fabrics from the reference collision set;
[0010] Based on the first form data and the collision data of the pair of virtual fabrics, perform collision detection on the pair of virtual fabrics to obtain the collision detection result of the pair of virtual fabrics.
[0011] Embodiments of this application provide a collision detection apparatus, the apparatus includes:
[0012] A first acquisition module, configured to acquire a reference collision set of virtual clothing, where the virtual clothing includes at least two layers of virtual fabrics, the reference collision set is pre-generated offline, and the reference collision set includes collision data of each pair of virtual fabrics in the virtual clothing, and the pair of virtual fabrics includes two adjacent layers of virtual fabrics;
[0013] A second acquisition module, configured to acquire first form data of the virtual clothing when a virtual object wearing the virtual clothing executes a first action;
[0014] A third acquisition module, configured to, for each pair of virtual fabrics, acquire the collision data of the pair of virtual fabrics from the reference collision set;
[0015] A first detection module, configured to perform collision detection on the pair of virtual fabrics based on the first form data and the collision data of the pair of virtual fabrics, to obtain a collision detection result of the pair of virtual fabrics.
[0016] An embodiment of the present application provides a computer device, including:
[0017] A memory, configured to store computer-executable instructions;
[0018] A processor, configured to implement the collision detection method provided by the embodiment of the present application when executing the computer-executable instructions stored in the memory.
[0019] An embodiment of the present application provides a computer-readable storage medium, storing computer-executable instructions, which are used to cause a processor to implement the collision detection method provided by the embodiment of the present application when executed.
[0020] An embodiment of the present application provides a computer program product, including a computer program or computer-executable instructions, where when the computer program or computer-executable instructions are executed by a processor, the collision detection method provided by the embodiment of the present application is implemented.
[0021] The embodiment of the present application has the following beneficial effects:
[0022] In an embodiment of the present application, first obtain a reference collision set of the virtual clothing. The reference collision set is pre-generated offline and includes collision data of each pair of virtual fabrics in the virtual clothing. Since the reference data set includes collision data that has occurred, the data volume of the reference data set is smaller than that of the full data set of the virtual clothing. Next, during the actual execution of the first action by the virtual object, obtain the first form data of the virtual clothing, which is used to represent the actual form of the virtual clothing. Then, obtain the collision data of the pair of virtual fabrics from the reference collision set. Since the collision data of the pair of virtual fabrics is included in the reference collision data, the data volume of the collision data of the pair of virtual fabrics is also smaller than that of the full data set of the pair of virtual fabrics. Finally, perform collision detection based on the first form data and the collision data of the pair of virtual fabrics. On the one hand, since the reference collision set is pre-generated in an ideal manner, that is, the reference collision set is generated before collision detection, it does not occupy computing resources during collision detection. On the other hand, since the data volume of the collision data of the pair of virtual fabrics is also smaller than that of the full data set of the pair of virtual fabrics, the complexity of collision detection can be reduced, computing resources can be reduced, and thus the performance and accuracy of collision detection can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 is a schematic network architecture diagram of a collision detection system 100 provided by an embodiment of the present application;
[0024] Figure 2 is a schematic structural diagram of a terminal 400 provided by an embodiment of the present application;
[0025] Figure 3 is a first flowchart of a collision detection method provided by an embodiment of the present application;
[0026] Figure 4 is a flowchart of a method for determining a reference collision set provided by an embodiment of the present application;
[0027] Figure 5 is a display schematic diagram of a method for determining second form data provided by an embodiment of the present application;
[0028] Figure 6 is a second flowchart of a collision detection method provided by an embodiment of the present application;
[0029] Figure 7 is a third flowchart of a collision detection method provided by an embodiment of the present application;
[0030] Figure 8A is a test result display interface diagram without using the collision detection method provided by an embodiment of the present application;
[0031] Figure 8B It is a test result display interface diagram using the collision detection method provided by the embodiments of the present application;
[0032] Figure 9 It is a schematic diagram showing a multi-layer virtual clothing provided by the embodiments of the present application;
[0033] Figure 10 It is a schematic flowchart of a pre-computation method provided by the embodiments of the present application.
[0034] It should be noted that the above "first" and "second" are only used to distinguish different solutions, and do not represent the distinction of the advantages and disadvantages of the solutions or the priority in the implementation process. Detailed implementation manners
[0035] In order to make the objectives, technical solutions, and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings. The described embodiments should not be regarded as limitations on the present application. All other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the scope of protection of the present application.
[0036] In the following description, reference is made to "some embodiments", which describe a subset of all possible embodiments. However, it can be understood that "some embodiments" can be the same subset or different subsets of all possible embodiments, and can be combined with each other without conflict.
[0037] In the following description, the terms "first / second / third" are only used to distinguish similar objects and do not represent a specific order for the objects. It can be understood that "first / second / third" can be interchanged with a specific order or sequence when allowed, so that the embodiments of the present application described here can be implemented in an order other than that illustrated or described here.
[0038] In the embodiments of the present application, the term "module" or "unit" refers to a computer program with a predetermined function or a part of a computer program, which works together with other related parts to achieve a predetermined goal, and can be fully or partially implemented by using software, hardware (such as a processing circuit or a memory), or a combination thereof. Similarly, one processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be a part of an overall module or unit including the function of the module or unit.
[0039] Unless otherwise defined, all technical and scientific terms used in the embodiments of the present application have the same meaning as commonly understood by those skilled in the technical field to which the present application belongs. The terms used in the embodiments of the present application are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.
[0040] In the embodiments of this application, when collecting and processing relevant data in practical applications, it should strictly comply with the requirements of relevant laws and regulations, obtain the informed consent or separate consent of the personal information subject, and carry out subsequent data use and processing within the scope authorized by laws and regulations and the personal information subject.
[0041] Before further elaborating on the embodiments of this application, the nouns and terms involved in the embodiments of this application are explained. The nouns and terms involved in the embodiments of this application are applicable to the following explanations.
[0042] 1) Collision detection refers to the process of detecting whether two or more objects come into contact or overlap in the fields of computer graphics, physical simulation, game development, robotics, etc. Its purpose is to determine whether there is a collision between objects so as to perform corresponding processing, such as triggering events, calculating collision responses, and preventing object penetration.
[0043] Collision detection includes discrete collision detection and continuous collision detection. Among them, discrete collision detection is to detect whether an object collides at discrete time points and is applicable to scenarios with high real-time requirements (such as games). Continuous collision detection is to detect whether an object will collide during the entire time interval and is applicable to high-speed moving objects to avoid the "tunnel effect".
[0044] Common methods of collision detection include geometric shape-based detection, space-based detection, and physics-based detection. Among them, geometric shape-based detection includes bounding box detection, separating axis theorem, and Gilbert-Johnson-Keerthi algorithm. Bounding box detection is to approximately represent an object using simple geometric shapes (such as AABB, OBB, sphere) to quickly detect intersection; the separating axis theorem is used to detect whether convex polyhedra intersect; the Gilbert-Johnson-Keerthi algorithm is used to detect collisions between convex shapes. Space-based detection includes space partitioning and hierarchical bounding boxes. Space partitioning is to divide the space into structures such as grids, quadtrees, and octrees to reduce the number of objects to be detected; hierarchical bounding boxes are to optimize the efficiency of collision detection by constructing a hierarchical structure. Physics-based detection is to combine a physics engine (such as Box2D, Bullet, Havok) for accurate collision detection and response.
[0045] 2) Acceleration of collision detection. The acceleration of collision detection refers to improving the speed and efficiency of collision detection and reducing the time required for calculation through algorithm optimization, data structure improvement, or hardware acceleration. In the fields of virtual reality, games, robot simulation, etc., collision detection is a basic and computationally complex technology. The acceleration of collision detection needs to determine whether an object in the scene has collided and how to respond to these collisions.
[0046] Common collision detection acceleration methods include spatial decomposition methods, hierarchical bounding box methods, Graphics Processing Unit (GPU) acceleration, physical engine optimization, and algorithm optimization. Among them, spatial decomposition methods divide the entire space into multiple small regions, such as quadtrees, octrees, etc. Collision detection is only performed when objects are in the same or adjacent regions, thus reducing unnecessary detections. Hierarchical bounding box methods use simple geometric bodies (such as boxes, spheres, etc.) to enclose complex objects and build a hierarchical structure. First, it quickly detects whether the bounding boxes intersect. Only when the bounding boxes intersect, precise collision detection is performed on the internal complex objects. GPU acceleration utilizes the powerful parallel computing ability of the GPU to perform collision detection. Especially when dealing with the collision detection of a large number of objects, the GPU can significantly improve the computing speed. Physical engine optimization provides optimization strategies for collision detection, such as using a unified coordinate system, merging static and dynamic object lists, reducing distance calculations between objects, etc. Algorithm optimization is to improve existing collision detection algorithms, such as optimizing the data structure of collision detection, reducing the number of intersection tests, or improving the efficiency of intersection tests.
[0047] 3) Virtual clothing refers to clothing and accessories created through computer graphics technology and existing in a digital environment. Virtual clothing is not physical clothing but a virtual item composed of digital elements such as 3D models, textures, colors, and patterns.
[0048] Virtual clothing can be used in a variety of digital platforms and applications, including but not limited to video games, social media and virtual worlds, augmented reality, virtual reality, and digital art and fashion. Among them, in video games, players can purchase and wear virtual clothing for characters in the game to personalize the appearance of the characters. In social media and virtual worlds, users can choose different clothing for their virtual avatars on virtual social platforms or in virtual worlds. Through augmented reality technology, users can overlay virtual clothing on the view of the real world for try-on or display. In a virtual reality environment, users can wear virtual clothing to experience immersive interactions. In digital art and fashion, designers can create virtual clothing as digital art works or use it to showcase future fashion trends.
[0049] 4) Virtual cloth pairs refer to the situation where two or more virtual cloths are close to or in contact with each other in a virtual environment. In computer graphics and physical simulation, dealing with adjacent virtual cloth pairs is an important technical issue because their interactions affect the appearance and dynamic behavior of the cloth.
[0050] When dealing with virtual fabric pairs, collision detection needs to be considered to ensure that the fabrics do not penetrate or overlap unnaturally, which requires an accurate collision detection algorithm to identify and handle the contact between the fabrics.
[0051] To better understand the collision detection method provided by the embodiments of the present application, first, the collision detection methods and existing technical problems in the related art will be described.
[0052] In the related art, collision detection is achieved through the following three methods. The first method is simple pairwise collision; the second is an algorithm for accelerating collision detection on the basis of simple pairwise collision, which is also called the Broad-Phase algorithm. Common ones include the Sort and Sweep method, the Spatial Hash method, etc.; the third is the Contact Caching method, which caches the collision acceleration information during runtime for subsequent collisions.
[0053] For the first method above, the algorithm complexity reaches the O(n 2 ) level. For a large number of collision detections, the performance of this method will decline exponentially. For the second method above, some additional calculations need to be performed during runtime to update the internal data structure. In extreme cases, the problem of negative optimization will occur; and the second method above also needs to update or maintain the acceleration result in real time, thus consuming computing resources. For the third method above, the collision acceleration information cache needs to be generated during runtime, and still only limited computing power can be utilized, and the construction of the acceleration information cannot be very accurate; generating collision acceleration data during runtime will increase additional runtime overhead, increase power consumption or introduce the risk of jamming.
[0054] Combined with the above related technologies, the disadvantages of the related technologies at least include: first, the collision detection process is complex, and the collision performance and efficiency are low; second, the consumption of computing resources and power is large, and even negative optimization occurs.
[0055] The embodiments of the present application provide a collision detection method, device, computer device, computer-readable storage medium, and computer program product, which can improve the efficiency of collision detection. Next, the exemplary application of the computer device provided by the embodiments of the present application will be described. The computer device provided by the embodiments of the present application can be implemented as various types of terminals such as laptops, tablets, desktop computers, set-top boxes, smartphones, smart speakers, smart watches, smart TVs, vehicle terminals, robots, drones, medical devices, smart wearable devices, smart mirrors, etc., or can be implemented as a server, or a combination of the two. Next, the exemplary application when the computer device is implemented as a terminal will be described.
[0056] SeeFigure 1 , Figure 1 It is a schematic diagram of the network architecture of the collision detection system 100 provided by an embodiment of the present application. To support a collision detection application, the server 200 is connected to the terminal 400 through the network 300. The network 300 can be a wide area network, a local area network, or a combination of the two.
[0057] Taking a game scenario as an example, the terminal 400 is used to obtain a game installation package from the server 200. The game installation package includes a reference collision set of virtual clothing. The virtual clothing includes at least two layers of virtual fabrics. The reference collision set is pre-generated by the server 200 in an offline manner. The reference collision set includes collision data for each pair of virtual fabrics in the virtual clothing. A pair of virtual fabrics includes two adjacent layers of virtual fabrics. The terminal 400 installs the game based on the game installation package and stores the reference collision set in the game installation package at the same time. The terminal 400 is also used to receive a running instruction for the game, obtain the first form data of the virtual clothing when the virtual object wearing the virtual clothing performs a first action, obtain the collision data of the pair of virtual fabrics from the reference collision set for each pair of virtual fabrics, and perform collision detection on the pair of virtual fabrics based on the first form data and the collision data of the pair of virtual fabrics to obtain the collision detection result of the pair of virtual fabrics.
[0058] In some embodiments, when the collision detection result indicates that a collision occurs between the pair of virtual fabrics, the terminal 400 can also adjust the first form data based on the collision detection result to obtain the adjusted first form data, and present the pair of virtual fabrics based on the adjusted first form data.
[0059] In the embodiment of the present application, the terminal 400 first obtains a reference collision set of the virtual clothing. The reference collision set is pre-generated offline and includes the collision data of each pair of virtual fabrics in the virtual clothing. Since the reference data set includes the collision data that has occurred, the data volume of the reference data set is smaller than that of the full data set of the virtual clothing. Next, during the actual execution of the first action by the virtual object, the terminal 400 obtains the first form data of the virtual clothing, which is used to represent the actual form of the virtual clothing. Then, it obtains the collision data of the pair of virtual fabrics from the reference collision set. Since the collision data of the pair of virtual fabrics is included in the reference collision data, the data volume of the collision data of the pair of virtual fabrics is also smaller than that of the full data of the pair of virtual fabrics. Finally, collision detection is performed based on the first form data and the collision data of the pair of virtual fabrics. On the one hand, since the reference collision set is pre-generated in an ideal manner, that is, the reference collision set is generated before collision detection, it does not occupy the computing resources during collision detection. On the other hand, since the data volume of the collision data of the pair of virtual fabrics is also smaller than that of the full data of the pair of virtual fabrics, the complexity of collision detection can be reduced, the computing resources can be reduced, and thus the performance and accuracy of collision detection can be improved.
[0060] In some embodiments, the server 200 may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It may also be a cloud server that provides basic cloud computing services such as network services, middleware services, domain name services, security services, Content Delivery Network (CDN), and big data and artificial intelligence platforms. The connection between the terminal and the server may be direct or indirect through wired or wireless communication methods, which are not limited in the embodiments of the present application.
[0061] In the collision detection technology of virtual clothing, in addition to being used in virtual clothing for games, the terminal and the server can also be applied to the following scenarios:
[0062] 1. Virtual fitting scene. The terminal device (such as an augmented reality fitting mirror) uses the collision detection algorithm to detect the fitting condition of the virtual clothing and the user's body in real time, ensuring that the virtual clothing does not penetrate the body or show unnatural deformation, and improving the realism of the fitting experience.
[0063] 2. Digital fashion design scene. The server runs collision detection in the design software to help designers verify the dynamic effects of virtual clothing on different human models and avoid clothing penetration or distortion during movement.
[0064] 3. In the virtual social platform scenario, a terminal device (such as a virtual reality headset) uses collision detection technology in a virtual social environment to ensure that the interaction between a user's virtual clothing and other users or environmental objects conforms to physical laws, enhancing the sense of immersion.
[0065] 4. In the film and television special effects production scenario, a server uses collision detection in special effects production software to simulate the matching of virtual clothing and object movements, ensuring that the clothing exhibits realistic physical behavior in dynamic scenes and enhancing the visual effect.
[0066] 5. In the virtual fashion show scenario, a terminal device real-time detects the collision between virtual clothing and a model's body in a virtual fashion show to ensure that the clothing does not experience model penetration or abnormal jitter during the show, presenting a high-quality visual performance.
[0067] 6. In the education and training scenario, a server uses collision detection technology in a virtual training system to help students learn the relationship between clothing design and ergonomics, ensuring the adaptability of virtual clothing to different body types.
[0068] 7. In the e-commerce platform scenario, a terminal device (such as a mobile phone or tablet) uses collision detection technology in an e-commerce application to provide users with a virtual try-on function, ensuring that the display effect of clothing on users is realistic and reliable, enhancing the shopping experience.
[0069] In the above scenarios, the terminal device or server uses an efficient collision detection algorithm to ensure the authenticity and interactivity of virtual clothing in different application scenarios.
[0070] See Figure 2 , Figure 2 which is a schematic structural diagram of the terminal 400 provided by an embodiment of the present application. Figure 2 The terminal 400 shown includes: at least one processor 410, a memory 450, at least one network interface 420, and a user interface 430. Each component in the terminal 400 is coupled together through a bus system 440. It can be understood that the bus system 440 is used to realize the connection and communication between these components. In addition to including a data bus, the bus system 440 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clear illustration, in Figure 2 all kinds of buses are labeled as the bus system 440.
[0071] The processor 410 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor can be a microprocessor or any conventional processor, etc.
[0072] The user interface 430 includes one or more output devices 431 that enable the presentation of media content, including one or more speakers and / or one or more visual display screens. The user interface 430 also includes one or more input devices 432, including user interface components that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, and other input buttons and controls.
[0073] The memory 450 can be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid state memory, hard disk drives, optical disk drives, etc. The memory 450 optionally includes one or more storage devices that are physically located remote from the processor 410.
[0074] The memory 450 includes volatile memory or non-volatile memory, and may also include both volatile and non-volatile memory. The non-volatile memory can be Read Only Memory (ROM), and the volatile memory can be Random Access Memory (RAM). The memory 450 described in the embodiments of the present application is intended to include any suitable type of memory.
[0075] In some embodiments, the memory 450 is capable of storing data to support various operations. Examples of such data include programs, modules, and data structures, or subsets or supersets thereof, which are described below by way of example.
[0076] The operating system 451 includes system programs for processing various basic system services and performing hardware-related tasks, such as a framework layer, a core library layer, a driver layer, etc., for implementing various basic services and processing hardware-based tasks;
[0077] The network communication module 452 is used to reach other electronic devices via one or more (wired or wireless) network interfaces 420. Exemplary network interfaces 420 include: Bluetooth, Wireless Fidelity (WiFi), and Universal Serial Bus (USB), etc.;
[0078] The presentation module 453 is used to enable the presentation of information (such as a user interface for operating peripheral devices and displaying content and information) via one or more output devices 431 associated with the user interface 430 (such as a display screen, speaker, etc.);
[0079] The input processing module 454 is used to detect and translate one or more user inputs or interactions from one of one or more input devices 432.
[0080] In some embodiments, the device provided by the embodiments of the present application may be implemented in software. Figure 2 Shown in the memory 450 is a collision detection device 455, which may be software in the form of a program, a plug-in, etc., including the following software modules: a first acquisition module 4551, a second acquisition module 4552, a third acquisition module 4553, and a first detection module 4554. These modules are logical, and thus can be arbitrarily combined or further split according to the functions to be implemented. The functions of each module will be described below.
[0081] In other embodiments, the device provided by the embodiments of the present application may be implemented in hardware. As an example, the device provided by the embodiments of the present application may be a processor in the form of a hardware decoding processor, which is programmed to execute the collision detection method provided by the embodiments of the present application. For example, a processor in the form of a hardware decoding processor may employ one or more application specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), or other electronic components.
[0082] In some embodiments, the terminal may implement the collision detection method provided by the embodiments of the present application by running various computer-executable instructions or computer programs. For example, the computer-executable instructions may be commands at the microprogram level, machine instructions, or software instructions. The computer program may be a native program or software module in an operating system; it may be a native application (APPlication, APP), that is, a program that needs to be installed in the operating system to run, such as a game APP, a shopping APP, a try-on APP, a mixed reality (MR) APP; or it may be a small program that can be embedded in any APP, that is, a program that only needs to be downloaded into the browser environment to run. In short, the above computer-executable instructions may be instructions in any form, and the above computer programs may be application programs, modules, or plug-ins in any form.
[0083] The collision detection method provided by the embodiments of the present application will be described in conjunction with the exemplary applications and implementations of the terminal provided by the embodiments of the present application.
[0084] Next, the collision detection method provided by the embodiments of the present application will be described. As mentioned above, the computer device implementing the collision detection method of the embodiments of the present application can be a terminal. Therefore, the execution subject of each step will not be repeated hereinafter.
[0085] It should be noted that in the examples of the collision detection method hereinafter, the virtual clothing in the game is taken as an example for illustration. Those skilled in the art can apply the collision detection method provided by the embodiments of the present application to the collision detection processing of virtual clothing in other types including MR, film and television videos, etc. according to the understanding of the following text. The embodiments of the present application can also be applied to various scenarios, including but not limited to games, virtual fitting rooms, digital fashion design, virtual social platforms, film and television special effects production, virtual fashion shows, education and training, e-commerce platforms, etc.
[0086] See Figure 3 , Figure 3 which is a schematic flowchart of a collision detection method provided by the embodiments of the present application. The collision detection method provided by the embodiments of the present application will be described in combination with the steps shown in Figure 3 , and the execution subject of Figure 3 is a terminal.
[0087] In step S101, a reference collision set of the virtual clothing is obtained.
[0088] In the embodiments of the present application, the virtual clothing includes at least two layers of virtual fabrics. The reference collision set is pre-generated in an offline manner. The reference collision set includes collision data of each pair of virtual fabrics in the virtual clothing, and the pair of virtual fabrics includes two adjacent layers of virtual fabrics.
[0089] In some embodiments, the two adjacent layers of virtual fabrics can be an inner fabric and an outer fabric, and the inner virtual fabric can include multiple inner triangular patches, and the outer fabric includes multiple outer triangular patches. Based on this, the collision data of the pair of virtual fabrics can include the first index of the inner triangular patch and the third index of the outer triangular patch. When the collision data includes the first index of the inner triangular patch and the third index of the outer triangular patch, it indicates that a point collision or an edge collision has occurred between the inner triangular patch and the outer triangular patch.
[0090] In some other embodiments, according to the actual situation of a collision, the collision can be classified into a point-triangle patch collision and an edge-triangle patch collision. Based on this, the collision data can also include one of the second index of the intersecting vertex and the fourth index of the intersecting edge. Exemplarily, the collision data can include (IT01, V01, OT01), where IT01 represents the first index of the inner triangle patch, V01 represents the second index of the intersecting vertex, and the intersecting vertex belongs to the inner triangle patch, and OT01 represents the third index of the outer triangle patch. The collision data can also include (IT01, E01, OT01), where E01 represents the fourth index of the intersecting edge, and the intersecting edge belongs to the inner triangle patch.
[0091] In some embodiments, the reference collision set includes the collision data that may occur for each pair of virtual cloths. The reference collision set is obtained by controlling the virtual object to perform at least one preset action. And during the collision detection process, the reference collision set remains unchanged and does not need to be updated or maintained.
[0092] In the embodiments of the present application, the reference collision set is pre-generated in an offline manner. Taking a game scenario as an example, the reference collision set is generated before the game goes online, that is, the reference collision set is generated during the game development stage, so as to directly use the reference collision set to accelerate the collision detection during the game operation stage, thereby improving the efficiency of collision detection.
[0093] In the embodiments of the present application, the reference collision set is stored in the memory space of the terminal, and the reference collision set can be obtained based on the storage location.
[0094] In some embodiments, before performing the above step S101, the reference collision set can be determined first. Based on this, see Figure 4 , before the above step S101, the following steps S001 to S005 can also be executed, which are specifically described below.
[0095] In step S001, at least one preset action is obtained.
[0096] In some embodiments, the preset action can be an action set according to experience. Exemplarily, the preset action can be walking, running, standing, or a dance action. Among them, the dance action can include at least one of a large swing, a wide spread, a strong stretch, a large jump, a wide rotation, a strong swing, and a large step. For example, the dance action can be a high knee lift, a split, a backbend, etc.
[0097] In some embodiments, the number of preset actions can be 1, 2, 5, etc., and the number of preset actions can also be set according to experience.
[0098] In the embodiments of the present application, at least one preset action can be obtained from an action library based on the description information or identifier of the preset action.
[0099] In step S002, during the process of obtaining the virtual object to execute at least one preset action, the first posture of the virtual object.
[0100] In some embodiments, the virtual object is controlled to execute each preset action in sequence. During the execution of the preset action, the first posture of the virtual object can be obtained periodically. Among them, the acquisition period can be determined in combination with visual pauses. Exemplarily, the acquisition period can be 0.05 seconds, 0.04 seconds, 0.03 seconds, etc. That is, in the embodiments of the present application, the first posture of the virtual object is obtained periodically.
[0101] In some embodiments, the preset action can be composed of action segments. Exemplarily, the preset action is waving, and this preset action can be composed of two action segments, namely action segment one: raising the arm and action segment two: waving the arm. The first posture of the virtual object refers to the posture of the virtual object after executing an action segment.
[0102] In some embodiments, at least one of forward dynamics, inverse dynamics, and hybrid dynamics can also be used to determine the first posture of the virtual object.
[0103] In step S003, based on the first posture, the second form data of the virtual clothing is determined.
[0104] In the embodiments of the present application, the physical simulation of the virtual clothing is driven based on the first posture to obtain the second form data of the virtual clothing. In some embodiments, at least one of position-based physical simulation (PBD), spring and mass model-based, particle system-based, constraint-based physical simulation, grid-based physical simulation, physical engine-based simulation, fluid dynamics-based cloth simulation, volume constraint-based cloth simulation, and dynamic grid reconstruction-based can be used to implement the physical simulation, so as to obtain the second form data of the virtual clothing.
[0105] In some embodiments, since the virtual clothing is composed of virtual cloth, based on this, the second form data of the virtual clothing can include the form data of each virtual cloth. Among them, the form data of the virtual cloth refers to the information used to describe and store the shape, structure, and state of the virtual cloth in computer graphics. The form data usually can include geometric data, topological data, material data, physical property data, state data, and animation data.
[0106] Among them, geometric data is used to describe the basic shape and structure of virtual cloth, and is usually represented using a mesh or a particle system. A mesh consists of vertices, edges, and faces, while a particle system consists of a series of particle points. Topological data is used to describe the connection relationships of the virtual cloth mesh, that is, the connection methods between vertices, edges, and faces. This is crucial for simulating the deformation and movement of virtual cloth. Material data is used to describe the surface properties of virtual cloth, such as color, texture, reflectivity, transparency, etc. These data affect the appearance of virtual cloth during rendering. Physical property data is used to describe the physical characteristics of virtual cloth, such as mass, elasticity, stiffness, damping, etc. These properties affect the dynamic behavior of virtual cloth under the action of forces. State data is used to describe the state of virtual cloth at a certain moment, including the position, velocity, acceleration, etc. of vertices. These data are used to simulate the movement and deformation of virtual cloth. In addition, if the virtual cloth is part of an animation, keyframe data or animation curves may also need to be stored to describe the changes of virtual cloth over time.
[0107] In some embodiments, referring to Figure 5 , the above step S003 can be implemented through the following steps S0031 to S0034, which are specifically described below.
[0108] In step S0031, for each layer of virtual cloth of the virtual clothing, the virtual cloth is bound to the skeletal system of the virtual object.
[0109] In some embodiments, the process of binding the virtual cloth to the skeletal system of the virtual object is to associate each first vertex of the virtual cloth with a bone node (or bone) in the skeletal system of the virtual object. Each vertex of the virtual cloth is associated with one or more bones, and a skinning weight is assigned to each bone, so that the bone movement of the virtual object will affect the deformation of the cloth.
[0110] In some embodiments, first, in the skeletal system of the object model, select the bones to be bound (such as bones of the shoulders, arms, neck, etc.), and these bones will affect the cloth parts connected to them. Secondly, establish bone weights. Establishing bone weights means assigning weight values to each first vertex of the cloth, indicating the degree to which the first vertex of the cloth is affected by each bone. Usually, skinning weights are used to represent this, where a skinning weight is a weight value vector indicating the relationship between the first vertex and one or more bones, and the sum of the skinning weights is 1. In addition, the skinning weights can be obtained through methods such as the nearest bone, weight assignment based on bone distance, and so on.
[0111] In step S0032, obtain the skinning weights, initial form data of the virtual cloth, and the system transformation matrix of the skeletal system.
[0112] In some embodiments, the skinning weights include the weights of each first vertex, where the weight of each first vertex reflects its degree of association with different bones. The initial form data of the virtual cloth generally refers to the static state of the virtual cloth without movement, and the initial form data includes the initial positions of each first vertex in the cloth mesh. Each bone has a transformation matrix representing the rotation, translation, and scaling of the bone, and the system transformation matrix includes the transformation matrices of each bone.
[0113] In some embodiments, the skinning weights and initial form data of each first vertex in the virtual cloth can be obtained. The transformation matrices of each bone in the bone system are also obtained.
[0114] In step S0033, based on the skinning weights and the system transformation matrix, the initial form data is transformed to obtain the mesh data of the virtual cloth.
[0115] In some embodiments, step S0033 is to apply the actions and transformations of the target bones to the initial form data of the virtual cloth, and apply the bone transformations to each vertex of the cloth through the skinning weights, so as to obtain the mesh data of the virtual cloth under the actions of the target.
[0116] In some embodiments, the virtual cloth includes a plurality of first vertices, and the initial form data includes the initial positions of the plurality of first vertices. Based on this, the implementation manner of the above step S0033 may include: for each first vertex, obtaining the first bone bound to the first vertex from the bone system; and obtaining the bone transformation matrix of the first bone from the system transformation matrix; obtaining the bone weight of the first vertex for the first bone from the skinning weights; using the bone transformation matrix and the bone weight to perform weighted processing on the initial position to obtain the transformed position of the first vertex; constructing the mesh data based on each transformed position.
[0117] In some embodiments, the implementation manner of the above "for each first vertex, obtaining the first bone bound to the first vertex from the bone system" may be: first obtaining the vertex identifier of the first vertex, and then obtaining the first bone bound to the first vertex from the bone system based on the vertex identifier.
[0118] In some embodiments, the implementation manner of the above "obtaining the bone transformation matrix of the first bone from the system transformation matrix" may be: obtaining the bone identifier of the first bone, and then obtaining the bone transformation matrix of the first bone from the system transformation matrix based on the bone identifier.
[0119] In some embodiments, when the number of the first bones is at least two, the implementation manner of the above "obtaining the bone weight of the first vertex for the first bone from the skinning weights" may be: based on the vertex identifier and the bone identifiers of each first bone, obtaining the bone weight of the first vertex for each first bone from the skinning weights.
[0120] In some embodiments, the above "using the bone transformation matrix and bone weights to perform weighted processing on the initial position to obtain the transformed position of the first vertex" can be implemented by the following formula (1).
[0121] V′ = ∑ i (W i ·T i ·V) Formula (1);
[0122] In the above formula (1), V′ represents the transformed position, W i represents the bone weight, T i represents the bone transformation matrix, and V represents the initial position. Among them, the initial position and the transformed position can be represented by coordinates.
[0123] In some embodiments, the transformed positions of each first vertex of the virtual fabric constitute the mesh data of the virtual fabric.
[0124] Through the above method of constructing mesh data, the virtual fabric is closely coordinated with the preset actions, ensuring that the virtual clothing is dynamic and natural. The influence of multiple bones and precise transformation improve the accuracy and authenticity of the deformation of the virtual fabric. Dynamic update and adaptation to complex actions enable the virtual fabric to respond to the changes in each frame. Efficient calculation and scalability optimize the performance and adapt to large-scale scenarios. It can adjust the simulation behavior according to the physical properties of different virtual fabrics, enhancing compatibility and diversity. Precise physical interaction and collision detection avoid unnatural collisions and penetrations. In this way, the simulation effect of the virtual clothing can be improved, making it exhibit more natural, realistic and dynamic characteristics in the virtual environment.
[0125] In step S0034, each piece of mesh data is adjusted based on preset physical simulation rules to obtain the second form data.
[0126] In the embodiments of the present application, step S0034 is to perform physical simulation on the mesh data of the virtual fabric, simulate the movement and deformation of the fabric under external forces (such as gravity, wind force, elasticity of the fabric itself, etc.), and finally obtain the dynamic form (second form data) of the fabric.
[0127] The implementation process of the above step S0034 includes: First, based on the physical properties of the virtual cloth (such as elasticity, flexibility, friction, etc.) and environmental conditions (such as gravity, wind force, object movement, etc.), the positions of each grid point are adjusted. Then, the elasticity of the virtual cloth is simulated; the collision between the virtual cloth and the body of the virtual object or other objects is detected and collision correction is performed; the gravity is applied to affect the positions of each vertex; and the influence of the wind force on the cloth is also simulated. Finally, physical simulation is carried out through preset physical simulation rules to adjust the positions of each first vertex in the virtual cloth, and the final form of the virtual cloth after executing the action segment is obtained. After physical simulation, the grid data of the virtual cloth is converted from the initial form data into the second form data, that is, the state of the virtual cloth after being affected by external forces during the simulation process.
[0128] In some embodiments, the preset physical simulation rules are physical simulation rules set according to experience. Exemplarily, the preset physical simulation rules can be at least one of PBD, spring and mass model-based, particle system-based, constraint-based physical simulation, grid-based physical simulation, physical engine-based simulation, fluid dynamics-based cloth simulation, volume constraint-based cloth simulation, and dynamic grid reconstruction-based.
[0129] Through the above steps S0031 to S0034, by binding the virtual cloth to the skeletal system of the virtual object, the movement of the virtual cloth can accurately follow the skeletal transformation of the object (such as actions like walking, jumping, etc.). This binding method ensures the coordination between the cloth and the object's actions, enabling the cloth to exhibit natural dynamic behavior during the object's animation. Thus, the virtual cloth will naturally deform as the preset actions of the virtual object change, avoiding the situation where the virtual clothing does not match the virtual object (such as the clothing floating or penetrating). By determining the deformation of the virtual cloth based on the skinning weights and the transformation matrix of the bones, the vertex positions of the virtual cloth will be adjusted according to the actual actions of the object's bones, making the movement of the virtual cloth more in line with physical laws. For example, the stretching, bending, twisting and other deformation behaviors of the virtual cloth are more natural and conform to the performance of cloth in the actual physical scene. Thus, the virtual cloth will not show abrupt deformations, and the vertex movement and morphological changes of the first vertex are smooth and conform to physical reality; natural clothing adaptability is achieved, such as parts like cuffs and skirt hems will naturally change according to the object's actions, avoiding the "stiffness" of artificial intervention. Due to the relationship between the initial form data of the virtual cloth and the transformation matrix of the skeletal system, the virtual cloth can be adjusted according to the changes in the object's animation. This means that no matter how the virtual object moves (such as walking, running, jumping, turning, etc.), the virtual cloth will adapt and make a physical response according to the transformation of the bones. Thus, no matter how the virtual object changes, the virtual cloth can accurately reflect the action changes, avoiding the situation of virtual cloth distortion or unnaturalness. Introducing physical simulations (such as spring forces, gravity, collision detection, etc.) into the simulation process of the virtual cloth can make the virtual cloth respond to environmental changes (such as gravity, wind force, collision, etc.), thereby making the behavior of the virtual cloth more realistic, increasing the dynamic naturalness of the cloth, avoiding unnatural behaviors, and enriching the interaction of the virtual cloth.
[0130] Continue to refer to Figure 4 , and continue to explain based on the above-mentioned step S003.
[0131] In step S004, for each pair of virtual cloths, collision detection is performed on the pair of virtual cloths based on the second form data to obtain the collision data of the pair of virtual cloths.
[0132] In some embodiments, assume that the virtual clothing is a skirt including four layers of skirt hems. If they are the first-layer virtual cloth, the second-layer virtual cloth, the third-layer virtual cloth, and the fourth-layer virtual cloth from the inside to the outside respectively, then the first-layer virtual cloth and the second-layer virtual cloth form virtual cloth pair 1, the second-layer virtual cloth and the third-layer virtual cloth form virtual cloth pair 2, and the third-layer virtual cloth and the fourth-layer virtual cloth form virtual cloth pair 3. That is, this virtual clothing includes three pairs of virtual cloths.
[0133] In some embodiments, continuing with the above example, taking the virtual fabric pair composed of the first-layer virtual fabric and the second-layer virtual fabric as an example, the third form data corresponding to the first-layer virtual fabric is obtained from the second form data, and the fourth form data corresponding to the second-layer virtual fabric is obtained from the second form data. Then, based on the third form data and the fourth form data, a collision detection is performed on the virtual fabric pair to obtain the collision data of the virtual fabric pair.
[0134] In some embodiments, the virtual fabric pair includes an inner fabric and an outer fabric. The inner fabric includes a plurality of inner triangular patches, and the outer fabric includes a plurality of outer triangular patches. Based on this, the implementation manner of the above step S004 may include: for each inner triangular patch, when it is determined based on the second form data that there is a target triangular patch intersecting with the inner triangular patch among the plurality of outer triangular patches, the intersection data of the inner triangular patch is determined based on the inner triangular patch and the target triangular patch; based on the intersection data of each inner triangular patch, the collision data of the virtual fabric pair is constructed.
[0135] In some embodiments, for each inner triangular patch in the inner fabric, when it is determined based on the second form data that there is a target triangular patch among the plurality of outer triangular patches, the first index of the inner triangular patch and the third index of the target triangular patch may be determined as the intersection data of the inner triangular patch; finally, the collision data of the virtual fabric pair is constructed based on the intersection data of each inner triangular patch. Here, the target triangular patch refers to the outer triangular patch intersecting with the inner triangular patch.
[0136] In some embodiments, it may also be first determined based on the second form data whether there is a target triangular patch intersecting with the inner triangular patch among the plurality of outer triangular patches. In actual implementation, the implementation manner of "determining whether there is a target triangular patch intersecting with the inner triangular patch among the plurality of outer triangular patches based on the second form data" may include: for each inner triangular patch, obtaining the first position of the second vertex of the inner triangular patch from the second form data; obtaining the second position of the third vertex of each outer triangular patch from the second form data; when it is determined based on the first position and each second position that at least one second vertex of the inner triangular patch is located inside any outer triangular patch, or at least one edge of the inner triangular patch intersects with any outer triangular patch, it is determined that there is a target triangular patch intersecting with the inner triangular patch among the plurality of outer triangular patches.
[0137] In some embodiments, for each inner triangular patch, first, based on the first patch identifier of the inner triangular patch, obtain the first positions of each second vertex of the inner triangular patch from the second form data. The first positions may be coordinates. Exemplarily, the first positions may include (a1, b1, c1), (a2, b2, c2), and (a3, b3, c3). Similarly, based on the second patch identifier of each outer triangular patch, obtain the second positions of each third vertex of each outer triangular patch from the second form data. Taking one outer triangular patch as an example, the second positions may include (d1, e1, f1), (d2, e2, f2), and (d3, e3, f3).
[0138] In some embodiments, continuing with the above example, first determine the planar position of the outer triangular patch based on (d1, e1, f1), (d2, e2, f2), and (d3, e3, f3); then determine the first distance of (a1, b1, c1) from the planar position, the second distance of (a2, b2, c2) from the planar position, and the third distance of (a3, b3, c3) from the planar position. If there is a target distance less than the distance threshold among the first distance, the second distance, and the third distance, then continue to determine whether (a1, b1, c1), (a2, b2, c2), and (a3, b3, c3) are within the boundary of the outer triangular patch. Here, the barycentric coordinate method or the vector cross product method can be used to determine whether the second vertex is within the boundary of the outer triangular patch. If at least one of (a1, b1, c1), (a2, b2, c2), and (a3, b3, c3) is within the boundary of the outer triangular patch, then determine that at least one second vertex in the inner triangular patch is located inside the outer triangular patch. Based on this, determine that there is a target triangular patch among the multiple outer triangular patches that intersects with the inner triangular patch. The distance threshold is a value set in advance according to experience. Exemplarily, the distance threshold may be 0, 0.01 mm, 0.02 mm, etc.
[0139] In some other embodiments, if the first distance, the second distance, and the third distance are all greater than the distance threshold, or if (a1, b1, c1), (a2, b2, c2), and (a3, b3, c3) are all not within the boundary of the outer triangular patch, then determine that each second vertex in the inner triangular patch is not located inside the outer triangular patch.
[0140] In some embodiments, continuing with the above example, the triangular patch may include three edges, e1, e2, and e3. The first edge position of edge e1 can be determined based on (a1, b1, c1) and (a2, b2, c2), the second edge position of edge e2 can be determined based on (a1, b1, c1) and (a3, b3, c3), and the third edge position of edge e3 can be determined based on (a2, b2, c2) and (a3, b3, c3). Then, based on the first edge position and the plane position of the outer triangular patch, it is determined whether edge e1 intersects the plane where the outer triangular patch is located; based on the second edge position and the plane position of the outer triangular patch, it is determined whether edge e2 intersects the plane where the outer triangular patch is located; based on the third edge position and the plane position of the outer triangular patch, it is determined whether edge e3 intersects the plane where the outer triangular patch is located. If there is at least one edge that intersects the plane where the outer triangular patch is located, the edge that intersects the outer triangular patch is determined as the intersecting edge, and the intersection point of the intersecting edge and the plane where the outer triangular patch is located is determined. If the intersection point is contained within the interior of the outer triangular patch, it is determined that at least one edge of the inner triangular patch intersects the outer triangular patch. Based on this, the target triangular patch among the multiple outer triangular patches that intersects the inner triangular patch is determined.
[0141] In some other embodiments, if each edge is parallel to the plane of the outer triangular patch, or the intersection point is located outside the outer triangular patch, it is determined that each edge of the inner triangular patch does not intersect the outer triangular patch.
[0142] In the above process of determining the target triangular patch, through the detection method of per-vertex and per-edge, the collision area between the inner fabric and the outer fabric can be accurately determined, it can be confirmed whether the vertices of the inner fabric are located inside the triangular patches of the outer fabric, and it can be judged whether the edges of the inner fabric intersect the edges of the triangular patches of the outer fabric. In this way, the possibility of missed detection or false detection can be significantly reduced, ensuring the accuracy of the collision result. The virtual fabric may have wrinkles, bends, or overlaps during movement, and these complex forms will significantly increase the difficulty of collision detection. By obtaining the vertex positions of the inner triangular patches and the vertex positions of the outer triangular patches, and dynamically comparing the spatial relationships of the triangular patches, the complex form changes of the fabric can be flexibly handled. During the detection process, not only the vertex positions are considered, but also the edge interaction situations are judged. This all-round collision detection method can more realistically reflect the physical interaction behaviors between virtual fabrics. This method of detecting each triangular patch one by one can be easily extended to the collision detection between multiple layers of fabrics. For scenarios with multiple objects or complex clothing designs, it can also be well adapted to generate accurate collision data. Through clear conditional judgments (such as vertices being inside the triangular patch or edge intersection situations), the detection range can be quickly narrowed, avoiding redundant calculations for all outer triangular patches. This strategic detection method effectively improves the overall performance.
[0143] In some other embodiments, when it is determined, based on the first position and each second position, that any second vertex in the inner triangular patches does not lie inside any outer triangular patch, or any edge in the inner triangular patches does not intersect any outer triangular patch, it is determined that there is no target triangular patch among the multiple outer triangular patches that intersects with the inner triangular patch.
[0144] In the above process of determining the collision data of the virtual cloth pair, through the intersection detection of each inner triangular patch and outer triangular patch, the collision points, collision depths and collision directions between the virtual cloths can be accurately determined, the overlapping or penetration problems between the inner cloth and the outer cloth can be identified, and a reasonable physical distance between the virtual cloths can be ensured, thereby avoiding the penetration phenomenon. By detecting the intersection situation for each triangular patch one by one instead of a rough overall detection, the collision area of the virtual cloth can be accurately located, avoiding omission or misjudgment, and thus improving the detection accuracy. The triangular patches of the inner and outer cloths may come into contact or overlap due to dynamic changes such as bending, wrinkling, and stretching of the virtual cloth. This process can detect and respond to these complex morphological changes in real time, support dynamic cloth interaction. Even when the virtual cloth undergoes drastic changes in a complex action scenario (such as the inner cloth approaching the outer cloth due to the actions of an object), it can still detect and generate accurate collision data in real time. And whether it is a simple single-layer virtual cloth or a multi-layer complex virtual cloth, it can adapt to complex cloth morphologies through per-triangular-patch detection. By distinguishing the inner and outer cloths and detecting the collisions between the inner triangular patches and the outer triangular patches respectively, the interaction between the cloths can be precisely controlled, thereby achieving hierarchical management and reducing the computational complexity.
[0145] In some embodiments, the implementation manner of the above "determining the intersection data of the inner triangular patch based on the inner triangular patch and the target triangular patch" may include: when at least one second vertex in the inner triangular patch lies inside any outer triangular patch, determining the outer triangular patch containing the second vertex as the target triangular patch, and determining the second vertex contained in the target triangular patch as the intersection vertex; obtaining the first index of the inner triangular patch, the second index of the intersection vertex, and the third index of the target triangular patch, and determining the first index, the second index, and the third index as the point intersection data; when at least one edge in the inner triangular patch intersects any outer triangular patch, determining the outer triangular patch intersecting with the edge as the target triangular patch, and determining the edge intersecting with the target triangular patch as the intersecting edge; obtaining the fourth index of the intersecting edge, and determining the first index, the fourth index, and the third index as the edge intersection data; determining the point intersection data and the edge intersection data as the intersection data of the inner triangular patch.
[0146] In some embodiments, when at least one second vertex in the inner triangular patch is located inside any outer triangular patch, point intersection data can be constructed using the first index, the second index, and the third index, and the point intersection data can be represented as (the first index, the second index, the third index); when at least one edge in the inner triangular patch intersects any outer triangular patch, edge intersection data can be constructed using the first index, the second index, and the fourth index, and the edge intersection data can be represented as (the first index, the fourth index, the third index); finally, the point intersection data and the edge intersection data are jointly determined as the intersection data of the inner triangular patch.
[0147] The above process of determining the intersection data can accurately capture the interaction details between the fabrics by performing a detailed collision and intersection analysis on the inner fabric triangular patches and the outer fabric triangular patches, including the detection of vertex and edge intersections. This detailed detection method can capture the minute changes in the fabrics during dynamic movement, ensure the accuracy of collisions and interactions, and thus accurately identify the interactions between virtual fabric pairs, ensure that the inner fabric does not penetrate the outer fabric, provide real physical feedback, and avoid the generation of false collisions. The above process not only considers whether the vertex is inside the patch, but also further checks whether the fabric edge intersects the outer fabric. This can flexibly handle the complex interactions during the bending or deformation of the fabrics, ensure that collision information can be captured in all cases. Therefore, whether the virtual fabrics are in a bent, stretched, or overlapping state, the interactions of vertices and edges are taken into account to ensure that the dynamic changes in the shape of the virtual fabrics are accurately reflected. By obtaining the indexes of the inner triangular patch, the target triangular patch, and the intersecting vertex or edge, the point intersection data and the edge intersection data are constructed. These data provide a clear basis for subsequent fabric collision correction and physical adjustment, enabling the fabric to return to a suitable position and shape after a collision. Thus, the point intersection data and the edge intersection data provide direct and accurate support for the physical correction of the fabric, avoiding errors in the collision correction process; and by constructing the intersection data, subsequent collision corrections can quickly refer to these data, reducing the computational complexity during each collision detection.
[0148] In step S005, a reference collision set is constructed based on the collision data of each virtual fabric pair.
[0149] In some embodiments, the collision data of each pair of virtual fabrics is stored in a set to obtain a reference collision set. Exemplarily, assume that there are three pairs of virtual fabrics in a virtual garment, namely virtual fabric pair 1, virtual fabric pair 2, and virtual fabric pair 3. The collision data of virtual fabric pair 1 includes data 1, data 2, and data 3, the collision data of virtual fabric pair 2 includes data 4 and data 5, and the collision data of virtual fabric pair 3 includes data 6, data 7, and data 8. Then, the reference collision set can be (data 1, data 2, data 3, data 4, data 5, data 6, data 7, data 8).
[0150] Through the above steps S001 to S005, by accurately recording the preset actions and the first poses of virtual objects and determining the second form data of virtual garments based on the first poses, it is ensured that the dynamic performance of virtual garments is natural and accurate. Collision detection and collision data collection can ensure that the interactions between virtual fabrics and between virtual fabrics and virtual objects conform to physical laws, avoiding unnatural penetrations or incorrect forms. The interactions between virtual fabrics and virtual objects and the environment are more realistic, enhancing the expressiveness of virtual garments and making the interactions between virtual objects and garments more immersive. By dynamically obtaining and updating the pose data (i.e., the first pose) of each action segment, complex object animations and multi-layer virtual garment simulations can be handled, ensuring that the performance of virtual fabrics always meets expectations in changing scenarios. In this way, the quality and effect of virtual garment simulation can be significantly improved, making the dynamic interactions between virtual objects and garments more natural and realistic and enhancing the user's immersive experience.
[0151] Continue to refer to Figure 3 and continue to describe based on step S101 above.
[0152] In step S102, obtain the first form data of the virtual garment when the virtual object wearing the virtual garment is performing the first action.
[0153] In some embodiments, the implementation process of step S102 is similar to the implementation processes of the above steps S002 and S003. Based on this, the implementation process of step S102 can refer to the implementation processes of the above steps S002 and S003. That is, step S102 also periodically obtains the first form data of the virtual garment.
[0154] In step S103, for each pair of virtual fabrics, obtain the collision data of the pair of virtual fabrics from the reference collision set.
[0155] In the embodiments of the present application, the virtual fabric pairs may be sorted in the order from the inside to the outside to obtain the sorted virtual fabric pairs. Continuing with the above example, virtual fabric pair 1, virtual fabric pair 2, and virtual fabric pair 3 are obtained; then, for each virtual fabric pair in the sorted virtual fabric pairs, the collision data of the virtual fabric pair is obtained from the reference collision set.
[0156] In some embodiments, continuing with the above example, assuming the reference collision set is (data 1, data 2, data 3, data 4, data 5, data 6, data 7, data 8), then for virtual fabric pair 1, the collision data of virtual fabric pair 1 is data 1, data 2, and data 3; for virtual fabric pair 2, the collision data of virtual fabric pair 2 is data 4 and data 5; for virtual fabric pair 3, the collision data of virtual fabric pair 3 is data 6, data 7, and data 8.
[0157] In step S104, based on the first form data and the collision data of the virtual fabric pair, collision detection is performed on the virtual fabric pair to obtain the collision detection result of the virtual fabric pair.
[0158] In the embodiments of the present application, when performing collision detection, not only based on the first form data of the virtual fabric, but also based on the collision data of the virtual fabric pair, so that the range of collision detection can be reduced based on the collision data of the virtual fabric pair, and the efficiency of collision detection can be improved.
[0159] In some embodiments, the collision data of the virtual fabric pair includes at least one of point intersection data and edge intersection data. The virtual fabric pair includes an inner fabric and an outer fabric. The inner fabric includes a plurality of inner triangular patches, and the outer fabric includes a plurality of outer triangular patches. Based on this, see Figure 6 , the above step S104 can be implemented by the following steps S1041 to S1047, which will be specifically described below.
[0160] In step S1041, it is determined whether the collision data of the virtual fabric pair includes point intersection data.
[0161] In some embodiments, the data identifier of the collision data of each virtual fabric pair may include a point intersection flag bit. If the point intersection flag bit is 1, it is determined that the collision data of the virtual fabric pair includes point intersection data, and step S1042 is entered; if the point intersection flag bit is 0, it is determined that the collision data of the virtual fabric pair does not include point intersection data. Since the collision data of the virtual fabric pair includes at least one of point intersection data and edge intersection data, it is characterized that the collision data of the virtual fabric pair includes edge intersection data, and step S1045 is entered.
[0162] In step S1042, obtain the first index of the inner triangular patch, the second index of the intersection vertex, and the third index of the outer triangular patch from the point intersection data.
[0163] In some embodiments, in combination with the above process of "determining the intersection data of the inner triangular patch based on the inner triangular patch and the target triangular patch", it can be known that the point intersection data may include (the first index, the second index, the third index). Based on this, in step S1042, the first index of the inner triangular patch, the second index of the intersection vertex, and the third index of the outer triangular patch can be directly obtained from the point intersection data; alternatively, the first index of the inner triangular patch, the second index of the intersection vertex, and the third index of the outer triangular patch can be obtained by parsing the point intersection data.
[0164] In step S1043, based on the first index and the second index, obtain the third position of the intersection vertex from the first form data; based on the third index, obtain the fourth position of the third vertex of the outer triangular patch from the first form data; perform a collision detection based on the third position and the fourth position to obtain a point collision result.
[0165] In some embodiments, first obtain the first positions of the three first vertices of the inner triangular patch from the first form data based on the first index, and then determine the third position of the intersection vertex from the first positions of the three first vertices based on the second index. Similarly, obtain the fourth positions of the three third vertices of the outer triangular patch from the first form data based on the third index. Among them, the third position and the fourth position can be coordinates.
[0166] In some embodiments, the implementation manner of the above "performing a collision detection based on the third position and the fourth position to obtain a point collision result" may include: when it is determined that the intersection vertex is included in the outer triangular patch based on the third position and the fourth position, determine that the intersection vertex intersects with the outer triangular patch, and determine that there is a collision as the point collision result; when it is determined that the intersection vertex is not included in the outer triangular patch based on the third position and the fourth position, determine that the intersection vertex does not intersect with the outer triangular patch, and determine that there is no collision as the point collision result.
[0167] In some embodiments, first determine the planar position of the outer triangular patch based on the fourth positions of the three third vertices; then, based on the third position and the planar position of the outer triangular patch, determine the fourth distance from the intersection vertex to the plane where the outer triangular patch is located. If the fourth distance is less than the distance threshold, continue to determine whether the intersection vertex is within the boundary of the outer triangular patch. Here, the barycentric coordinate method or the vector cross product method can be used to determine whether the intersection vertex is within the boundary of the outer triangular patch. If the intersection vertex is within the boundary of the outer triangular patch, determine that the intersection vertex intersects with the outer triangular patch. Based on this, determine that there is a collision as the point collision result.
[0168] In some other embodiments, if the fourth distance is greater than the distance threshold, or the intersection vertex is outside the boundary of the outer triangular patch, it is determined that the intersection vertex does not intersect with the outer triangular patch. Based on this, it is determined that there is no collision as the point collision result.
[0169] In the above process of determining the point collision result, by clearly judging whether the "intersection vertex is included in the outer triangular patch", the result of whether there is a point collision can be directly obtained. This clear judgment logic reduces the complexity of the algorithm. This judgment based on the geometric position relationship has a simple and clear logic, and can quickly locate and repair errors or abnormal situations. When judging whether the intersection vertex is included inside the outer triangular patch, it is usually based on geometric operations (such as the barycentric coordinate method). This method can accurately judge the relative position of the vertex and the triangular patch, ensure the accuracy of the detection result, so as to accurately distinguish the "intersection" and "non-intersection" situations, avoid mislabeling, and ensure that the detection result has high consistency under different fabric forms.
[0170] In step S1044, it is judged whether the collision data of the virtual fabric pair includes edge intersection data.
[0171] In some embodiments, the data identifier of the collision data of each virtual fabric pair may further include an edge intersection flag bit. If the edge intersection flag bit is 1, it is determined that the collision data of the virtual fabric pair includes edge intersection data, and step S1045 is entered; if the edge intersection flag bit is 0, it is determined that the collision data of the virtual fabric pair does not include edge intersection data, and step S1047 is entered.
[0172] In step S1045, the first index of the inner triangular patch, the fourth index of the intersecting edge, and the third index of the outer triangular patch are obtained from the edge intersection data.
[0173] In some embodiments, combining the above process of "determining the intersection data of the inner triangular patch based on the inner triangular patch and the target triangular patch", it can be known that the edge intersection data may include (the first index, the fourth index, the third index). Based on this, in step S1045, the first index of the inner triangular patch, the fourth index of the intersecting edge, and the third index of the outer triangular patch can be directly obtained from the edge intersection data; or the first index of the inner triangular patch, the fourth index of the intersecting edge, and the third index of the outer triangular patch can be obtained by parsing the edge intersection data.
[0174] In step S1046, based on the first index and the fourth index, the fifth position of the intersecting edge is obtained from the first form data; collision detection is performed based on the fifth position and the fourth position to obtain the edge collision result.
[0175] In some embodiments, the first positions of the three first vertices of the inner triangular patches may be obtained from the first form data based on the first index, and then the fifth position of the intersecting edge may be determined from the first positions of the three first vertices based on the fourth index.
[0176] In some embodiments, the implementation of "performing collision detection based on the fifth position and the fourth position to obtain an edge collision result" may include: when it is determined that the intersecting edge intersects with the outer triangular patch based on the fifth position and the fourth position, it is determined that the intersecting edge intersects with the outer triangular patch, and the existence of a collision is determined as the edge collision result; when it is determined that the intersecting edge does not intersect with the outer triangular patch based on the fifth position and the fourth position, it is determined that the intersecting edge does not intersect with the outer triangular patch, and the non - existence of a collision is determined as the edge collision result.
[0177] In some embodiments, based on the fifth position and the planar position of the outer triangular patch, it is determined whether the intersecting edge is parallel to the plane where the outer triangular patch is located; if the intersecting edge is not parallel to the plane where the outer triangular patch is located, the intersection point of the intersecting edge and the plane where the outer triangular patch is located is determined. If the intersection point is included in the interior of the outer triangular patch, it is determined that the intersecting edge intersects with the outer triangular patch, that is, it is determined that the intersecting edge intersects with the outer triangular patch. Based on this, the existence of a collision is also determined as the edge collision result.
[0178] In some other embodiments, if the intersecting edge is parallel to the plane where the outer triangular patch is located, when it is determined that the intersecting edge does not intersect with the outer triangular patch, that is, it is determined that the intersecting edge does not intersect with the outer triangular patch. Based on this, the non - existence of a collision is also determined as the edge collision result.
[0179] The above - mentioned process of determining the point collision result accurately judges whether the intersecting edge intersects with the outer triangular patch, reduces errors geometrically, thus ensuring that collisions in complex interactions between cloths will not be ignored, and is applicable to the diverse deformations and interactions that may occur in virtual clothing in a dynamic state.
[0180] In step S1047, based on the point collision result and the edge collision result, the collision detection result of the virtual cloth pair is determined.
[0181] In some embodiments, the implementation of the above - mentioned step S1047 may include: when at least one of the point collision result and the edge collision result is the existence of a collision, it is determined that a collision occurs between the virtual cloth pair as the collision detection result of the virtual cloth pair; when both the point collision result and the edge collision result are the non - existence of a collision, it is determined that no collision occurs between the virtual cloth pair as the collision detection result of the virtual cloth pair.
[0182] In some embodiments, if there are point collision results and edge collision results, in the following three cases, the collision between virtual fabrics is determined as the collision detection result of the virtual fabric pair. Case 1: Both the point collision result and the edge collision result indicate a collision. Case 2: The point collision result indicates a collision and the edge collision result indicates no collision. Case 3: The point collision result indicates no collision and the edge collision result indicates a collision.
[0183] In other embodiments, if there is only a point collision result, when the point collision result indicates a collision, the collision between virtual fabrics is determined as the collision detection result of the virtual fabric pair; when the point collision result indicates no collision, the non - occurrence of collision between virtual fabrics is determined as the collision detection result of the virtual fabric pair. Similarly, if there is only an edge collision result, when the edge collision result indicates a collision, the collision between virtual fabrics is determined as the collision detection result of the virtual fabric pair; when the edge collision result indicates no collision, the non - occurrence of collision between virtual fabrics is determined as the collision detection result of the virtual fabric pair.
[0184] In the above process of determining the collision detection result, through the logical combination of the point collision result and the edge collision result, only two possibilities (collision or no collision) need to be checked to determine whether a collision occurs between fabric pairs. This simple and clear logic greatly simplifies the judgment process of collision detection, thereby reducing complex conditional judgments, improving the readability and maintainability of the program. It also avoids additional complex logical analysis and improves the detection efficiency. By integrating the results of point collision and edge collision, all possible interaction situations between fabrics can be comprehensively covered, including the case where the intersection vertex is inside the outer fabric or the fabric edges intersect, etc. This dual - verification mechanism ensures the reliability of the detection result, thereby reducing missed detections and ensuring that a collision is only determined to occur when there is indeed a collision, reducing the possibility of misjudgment.
[0185] Through the above steps S1041 to S1047, by separately processing point intersection data and edge intersection data, the collision detection task is divided into two independent parts, which can accurately capture the collision information between cloths. This refined process not only improves the accuracy of detection but also facilitates taking corresponding subsequent processing for different collision types. In this way, by simultaneously focusing on the intersection of points and edges, all possible collision situations are ensured to be covered; and each detection step is based on clear data indexing and position information, enhancing the detection accuracy. By processing point intersection data and edge intersection data, point collision results and edge collision results are obtained respectively. Finally, the two results are combined to determine the overall collision detection result. This clear output structure facilitates the use and decision-making of subsequent algorithm logic, making the output result intuitive and easy to analyze and store. It is also possible to quickly locate whether the collision problem of the virtual cloth pair is caused by point collision or edge collision. By using the first index, the second index, the third index, and the fourth index, unnecessary repeated calculations are reduced. This index-based method effectively reduces the scale of data to be processed, reduces the computational overhead of directly traversing all triangular patches, and the index structure can be extended to more complex virtual cloth meshes.
[0186] Through the above steps S101 to S104, first, a reference collision set of the virtual clothing is obtained. The reference collision set is pre-generated offline, and the reference collision set includes the collision data of each virtual cloth pair in the virtual clothing. Since the reference data set includes the collision data that has occurred, the data volume of the reference data set is smaller than that of the full data set of the virtual clothing. Then, during the actual execution of the first action by the virtual object, the first form data of the virtual clothing is obtained. The first form data is used to represent the real form of the virtual clothing. Then, the collision data of the virtual cloth pair is obtained from the reference collision set. Since the collision data of the virtual cloth pair is included in the reference collision data, the data volume of the collision data of the virtual cloth pair is also smaller than that of the full data set of the virtual cloth pair. Finally, collision detection is performed based on the first form data and the collision data of the virtual cloth pair. On the one hand, since the reference collision set is pre-generated in an ideal way, that is, the reference collision set is generated before collision detection, it does not occupy the computing resources during collision detection. On the other hand, since the data volume of the collision data of the virtual cloth pair is also smaller than that of the full data set of the virtual cloth pair, the complexity of collision detection can be reduced, the computing resources can be reduced, and thus the performance and accuracy of collision detection can be improved.
[0187] In some embodiments, after determining the collision detection result, the virtual cloth pair can also be presented based on the collision detection result and the first form data. See Figure 7 , after the above step S104, the following steps S105 to S107 can also be executed. The following is a specific description.
[0188] In step S105, it is determined whether the collision detection result is that no collision occurs between the virtual fabric pairs.
[0189] In some embodiments, if the collision detection result is that no collision occurs between the virtual fabric pairs, step S106 is entered; while if the collision detection result is that a collision occurs between the virtual fabric pairs, step S107 is entered.
[0190] In step S106, the virtual fabric pairs are presented based on the first form data. And the process ends.
[0191] Here, it is characterized that no collision occurs between the virtual fabric pairs, so there is no need to perform a correction operation, that is, there is no need to adjust the first form data, and thus the virtual fabric pairs are presented based on the first form data.
[0192] In step S107, the first form data is adjusted based on the collision detection result to obtain the adjusted first form data, and the virtual fabric pairs are presented based on the adjusted first form data.
[0193] Here, it is characterized that a collision occurs between the virtual fabric pairs, so a correction operation needs to be performed, that is, the first form data needs to be adjusted, and the virtual fabric pairs are presented based on the adjusted first form data.
[0194] In some embodiments, the collision detection result includes a collision point, a collision direction, and a collision depth. Based on this, the implementation manner of the above "adjusting the first form data based on the collision detection result to obtain the adjusted first form data" may include: obtaining a preset ratio and obtaining the sixth position of the collision point from the first form data; determining the product of the preset ratio and the collision depth as the adjustment size; controlling the sixth position to move the adjustment size in the opposite direction of the collision direction to obtain the adjusted sixth position; and updating the first form data with the adjusted sixth position to obtain the adjusted first form data.
[0195] In some embodiments, the preset ratio may be a value set in advance according to experience. Exemplarily, the preset ratio may be 1.1, 1.2, 1.5, etc. Assuming the preset ratio is 1.1 and the collision depth is 0.2 mm, then 0.22 mm is determined as the adjustment size. Based on this, assuming the collision direction is horizontally to the right, then the sixth position is controlled to move 0.22 mm horizontally to the left to obtain the adjusted sixth position; and the sixth position in the first form data is replaced with the adjusted sixth position, thereby obtaining the adjusted first form data.
[0196] In the above process of adjusting the first form data, after detecting a collision, by adjusting the position of the collision point, the overlap between virtual cloth pairs can be effectively eliminated. This automated correction method avoids manual intervention and is suitable for dynamic scenarios, thus improving efficiency and enhancing real-time performance. By multiplying the preset ratio by the collision depth to determine the adjustment size, this processing method is designed directly based on physical phenomena, which can ensure the rationality of the adjustment process and the actual cloth movement. The adjustment process conforms to physical intuition (for example, a deeper collision requires a larger adjustment), ensuring physical authenticity; and by adjusting the preset ratio, different types of cloth materials (such as soft or rigid cloth) can be adapted. Adjusting the position of the collision point in the opposite direction of the collision direction can effectively avoid the penetration phenomenon of virtual cloth, so as to ensure that the cloth will not continue to cross after the collision, thus enhancing the visual effect and simulating a reasonable contact state between the cloth and the environment or other cloths.
[0197] Through the above steps S105 to S107, by distinguishing the situation of whether there is a collision, the adjustment operation is only performed when a collision occurs, and when there is no collision, the virtual cloth pair is directly presented based on the first form data, thereby reducing the consumption of computing resources, avoiding unnecessary form adjustment operations, and improving the running efficiency. When a collision is detected, the first form data is adjusted based on the collision detection result to ensure that the interaction between the cloth pairs conforms to the actual physical laws, avoiding overlap or penetration, thereby enhancing physical authenticity, and the adjusted first form data is more in line with the expected collision response. By presenting the cloth state based on the first form data or the adjusted first form data, it can be ensured that the finally presented cloth effect has no interpenetration or overlap, and the visual effect is more natural and smooth, thus improving the user experience and making the interaction and dynamic effect of the virtual cloth pair closer to the real world. Logically separating the processing methods for no collision and collision makes the entire implementation process more organized. In this way, it is convenient to quickly locate problems, enhance maintainability, and is more conducive to subsequent optimization or function expansion.
[0198] Next, an exemplary application of the embodiment of the present application in a practical application scenario will be described.
[0199] The embodiment of the present application proposes a collision detection method, which belongs to a multi-layer cloth collision acceleration method based on pre-computation. In the embodiment of the present application, through an offline motion analysis technology, the collisions between multi-layer cloths are evaluated, and a potentially contact set (PCS) is generated for each triangle in the grid on the cloth. During runtime, it is only necessary to detect whether the collisions in this PCS occur under the current animation. Among them, the cloth corresponds to the virtual cloth in other embodiments, and the PCS corresponds to the reference collision set in other embodiments.
[0200] The collision detection method provided by the embodiments of the present application can improve the collision detection performance of multi-layer fabrics. Figure 8A It is a test result display interface diagram without using the collision detection method provided by the embodiments of the present application. Figure 8B It is a test result display interface diagram using the collision detection method provided by the embodiments of the present application. Refer to Figure 8A and Figure 8B , in unit tests, the calculation time for collision detection and intersection resolution of multi-layer fabrics is reduced from 1.54 milliseconds to 0.02 milliseconds, and the additional operations required to maintain the acceleration structure during the operation of the traditional spatial hashing algorithm are avoided.
[0201] The collision detection method provided by the embodiments of the present application performs offline preprocessing on collision information. Since there is more computing power during precomputation, more accurate data can be obtained. Based on this, when performing collision detection during the game operation, the precomputation results can be used to optimize the collision detection performance.
[0202] Figure 9 It is a schematic display diagram of a multi-layer virtual clothing provided by the embodiments of the present application. Refer to Figure 9 , this virtual clothing includes 4 layers of fabrics, which can be respectively marked as layer 1, layer 2, layer 3, and layer 4. Among them, layer 1 is adjacent to layer 2, layer 2 is adjacent to layer 3, and layer 3 is adjacent to layer 4.
[0203] Multi-layer clothing can also be called multi-layer apparel. Multi-layer apparel is one of the biggest challenges and a research hotspot in game clothing simulation. Due to the limited performance of computer devices during operation, precise collision processing is required between multi-layer fabrics to ensure that there is no penetration between the fabrics. This requires a large amount of calculation. Even in the case of some acceleration algorithms proposed in the related art, it is still too consuming for computer devices or has the risk of negative optimization. Therefore, no game product can provide collision detection for multi-layer clothing.
[0204] The embodiments of the present application generate collision acceleration information, that is, the above-mentioned PCS, through precomputation. Through this offline precomputation process, computer device (such as mobile) game products can have the ability to process multi-layer fabric clothing.
[0205] In some embodiments, during precomputation, a series of character animations specified by the art are used to drive the multi-layer fabric clothing. The series of character animations need to be typical and have large movement amplitudes or extreme poses (Poses), that is, in these Poses of the character animations, it is possible to generate the most collisions for the multi-layer fabrics. Exemplarily, the series of character animations can be walking, running, standing, dance movements, etc. Among them, the series of character animations correspond to the preset actions in other embodiments.
[0206] Refer toFigure 10 , Figure 10 is a flowchart of an implementation of the pre - calculation method provided by an embodiment of the present application. The pre - calculation method provided by the embodiment of the present application will be described in conjunction with Figure 10 the steps shown. Figure 10 The execution subject is any one of the terminal and the server.
[0207] In step S1001, start pre - calculation.
[0208] In step S1002, obtain the character animation and multiple character actions in the character animation.
[0209] In some embodiments, run the specified animation, use forward dynamics to evaluate the pose of the character in each frame of the animation, and use this pose to drive the clothing physical simulation. In the embodiment of the present application, the PBD method is used to implement it. Among them, the character corresponds to the virtual object in other embodiments.
[0210] In step S1003, for each action, evaluate the character pose of each frame in the action and drive the cloth.
[0211] In some embodiments, for each frame, perform collision detection between every two layers of cloth meshes. In the embodiment of the present application, as an example, it is assumed that the inner - layer cloth will push the outer - layer cloth to move, and the reverse push can be ignored. Because offline calculation is used, naive pairwise collision can be used to calculate the collision of triangles in the meshes of two layers of cloth. Among them, the triangle corresponds to the triangular patch in other embodiments.
[0212] In step S1004, perform vertex - triangle collision detection.
[0213] In some embodiments, for triangle - triangle collision, "vertex - triangle" and "edge - triangle" need to be detected. Therefore, during the execution process, the data with collisions is recorded, that is, two types of data will be recorded. One is the data record of vertex - triangle, and the other is the data record of edge - triangle.
[0214] In some embodiments, what is obtained by performing vertex - triangle collision detection is the data record of vertex - triangle. The data record of vertex - triangle includes: the index of the inner - layer triangle, the index of the inner - layer point, and the index of the outer - layer triangle.
[0215] In step S1005, perform edge - triangle collision detection.
[0216] In some embodiments, what is obtained by performing edge - triangle collision detection is the data record of edge - triangle. The data record of edge - triangle includes: the index of the inner - layer triangle, the index of the inner - layer edge, and the index of the outer - layer triangle.
[0217] In step S1006, the data is cached to the potential collision set.
[0218] In step S1007, it is determined whether there is a next character animation.
[0219] In some embodiments, if there is a next character animation, return to the above step S1003; if there is no next character animation, enter step S1008.
[0220] In step S1008, the pre - calculation is completed and the potential collision set is generated.
[0221] In some embodiments, after the character animation to be tested is run, the record of the above - mentioned collision relationship is determined as the potential collision set.
[0222] In some embodiments, at runtime, that is, when collision detection needs to be performed on two layers of fabric, the following steps 1 to 4 can be executed:
[0223] Step 1, according to the indices of the two layers of fabric, determine the collision data corresponding to the two layers of fabric from the potential collision set generated offline.
[0224] Step 2, traverse the vertex and triangle records of the collision data corresponding to the two layers of fabric, and execute the vertex - triangle collision detection algorithm.
[0225] Step 3, traverse the edge and triangle records of the collision data corresponding to the two layers of fabric, and execute the edge - triangle collision detection algorithm.
[0226] Step 4, if a collision occurs in the current frame, continue to run the collision correction operation.
[0227] As can be seen from the above steps 1 to 4, only the data in the potential collision set needs to be subjected to collision detection, thus greatly reducing the computational amount of collision detection during the application runtime.
[0228] Through the collision detection method provided by the embodiments of the present application, the performance of collision handling for multi - layer clothing can be improved, enabling multi - layer clothing to run on devices with limited performance such as mobile terminals; it can also help game products have more room for play in character clothing design and create better expressiveness. Therefore, the collision detection method provided by the embodiments of the present application is a technical advantage for game products.
[0229] It can be understood that in the embodiments of the present application, data related to the reference collision set, the first action, the preset action, the first posture, the skinning weight, the initial form data, the system transformation matrix, the preset ratio, etc. are involved. The collection, use, and processing of this related data need to comply with relevant laws, regulations, and standards.
[0230] Next, the exemplary structure of the collision detection device 455 provided in the embodiments of the present application implemented as a software module will be further described. In some embodiments, as Figure 2 shown, the software module stored in the collision detection device 455 in the memory 450 may include:
[0231] A first acquisition module 4551, configured to acquire a reference collision set of the virtual clothing. The virtual clothing includes at least two layers of virtual fabrics. The reference collision set is pre-generated in an offline manner. The reference collision set includes collision data of each pair of virtual fabrics in the virtual clothing. The pair of virtual fabrics includes two adjacent layers of virtual fabrics; a second acquisition module 4552, configured to acquire first form data of the virtual clothing when the virtual object wearing the virtual clothing performs a first action; a third acquisition module 4553, configured to, for each pair of virtual fabrics, acquire the collision data of the pair of virtual fabrics from the reference collision set; a first detection module 4554, configured to perform collision detection on the pair of virtual fabrics based on the first form data and the collision data of the pair of virtual fabrics, and obtain a collision detection result of the pair of virtual fabrics.
[0232] In some embodiments, the software module stored in the collision detection device 455 in the memory 450 further includes:
[0233] A fourth acquisition module, configured to acquire at least one preset action; a fifth acquisition module, configured to acquire a first posture of the virtual object when the virtual object performs at least one of the preset actions; a first determination module, configured to determine second form data of the virtual clothing based on the first posture; a second detection module, configured to, for each pair of virtual fabrics, perform collision detection on the pair of virtual fabrics based on the second form data, and obtain the collision data of the pair of virtual fabrics; a construction module, configured to construct the reference collision set based on the collision data of each pair of virtual fabrics.
[0234] In some embodiments, the first determination module is further configured to: for each layer of virtual fabric of the virtual clothing, bind the virtual fabric to the bone system of the virtual object; acquire the skinning weight, initial form data of the virtual fabric, and the system transformation matrix of the bone system; perform transformation processing on the initial form data based on the skinning weight and the system transformation matrix to obtain the mesh data of the virtual fabric; and adjust each piece of the mesh data based on a preset physical simulation rule to obtain the second form data.
[0235] In some embodiments, the virtual fabric includes a plurality of first vertices, and the initial form data includes the initial positions of the plurality of first vertices. The first determination module is further configured to: for each of the first vertices, obtain a first bone bound to the first vertex from the bone system; obtain the bone transformation matrix of the first bone from the system transformation matrix; obtain the bone weight of the first vertex with respect to the first bone from the skinning weights; perform weighted processing on the initial position by using the bone transformation matrix and the bone weight to obtain the transformed position of the first vertex; and construct the mesh data based on each of the transformed positions.
[0236] In some embodiments, the virtual fabric pair includes an inner fabric and an outer fabric. The inner fabric includes a plurality of inner triangular patches, and the outer fabric includes a plurality of outer triangular patches. The second detection module is further configured to: for each of the inner triangular patches, when it is determined based on the second form data that there is a target triangular patch among the plurality of outer triangular patches that intersects the inner triangular patch, determine the intersection data of the inner triangular patch based on the inner triangular patch and the target triangular patch; and construct the collision data of the virtual fabric pair based on the intersection data of each of the inner triangular patches.
[0237] In some embodiments, the software module stored in the collision detection device 455 of the memory 450 further includes:
[0238] A sixth acquisition module, configured to obtain, for each of the inner triangular patches, the first position of the second vertex of the inner triangular patch from the second form data; a seventh acquisition module, configured to obtain the second position of the third vertex of each of the outer triangular patches from the second form data; and a second determination module, configured to determine that there is a target triangular patch among the plurality of outer triangular patches that intersects the inner triangular patch when it is determined based on the first position and each of the second positions that at least one second vertex of the inner triangular patches is located inside any one of the outer triangular patches, or at least one edge of the inner triangular patches intersects any one of the outer triangular patches.
[0239] In some embodiments, the second detection module is further configured to: when at least one second vertex in the inner triangular patches is located inside any one of the outer triangular patches, determine the outer triangular patch containing the second vertex as the target triangular patch, and determine the second vertex included in the target triangular patch as the intersection vertex; obtain the first index of the inner triangular patch, the second index of the intersection vertex, and the third index of the target triangular patch, and determine the first index, the second index, and the third index as point intersection data; when at least one edge of the inner triangular patches intersects any one of the outer triangular patches, determine the outer triangular patch intersecting with the edge as the target triangular patch, and determine the edge intersecting with the target triangular patch as the intersection edge; obtain the fourth index of the intersection edge, and determine the first index, the fourth index, and the third index as edge intersection data; determine the point intersection data and the edge intersection data as the intersection data of the inner triangular patches.
[0240] In some embodiments, the collision data of the virtual fabric pair includes at least one of point intersection data and edge intersection data. The virtual fabric pair includes an inner fabric and an outer fabric. The inner fabric includes a plurality of inner triangular patches, and the outer fabric includes a plurality of outer triangular patches. The first detection module 4554 is further configured to: obtain the first index of the inner triangular patch, the second index of the intersection vertex, and the third index of the outer triangular patch from the point intersection data; obtain the third position of the intersection vertex from the first form data based on the first index and the second index; obtain the fourth position of the third vertex of the outer triangular patch from the first form data based on the third index; perform collision detection based on the third position and the fourth position to obtain a point collision result; obtain the first index of the inner triangular patch, the fourth index of the intersection edge, and the third index of the outer triangular patch from the edge intersection data; obtain the fifth position of the intersection edge from the first form data based on the first index and the fourth index; perform collision detection based on the fifth position and the fourth position to obtain an edge collision result; determine the collision detection result of the virtual fabric pair based on the point collision result and the edge collision result.
[0241] In some embodiments, the first detection module 4554 is further configured to: when it is determined that the intersection vertex is included in the outer triangular patch based on the third position and the fourth position, determine that the intersection vertex intersects with the outer triangular patch, and determine that there is a collision as the point collision result; when it is determined that the intersection vertex is not included in the outer triangular patch based on the third position and the fourth position, determine that the intersection vertex does not intersect with the outer triangular patch, and determine that there is no collision as the point collision result.
[0242] In some embodiments, the first detection module 4554 is further configured to: when it is determined, based on the fifth position and the fourth position, that the intersecting edge intersects with the outer triangular patch, determine that the intersecting edge intersects with the outer triangular patch, and determine that there is a collision as the edge collision result; when it is determined, based on the fifth position and the fourth position, that the intersecting edge does not intersect with the outer triangular patch, determine that the intersecting edge does not intersect with the outer triangular patch, and determine that there is no collision as the edge collision result.
[0243] In some embodiments, the first detection module 4554 is further configured to: when at least one of the point collision result and the edge collision result is a collision, determine that a collision occurs between the virtual fabric pairs as the collision detection result of the virtual fabric pairs; when both the point collision result and the edge collision result are no collision, determine that no collision occurs between the virtual fabric pairs as the collision detection result of the virtual fabric pairs.
[0244] In some embodiments, the software module in the collision detection device 455 stored in the memory 450 further includes:
[0245] A first presentation module, configured to present the virtual fabric pairs based on the first form data when the collision detection result is that no collision occurs between the virtual fabric pairs; a second presentation module, configured to adjust the first form data based on the collision detection result to obtain adjusted first form data, and present the virtual fabric pairs based on the adjusted first form data when the collision detection result is that a collision occurs between the virtual fabric pairs.
[0246] In some embodiments, the collision detection result includes a collision point, a collision direction, and a collision depth. The second presentation module is further configured to: obtain a preset ratio, and obtain a sixth position of the collision point from the first form data; determine the product of the preset ratio and the collision depth as the adjustment size; control the sixth position to move the adjustment size in the opposite direction of the collision direction to obtain an adjusted sixth position; update the first form data with the adjusted sixth position to obtain the adjusted first form data.
[0247] An embodiment of the present application provides a computer program product, which includes a computer program or computer executable instructions, and the computer program or computer executable instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer executable instructions from the computer-readable storage medium, and the processor executes the computer executable instructions, so that the computer device executes the above-mentioned collision detection method of the embodiment of the present application.
[0248] Embodiments of the present application provide a computer-readable storage medium storing computer-executable instructions or a computer program, which, when executed by a processor, cause the processor to execute the collision detection method provided by the embodiments of the present application. For example, as Figure 3 , 7 shown in the collision detection method.
[0249] In some embodiments, the computer-readable storage medium may be a memory such as RAM, ROM, flash memory, magnetic surface memory, optical disc, or CD-ROM; or may be various devices including one or any combination of the above memories.
[0250] In some embodiments, the computer-executable instructions may be in the form of a program, software, software module, script, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including being deployed as an independent program or being deployed as a module, component, subroutine, or other unit suitable for use in a computing environment.
[0251] As an example, the computer-executable instructions may or may not correspond to a file in the file system, may be stored as part of a file that stores other programs or data, for example, in one or more scripts in a Hyper Text Markup Language (HTML) document, stored in a single file dedicated to the program being discussed, or stored in multiple cooperating files (for example, files that store one or more modules, subroutines, or code portions).
[0252] As an example, the computer-executable instructions may be deployed to execute on one computing device, or on multiple computing devices located at one location, or, on multiple computing devices distributed at multiple locations and interconnected by a communication network.
[0253] As described above, the above are only embodiments of the present application and are not intended to limit the protection scope of the present application. Any modifications, equivalent replacements, and improvements made within the spirit and scope of the present application are included in the protection scope of the present application.
Claims
1. A collision detection method, characterized in that: The method comprises: Acquire a reference collision set of a virtual garment, the virtual garment comprising at least two layers of virtual cloth, the reference collision set being pre-generated in an offline manner, the reference collision set comprising collision data of each virtual cloth pair in the virtual garment, the virtual cloth pair comprising two adjacent layers of virtual cloth; Acquiring first form data of the virtual clothing when a virtual object wearing the virtual clothing performs a first action; For each virtual cloth pair, obtaining collision data of the virtual cloth pair from the reference collision set; Based on the first shape data and the collision data of the virtual cloth pair, collision detection is performed on the virtual cloth pair to obtain a collision detection result of the virtual cloth pair.
2. The method according to claim 1, characterized in that The method further comprises: Get at least one preset action; Acquire a first posture of the virtual object during a process in which the virtual object performs at least one of the preset actions; Based on the first posture, determining second form data of the virtual clothing; For each of the virtual cloth pairs, performing collision detection on the virtual cloth pair based on the second shape data to obtain collision data of the virtual cloth pair; The reference collision set is constructed based on the collision data of each of the virtual cloth pairs.
3. The method according to claim 2, characterized in that The determining, based on the first posture, second form data of the virtual clothing includes: For each layer of virtual cloth of the virtual clothing, binding the virtual cloth to the skeleton system of the virtual object; Acquire the skin weight and initial shape data of the virtual cloth and the system transformation matrix of the skeletal system; Based on the skin weight and the system transformation matrix, the initial shape data is transformed to obtain mesh data of the virtual cloth; Each of the grid data is adjusted based on a preset physical simulation rule to obtain the second shape data.
4. The method according to claim 3, characterized in that The virtual cloth includes a plurality of first vertices, the initial shape data includes initial positions of the plurality of first vertices, and the initial shape data is transformed based on the skin weight and the system transformation matrix to obtain mesh data of the virtual cloth, including: For each of the first vertices, obtain a first bone bound to the first vertex from the skeletal system; and obtain a bone transformation matrix of the first bone from the system transformation matrix; Obtaining a bone weight of the first vertex to the first bone from the skin weight; Performing weighted processing on the initial position using the bone transformation matrix and the bone weight to obtain a transformed position of the first vertex; The grid data is constructed based on each of the transformed positions.
5. The method according to claim 4, characterized in that The virtual cloth pair includes an inner cloth layer and an outer cloth layer, the inner cloth layer includes a plurality of inner triangular facets, and the outer cloth layer includes a plurality of outer triangular facets, and performing collision detection on the virtual cloth pair based on the second morphological data to obtain collision data of the virtual cloth pair includes: For each of the inner triangular facets, when it is determined based on the second morphological data that there is a target triangular facet intersecting with the inner triangular facet among the plurality of outer triangular facets, determining intersection data of the inner triangular facet based on the inner triangular facet and the target triangular facet; Based on the intersection data of each of the inner triangular facets, collision data of the virtual cloth pair is constructed.
6. The method according to claim 5, characterized in that The method further comprises: For each of the inner triangular facets, obtaining a first position of a second vertex of the inner triangular facet from the second morphological data; Acquire a second position of a third vertex of each of the outer triangular facets from the second morphological data; When it is determined based on the first position and each of the second positions that at least one second vertex in the inner triangle is located inside any of the outer triangles, or at least one edge in the inner triangle intersects with any of the outer triangles, it is determined that there is a target triangle among the multiple outer triangles that intersects with the inner triangles.
7. The method according to claim 6, characterized in that The determining, based on the inner triangular facet and the target triangular facet, intersection data of the inner triangular facet comprises: When at least one second vertex in the inner triangular facet is located inside any of the outer triangular facets, the outer triangular facet containing the second vertex is determined as a target triangular facet, and the second vertex contained in the target triangular facet is determined as an intersection vertex; Obtaining a first index of the inner triangle, a second index of the intersection vertex, and a third index of the target triangle, and determining the first index, the second index, and the third index as point intersection data; When at least one edge of the inner triangle patch intersects with any of the outer triangle patches, the outer triangle patch intersecting with the edge is determined as a target triangle patch, and the edge intersecting with the target triangle patch is determined as an intersecting edge; Obtaining a fourth index of the intersecting edge, and determining the first index, the fourth index, and the third index as edge intersection data; The point intersection data and the edge intersection data are determined as the intersection data of the inner layer triangle facets.
8. The method according to any one of claims 1 to 7, characterized in that: The collision data of the virtual cloth pair includes at least one of point intersection data and edge intersection data, the virtual cloth pair includes an inner cloth layer and an outer cloth layer, the inner cloth layer includes a plurality of inner triangular facets, and the outer cloth layer includes a plurality of outer triangular facets, and the performing collision detection on the virtual cloth pair based on the first morphological data and the collision data of the virtual cloth pair to obtain the collision detection result of the virtual cloth pair includes: Obtaining a first index of an inner triangular face, a second index of an intersection vertex, and a third index of an outer triangular face from the point intersection data; Based on the first index and the second index, obtain the third position of the intersecting vertex from the first morphological data; based on the third index, obtain the fourth position of the third vertex of the outer triangular facet from the first morphological data; perform collision detection based on the third position and the fourth position to obtain a point collision result; Obtaining a first index of an inner triangle patch, a fourth index of an intersecting edge, and a third index of an outer triangle patch from the edge intersection data; Based on the first index and the fourth index, obtaining a fifth position of the intersecting edge from the first shape data; performing collision detection based on the fifth position and the fourth position to obtain an edge collision result; A collision detection result of the virtual cloth pair is determined based on the point collision result and the edge collision result.
9. The method according to claim 8, characterized in that The performing collision detection based on the third position and the fourth position to obtain a point collision result includes: When it is determined that the intersecting vertex is included in the outer triangular facet based on the third position and the fourth position, it is determined that the intersecting vertex intersects with the outer triangular facet, and the existence of a collision is determined as the point collision result; When it is determined based on the third position and the fourth position that the intersecting vertex is not included in the outer triangular facet, it is determined that the intersecting vertex does not intersect with the outer triangular facet, and the absence of collision is determined as the point collision result.
10. The method according to claim 9, characterized in that The performing collision detection based on the fifth position and the fourth position to obtain an edge collision result includes: When it is determined that the intersecting edge intersects with the outer triangular facet based on the fifth position and the fourth position, determining that the intersecting edge intersects with the outer triangular facet, and determining the existence of a collision as the edge collision result; When it is determined based on the fifth position and the fourth position that the intersecting edge does not intersect with the outer triangular facet, it is determined that the intersecting edge does not intersect with the outer triangular facet, and the absence of collision is determined as the edge collision result.
11. The method according to claim 10, characterized in that The determining the collision detection result of the virtual cloth pair based on the point collision result and the edge collision result includes: When at least one of the point collision result and the edge collision result indicates that there is a collision, a collision occurs between the virtual cloth pairs, and is determined as a collision detection result of the virtual cloth pairs; When both the point collision result and the edge collision result indicate that there is no collision, it is determined that no collision occurs between the virtual cloth pairs as the collision detection result of the virtual cloth pairs.
12. The method according to claim 11, characterized in that After obtaining the collision detection result of the virtual cloth pair, the method further includes: When the collision detection result shows that no collision occurs between the virtual cloth pairs, presenting the virtual cloth pairs based on the first shape data; When the collision detection result indicates that a collision occurs between the virtual cloth pair, the first shape data is adjusted based on the collision detection result to obtain adjusted first shape data, and the virtual cloth pair is presented based on the adjusted first shape data.
13. The method according to claim 12, characterized in that The collision detection result includes a collision point, a collision direction, and a collision depth. The adjusting the first shape data based on the collision detection result to obtain the adjusted first shape data includes: Obtaining a preset ratio, and obtaining a sixth position of the collision point from the first form data; determining the product of the preset ratio and the collision depth as the adjustment size; Controlling the sixth position to move the adjustment size in the opposite direction of the collision direction to obtain an adjusted sixth position; The first form data is updated using the adjusted sixth position to obtain the adjusted first form data.
14. A collision detection device, characterized in that: The device comprises: A first acquisition module is used to acquire a reference collision set of a virtual garment, the virtual garment comprising at least two layers of virtual cloth, the reference collision set being pre-generated in an offline manner, the reference collision set comprising collision data of each virtual cloth pair in the virtual garment, the virtual cloth pair comprising two adjacent layers of virtual cloth; A second acquisition module is used to acquire first form data of the virtual clothing when the virtual object wearing the virtual clothing performs a first action; A third acquisition module, configured to acquire, for each virtual cloth pair, collision data of the virtual cloth pair from the reference collision set; The first detection module is used to perform collision detection on the virtual cloth pair based on the first shape data and the collision data of the virtual cloth pair to obtain a collision detection result of the virtual cloth pair.
15. A computer device, characterized in that: The computer device comprises: A memory for storing computer executable instructions; A processor, configured to implement the collision detection method according to any one of claims 1 to 13 when executing the computer executable instructions stored in the memory.
16. A computer-readable storage medium storing computer-executable instructions, characterized in that: When the computer executable instructions are executed by a processor, the collision detection method according to any one of claims 1 to 13 is implemented.
17. A computer program product comprising a computer program or computer executable instructions, characterized in that When the computer program or computer executable instructions are executed by a processor, the collision detection method according to any one of claims 1 to 13 is implemented.