A multi-thread based model collision detection method

By employing multi-threaded parallel computing technology and utilizing spherical point sets and independent sub-threads to determine model collisions, the problem of excessively long detection times for high-surface-number models in traditional methods is solved, achieving efficient collision detection.

CN117473786BActive Publication Date: 2026-07-21GENERAL ENG RES INST CHINA ACAD OF ENG PHYSICS
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
GENERAL ENG RES INST CHINA ACAD OF ENG PHYSICS
Filing Date
2023-12-04
Publication Date
2026-07-21

AI Technical Summary

Technical Problem

Traditional model collision detection methods are too time-consuming as the model's detail increases, especially for models with a high number of polygons. Existing filter methods have failed to effectively solve the detection efficiency problem.

Method used

By employing multi-threaded parallel computing technology, a spherical point set is established through random sampling and an independent sub-thread is allocated to perform ray set judgment. The main thread merges the results of the sub-threads to determine model collisions, thereby making full use of parallel computing resources.

Benefits of technology

Collision detection of refined facet models can be completed in a shorter time, improving detection efficiency and meeting the needs of rapid detection of high facet models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117473786B_ABST
    Figure CN117473786B_ABST
Patent Text Reader

Abstract

The application discloses a kind of model collision detection methods based on multithreading, multithread parallel computing technology is introduced into model collision detection calculation simulation, to improve the efficiency of calculation, solve the problem of poor timeliness caused by single-threaded computing;With the center of a point in model A as the center of a sphere, a spherical surface is established, a set of uniformly distributed points on the spherical surface is obtained based on random sampling algorithm, a set of rays is established, and a shooting trace method is used to determine whether model A and model B intersect;Introduce envelope rectangle to filter invalid rays, and the number of sampling points can also be used to control the workload of collision detection calculation;The ray set is divided into n sub-ray sets, each sub-ray set is independent of each other, and each sub-ray set is assigned a sub-thread, and whether the two models collide is determined based on the sub-ray set in the sub-thread;Under the condition of limited computing resources, the calculation time can be effectively shortened.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of model collision detection technology, and in particular to a multi-threaded model collision detection method. Background Technology

[0002] In computer simulations, collision detection time increases exponentially with model detail. Traditional methods employ various filters to remove invalid detection points in an attempt to improve efficiency. However, for models with high detail and a large number of facets, the time consumption remains a significant concern.

[0003] Therefore, it is necessary to develop a multi-threaded model collision detection method to solve the above problems. Summary of the Invention

[0004] The purpose of this invention is to design a multi-threaded model collision detection method to solve the above problems.

[0005] The present invention achieves the above objectives through the following technical solutions:

[0006] A multi-threaded model collision detection method is provided to determine whether model A and model B collide. The model collision detection method includes the following steps:

[0007] S1. Construct a sphere with a point inside model A as the center, and obtain a set of points uniformly distributed on the sphere through a random sampling algorithm;

[0008] S2. Using the center of the sphere as the initial point, establish a ray set based on the point set on the sphere:

[0009] S3. Divide the ray set into m parts and assign an independent sub-thread to each ray subset;

[0010] S4. Start all child threads in the main thread. In the child threads, determine whether the two models collide based on the sub-ray set. If they collide, set the flag to 1.

[0011] S5. In the main thread, wait in a loop. When a sub-thread finishes its calculation and its corresponding flag is set to 1, it is considered that model A and model B have collided, and all sub-threads are stopped. When all sub-threads have finished their calculations and no sub-thread flag is set to 1, it is considered that model A and model B have not collided.

[0012] Specifically, in step S1, the center of the sphere is Construct a sphere with radius r, and obtain a set of n points uniformly distributed on the sphere through the following steps:

[0013] S11. Obtain random numbers between -1 and 1 through uniform sampling. and As shown in equation (1);

[0014] (1)

[0015] S12, if If the value is less than 1, the coordinates of a point in the point set can be obtained using formula (2).

[0016] (2)

[0017] in, , , These are the coordinates of a point in the point set.

[0018] S13. Through the above steps, obtain a point set of number n uniformly distributed on the sphere.

[0019] Specifically, in step S4, the collision between two models is determined in the sub-thread based on the sub-ray set. The determination method is as follows:

[0020] S41. Based on the coordinates of the triangular facets of model B, obtain the coordinates of each vertex of its envelope rectangle, and then obtain the 12 triangular facets that make up the envelope rectangle.

[0021] S42. Select a ray from the sub-ray set and determine whether the ray intersects with the 12 triangular facets based on the shooting trajectory method. If they do not intersect, proceed to the next ray judgment.

[0022] S43. If they intersect, the ray traverses all triangular elements of model B to obtain all intersection points with model B; if they do not intersect, proceed to the next ray judgment; if they intersect, based on the arrival time, obtain the coordinates of the point that first intersects with model B, and proceed to the next step.

[0023] S44. The ray traverses all triangular elements of model A to obtain all intersection points with model A; based on the arrival time, the coordinates of the point that finally intersects with model A are obtained.

[0024] S45. Based on the two intersection points of the ray with model A and model B, if the ray reaches the intersection point of model A first, proceed to the next ray judgment; if the ray reaches the intersection point of model B first, it is considered that model A and model B collide, the sub-thread ends, and the sub-thread flag is set to 1.

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

[0026] This application introduces multi-threaded parallel computing technology into the model collision detection calculation process. To adapt to multi-threaded computing, the computational workload is divided into several subsets, and an independent thread is allocated to each subset. The collision detection calculation is completed within the subset. After all threads have completed their calculations, the results of the thread calculations are fused to obtain the collision detection results of the surface model. This fully utilizes parallel computing resources to complete the collision detection calculation of the refined surface model in a short time. Attached Figure Description

[0027] Figure 1 This is a flowchart illustrating the process of this application. Detailed Implementation

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

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

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

[0031] In the description of this invention, it should be understood that the terms "upper," "lower," "inner," "outer," "left," "right," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings, or the orientation or positional relationship commonly used when the product of this invention is in use, or the orientation or positional relationship commonly understood by those skilled in the art. They are only used to facilitate the description of this invention and to simplify the description, and are not intended to indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this invention.

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

[0033] In the description of this invention, it should also be noted that, unless otherwise explicitly specified and limited, terms such as "set" and "connection" should be interpreted broadly. For example, "connection" can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium; it can be a connection within two components. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.

[0034] The specific embodiments of the present invention will now be described in detail with reference to the accompanying drawings.

[0035] like Figure 1 As shown, a multi-threaded model collision detection method is used to determine whether model A and model B collide. The model collision detection method includes the following steps:

[0036] S1. Take any point inside model A. Using this point as the center, construct a sphere with radius r, and obtain a set of n points uniformly distributed on the sphere through the following steps.

[0037] S11. Obtain random numbers between -1 and 1 through uniform sampling. and The formula is shown in equation (1).

[0038] (1)

[0039] S12, if If the value is less than 1, the coordinates of a point in the point set can be obtained through formula (2).

[0040] (2)

[0041] in, , , These are the coordinates of a point in the point set.

[0042] S13. Through the above steps, obtain a point set of number n that is uniformly distributed on the sphere.

[0043] S2. With the center of the sphere as the initial point, establish a ray set based on the sphere's point set. The velocity vector of the ray set is shown in formula (3).

[0044] (3)

[0045] S3. Divide the ray set into m parts and assign an independent child thread to each ray subset. Set a global flag for each thread, with an initial value of 0. Taking C# as an example, the thread allocation statement is: my_thread = new Thread(newThreadStart(fun)), where my_thread is the newly created thread and fun is the collision detection function.

[0046] S4. Start all child threads in the main thread, and determine whether the two models collide based on the sub-ray sets in the child threads. The determination method is as follows:

[0047] S41. Coordinates of triangular facets based on model B Obtain the coordinates of each vertex of its envelope rectangle. The calculation formulas are shown in equations (4) and (5). This yields 12 triangular facets that form the envelope rectangle.

[0048] (4)

[0049] (5)

[0050] in, For the coordinate set of triangular facet elements The maximum coordinate value in; For the coordinate set of triangular facet elements The minimum coordinate value in; The coordinates of the center point of the envelope rectangle of model B; Let the length, width, and height be the dimensions of the rectangle enclosing model B; , , , , , , , Here are the coordinates of the 8 vertices of the rectangle enclosing model B.

[0051] S42. Select a ray from the sub-ray set. Based on the shooting trajectory method, determine whether the ray intersects with any of the 12 triangular facets. If they do not intersect, proceed to the next ray. The method for determining ray-facet intersection is: calculate the time it takes for the ray to reach the plane containing the triangular facet. The calculation formula is shown in equation (6). If If the value is greater than or equal to zero, the ray trajectory intersects the plane containing the triangular element. Then, the intersection point of the ray and the plane is calculated using the formula shown in equation (7). Determine whether the intersection point is inside the triangular element. If the intersection point is inside the triangular element, then the ray is considered to intersect the triangular element.

[0052] (6)

[0053] (7)

[0054] in, , , The firing speed is consistent with the direction of the ray, and its size is arbitrary. , , , The plane coefficient of the triangular element; , , The coordinates are the points where the ray intersects the plane containing the triangular element.

[0055] S43. If they intersect, the ray traverses all triangular elements of model B in the same way to obtain all intersection points with model B. If they do not intersect, proceed to the next ray judgment; if they intersect, based on the arrival time, obtain the coordinates of the point that first intersects with model B, and proceed to the next step.

[0056] S44. The ray traverses all triangular elements of model A, obtaining all intersection points with model A. Based on the arrival time, the coordinates of the point that finally intersects with model A are obtained.

[0057] S45. Based on the two intersection points of the ray with model A and model B, if the ray reaches the intersection point of model A first, proceed to the next ray judgment; if the ray reaches the intersection point of model B first, it is considered that model A and model B collide, the sub-thread ends, and the sub-thread flag is set to 1.

[0058] S5. In the main thread, wait in a loop. When a sub-thread finishes its calculation and its corresponding flag is set to 1, it is considered that model A and model B have collided, and all sub-threads are stopped. When all sub-threads have finished their calculations and no sub-thread flag is set to 1, it is considered that model A and model B have not collided.

[0059] S6. Through steps S1-S5, rapid collision detection between model A and model B can be completed.

[0060] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the technical principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A multi-threaded model collision detection method for determining whether model A and model B collide, characterized in that, The model collision detection method includes the following steps: S1. Construct a sphere with a point inside model A as the center, and obtain a set of points uniformly distributed on the sphere through a random sampling algorithm; S2. Using the center of the sphere as the initial point, establish a ray set based on the point set on the sphere: S3. Divide the ray set into m parts and assign an independent sub-thread to each ray subset; S4. Start all child threads in the main thread. In the child threads, determine whether the two models collide based on the sub-ray set. If they collide, set the flag to 1. S5. In the main thread, wait in a loop. When a sub-thread finishes its calculation and its corresponding flag is set to 1, consider that Model A and Model B have collided and stop all sub-threads. When all sub-threads have finished their calculations and no sub-thread's flag is set to 1, consider that Model A and Model B have not collided. In step S1, the center of the ball is Construct a sphere with radius r, and obtain a set of n points uniformly distributed on the sphere through the following steps: S11. Obtain random numbers between -1 and 1 through uniform sampling. and As shown in equation (1); (1) S12, if If the value is less than 1, the coordinates of a point in the point set can be obtained using formula (2). (2) in, , , These are the coordinates of a point in the point set. S13. Obtain a set of points of number n uniformly distributed on the sphere through the above steps; In step S4, the collision between two models is determined in the sub-thread based on the sub-ray set. The determination method is as follows: S41. Based on the coordinates of the triangular facets of model B, obtain the coordinates of each vertex of its envelope rectangle, and then obtain the 12 triangular facets that make up the envelope rectangle. S42. Select a ray from the sub-ray set and determine whether the ray intersects with the 12 triangular facets based on the shooting trajectory method. If they do not intersect, proceed to the next ray judgment. S43. If they intersect, the ray traverses all triangular elements of model B to obtain all intersection points with model B; if they do not intersect, proceed to the next ray judgment; if they intersect, based on the arrival time, obtain the coordinates of the point that first intersects with model B, and proceed to the next step. S44. The ray traverses all triangular elements of model A to obtain all intersection points with model A; based on the arrival time, the coordinates of the point that finally intersects with model A are obtained. S45. Based on the two intersection points of the ray with model A and model B, if the ray reaches the intersection point of model A first, proceed to the next ray judgment; if the ray reaches the intersection point of model B first, it is considered that model A and model B collide, the sub-thread ends, and the sub-thread flag is set to 1.