Model collision detection method and device

By hierarchizing and subdividing the initial enclosure box, spherical voxels are constructed for collision detection, the problems of poor detection accuracy and large calculation volume in traditional methods are solved, and real-time collision detection in large-scale digital twin scenarios are realized .

CN118674876BActive Publication Date: 2024-11-05中电信数字城市科技有限公司
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411171426.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-26
Publication Date
2024-11-05
Estimated Expiration
2044-08-26

AI Technical Summary

Technical Problem

The collision detection methods of traditional models have poor detection accuracy and large calculation volume, and cannot be applied to collision detection in large-scale digital twin scenarios.

Method used

By synchronously or asynchronously octree stratification of the initial bounding box, the sub-bounding box with the smallest side length smaller than the preset side length is determined, and subdivided, spherical voxels are constructed to judge collisions between models.

Benefits of technology

It improves the accuracy of collision detection and reduces the calculation amount, and can realize real-time collision detection in large-scale digital twin scenarios, solving the problems of poor detection accuracy and large calculation amount of traditional methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118674876B_ABST
    Figure CN118674876B_ABST
Patent Text Reader

Abstract

The present invention provides a model collision detection method and device, belonging to the technical field of collision detection. In the method, two layered sub-bounding boxes that are most likely to collide are first determined by synchronously or asynchronously layering two initial bounding boxes with an octree, and then collision detection is performed only on two models to be detected in the two layered sub-bounding boxes, and other models to be detected that do not belong to the two layered sub-bounding boxes are not considered, which greatly reduces the part of the models to be detected that perform collision detection, that is, reduces the calculation amount of subsequent collision detection; when collision detection is performed on the two models to be detected in the two layered sub-bounding boxes, triangular facets on the surface of some models in the two layered sub-bounding boxes are subdivided, and based on the subdivided triangular facets, collision detection between the two models to be detected is performed by constructing spherical voxels and using whether the spherical voxels intersect, and the detection accuracy is high.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of collision detection, and in particular to a collision detection method and device for a model. Background Art

[0002] In the digital twin system, collision detection and collision interaction between virtual models are crucial. If collision detection is not performed, the models will penetrate each other, thus affecting the realism and immersion of the digital twin system. The essence of collision detection is to determine whether the triangular facets constituting the two models intersect. However, the number of triangular facets in a complex virtual model ranges from tens of thousands to hundreds of thousands. When using the method of whether the triangular facets intersect to perform collision detection between models, the amount of calculation is large. Another common collision detection method is to represent the entire model with an approximate bounding box such as a sphere, a cuboid, or a capsule, and then perform collision detection between models by whether the bounding boxes intersect. However, since the above bounding boxes have poor tightness with the model, and the models in the digital twin system are extremely irregular, the detection accuracy is poor when only using the method of whether the bounding boxes intersect to detect whether the models collide (because the bounding boxes intersect, the models may not necessarily collide).

[0003] In summary, the traditional model collision detection method has technical problems such as poor detection accuracy and large amount of calculation, and cannot be applied to collision detection in large-scale digital twin scenarios. Summary of the invention

[0004] In view of this, the purpose of the present invention is to provide a model collision detection method and device to alleviate the technical problems of poor detection accuracy and large calculation amount in the existing model collision detection method, which cannot be applied to collision detection in large-scale digital twin scenarios.

[0005] In a first aspect, an embodiment of the present invention provides a model collision detection method, comprising:

[0006] Constructing an initial bounding box for each model to be detected respectively, and determining at least one group of target initial bounding boxes that collide based on the initial bounding boxes, wherein a group of the target initial bounding boxes includes two of the initial bounding boxes;

[0007] The following collision detection process is performed in parallel on the two models to be detected in each group of the target initial bounding box:

[0008] Calculate the radii of the circumscribed spheres of two of the target initial bounding boxes in the current group respectively;

[0009] Performing synchronous or asynchronous octree layering on two of the target initial bounding boxes in the current group according to the ratio of the radii of the circumscribed sphere, and determining the layered sub-bounding boxes retained by each of the two initial bounding boxes according to the angles between the vectors formed by the center points of the two initial bounding boxes and the three coordinate axes, wherein the three coordinate axes are the coordinate axes formed by the center point of the initial bounding box and the center points of three adjacent faces of the initial bounding box that share the same vertex, and the two layered sub-bounding boxes are the areas where collision is most likely to occur;

[0010] Determine whether the minimum side lengths of the two layered sub-bounding boxes are both smaller than a preset side length;

[0011] If they are not both smaller than, the two layered sub-bounding boxes are used as the two initial bounding boxes in the target initial bounding box of the current group, and the step of respectively calculating the radii of the circumscribed spheres of the two initial bounding boxes in the target initial bounding box of the current group is returned to, until the minimum side lengths of the two layered sub-bounding boxes are both smaller than the preset side length, thereby obtaining the two layered sub-bounding boxes;

[0012] Subdividing the triangular facets of the partial model surfaces of the two models to be detected in the two layered sub-bounding boxes, and constructing a spherical voxel with the vertices of the subdivided triangular facets as the center points of the spherical voxels and the radius of the inscribed circle of the subdivided triangular facets as the radius of the spherical voxel;

[0013] Whether a collision occurs between the two models to be detected is determined by determining whether the spherical voxels intersect.

[0014] Further, synchronous or asynchronous octree layering is performed on two of the target initial bounding boxes in the current group according to the ratio of the radii of the circumscribed sphere, and layered sub-bounding boxes retained by each of the two initial bounding boxes are determined according to the angles between the vectors formed by the center points of the two initial bounding boxes and the three coordinate axes, including:

[0015] Determining whether the ratio of the radius of the circumscribed sphere is less than a preset threshold;

[0016] If it is less than the preset threshold, the two initial bounding boxes in the current group of the target initial bounding boxes are simultaneously octree layered, and the layered sub-bounding boxes retained by each of the two initial bounding boxes are determined according to the angles between the vectors formed by the center points of the two initial bounding boxes and the three coordinate axes;

[0017] If it is not less than the preset threshold, the larger initial bounding box in the target initial bounding box of the current group is layered by octree, and the layered sub-bounding box retained by the larger initial bounding box is determined according to the angle between the vector formed by the center points of the two initial bounding boxes and the three coordinate axes, so as to obtain the layered sub-bounding box of the larger initial bounding box, and the smaller initial bounding box is used as the layered sub-bounding box of the smaller initial bounding box.

[0018] Further, subdividing the triangular facets of the partial model surfaces of the two models to be detected in the two layered sub-bounding boxes includes:

[0019] Calculating the length of each side of the triangular facets on the partial model surfaces of the two models to be detected;

[0020] Determine whether the length of each side of the same triangular face is less than a preset edge length threshold;

[0021] If they are not all smaller than , then calculate the tangent points between the inscribed circle of the triangular patch and each edge of the triangular patch;

[0022] Connect the tangent points to subdivide the triangular face to obtain a first subdivided triangular face;

[0023] Determine whether the length of each side of the same first subdivided triangular face is less than the preset edge length threshold;

[0024] If they are not all less than, then the first subdivided triangle patch is used as the triangle patch, and the step of calculating the tangent points of the inscribed circle of the triangle patch and each edge of the triangle patch is returned to execute, until the length of each edge of the same first subdivided triangle patch is less than the preset edge length threshold, and the first subdivided triangle patch finally obtained is used as the subdivided triangle patch.

[0025] Furthermore, the method further comprises:

[0026] If the length of each side of the same triangular face is less than the preset edge length threshold, the triangular face is used as the subdivided triangular face;

[0027] If the length of each side of the same first-subdivided triangular facet is less than the preset side length threshold, the first-subdivided triangular facet is used as the subdivided triangular facet.

[0028] Furthermore, the method further comprises:

[0029] After each subdivision, the attribute information of the vertices and the attribute information of the triangles are updated according to the first subdivided triangles, wherein the attribute information of the vertices includes: vertex array, triangle composition array, vertex normal, vertex texture coordinates and vertex tangent array, and the attribute information of the triangles includes: face normal vector and vertex color of the triangles.

[0030] Furthermore, the spherical voxel is constructed by taking the vertex of the subdivided triangular facet as the center point of the spherical voxel and taking the radius of the inscribed circle of the subdivided triangular facet as the radius of the spherical voxel, including:

[0031] Deduplicating vertices in the vertex array to obtain a deduplicated vertex array;

[0032] The spherical voxel is constructed by taking the vertex in the deduplicated vertex array as the center point of the spherical voxel and taking the radius of the inscribed circle of the subdivided triangular facet corresponding to the vertex as the radius of the spherical voxel.

[0033] Further, judging whether a collision occurs between the two models to be detected by using the method of whether the spherical voxels intersect includes:

[0034] If the spherical voxels intersect, a collision occurs between the two models to be detected.

[0035] Furthermore, the method further comprises:

[0036] During the next collision detection, it is determined whether two of the layered sub-bounding boxes where the center points of the two spherical voxels intersecting during the previous collision detection are located collide with each other;

[0037] If a collision occurs, determining the index values ​​of the center points of the two intersecting spherical voxels in the deduplicated vertex array;

[0038] Based on the index value, a first spherical voxel to be detected in one of the models to be detected and a second spherical voxel to be detected in another model to be detected are determined, wherein the index values ​​of the center points of the first spherical voxel to be detected and the second spherical voxel to be detected are in Spherical voxels within the range, Represents the index value of the center point of the two intersecting spherical voxels in the deduplicated vertex array, Indicates the preset value;

[0039] Performing collision detection on the first to-be-detected spherical voxel and the second to-be-detected spherical voxel;

[0040] If it is detected that the first spherical voxel to be detected and the second spherical voxel to be detected do not collide, a third spherical voxel to be detected in one of the models to be detected and a fourth spherical voxel to be detected in another model to be detected are determined based on the index value, wherein the index values ​​of the center points of the third spherical voxel to be detected and the fourth spherical voxel to be detected are in and Spherical voxels within the range, Represents the index value of the center point of the two intersecting spherical voxels in the deduplicated vertex array, Indicates the preset value;

[0041] performing collision detection on the first spherical voxel to be detected and the fourth spherical voxel to be detected, the second spherical voxel to be detected and the third spherical voxel to be detected, and the third spherical voxel to be detected and the fourth spherical voxel to be detected;

[0042] If it is detected that the first to-be-detected spherical voxel and the fourth to-be-detected spherical voxel, the second to-be-detected spherical voxel and the third to-be-detected spherical voxel, and the third to-be-detected spherical voxel and the fourth to-be-detected spherical voxel do not collide, it is determined that the two to-be-detected models do not collide.

[0043] Furthermore, the method further comprises:

[0044] If there are no two intersecting spherical voxels in the last collision detection, returning to the step of determining at least one set of target initial bounding boxes that collide according to the initial bounding boxes;

[0045] If the two layered sub-bounding boxes where the center points of the two intersecting spherical voxels are located do not collide during the last collision detection, the two layered sub-bounding boxes are restored upward by one layer to obtain two layered new sub-bounding boxes;

[0046] The two layered new sub-bounding boxes are used as the two initial bounding boxes in the target initial bounding box of the current group, and the step of respectively calculating the radii of the circumscribed spheres of the two initial bounding boxes in the target initial bounding box of the current group is returned to be executed.

[0047] In a second aspect, an embodiment of the present invention further provides a model collision detection device, comprising:

[0048] A construction and determination unit, configured to construct an initial bounding box for each model to be detected, and determine at least one group of target initial bounding boxes that collide according to the initial bounding boxes, wherein a group of target initial bounding boxes includes two initial bounding boxes;

[0049] The collision detection unit is used to perform the following collision detection process on the two models to be detected in each group of the target initial bounding box in parallel:

[0050] Calculate the radii of the circumscribed spheres of two of the target initial bounding boxes in the current group respectively;

[0051] Performing synchronous or asynchronous octree layering on two of the target initial bounding boxes in the current group according to the ratio of the radii of the circumscribed sphere, and determining the layered sub-bounding boxes retained by each of the two initial bounding boxes according to the angles between the vectors formed by the center points of the two initial bounding boxes and the three coordinate axes, wherein the three coordinate axes are the coordinate axes formed by the center point of the initial bounding box and the center points of three adjacent faces of the initial bounding box that share the same vertex, and the two layered sub-bounding boxes are the areas where collision is most likely to occur;

[0052] Determine whether the minimum side lengths of the two layered sub-bounding boxes are both smaller than a preset side length;

[0053] If they are not both smaller than, the two layered sub-bounding boxes are used as the two initial bounding boxes in the target initial bounding box of the current group, and the step of respectively calculating the radii of the circumscribed spheres of the two initial bounding boxes in the target initial bounding box of the current group is returned to, until the minimum side lengths of the two layered sub-bounding boxes are both smaller than the preset side length, thereby obtaining the two layered sub-bounding boxes;

[0054] Subdividing the triangular facets of the partial model surfaces of the two models to be detected in the two layered sub-bounding boxes, and constructing a spherical voxel with the vertices of the subdivided triangular facets as the center points of the spherical voxels and the radius of the inscribed circle of the subdivided triangular facets as the radius of the spherical voxel;

[0055] Whether a collision occurs between the two models to be detected is determined by determining whether the spherical voxels intersect.

[0056] In an embodiment of the present invention, a model collision detection method is provided, comprising: constructing an initial bounding box for each model to be detected, and determining at least one group of target initial bounding boxes that collide based on the initial bounding boxes, wherein a group of target initial bounding boxes includes two initial bounding boxes; performing the following collision detection process on the two models to be detected in each group of target initial bounding boxes in parallel: calculating the radii of the circumscribed spheres of the two initial bounding boxes in the current group of target initial bounding boxes, respectively; performing synchronous or asynchronous octree layering on the two initial bounding boxes in the current group of target initial bounding boxes based on the ratio of the radii of the circumscribed spheres, and determining the layered sub-bounding boxes retained by each of the two initial bounding boxes based on the angles between the center points of the two initial bounding boxes and the three coordinate axes, wherein the three coordinate axes are the angles between the center points of the initial bounding boxes and the three axes that share the same vertex of the initial bounding boxes. The coordinate axis is formed by the center points of adjacent faces; whether the minimum side lengths of the two layered sub-bounding boxes are both less than the preset side lengths; if not, the two layered sub-bounding boxes are used as the two initial bounding boxes in the current group target initial bounding box, and the steps of respectively calculating the radii of the circumscribed spheres of the two initial bounding boxes in the current group target initial bounding box are returned to execute, until the minimum side lengths of the two layered sub-bounding boxes are both less than the preset side lengths, and the two layered sub-bounding boxes are obtained; the triangular facets of the partial model surfaces of the two models to be detected in the two layered sub-bounding boxes are subdivided, and the vertices of the subdivided triangular facets are used as the center points of the spherical voxels, and the radius of the inscribed circle of the subdivided triangular facets is used as the radius of the spherical voxel to construct a spherical voxel; whether the two models to be detected collide with each other is determined by whether the spherical voxels intersect.From the above description, it can be known that in the collision detection method of the model of the present invention, two layered sub-bounding boxes whose minimum side lengths are less than the preset side lengths are first determined by synchronously or asynchronously layering the two initial bounding boxes that collide and contain the models to be detected, and the two layered sub-bounding boxes are the areas where collision is most likely to occur, and then the triangular facets of the partial model surfaces of the two models to be detected in the layered sub-bounding boxes are subdivided, and then the vertices of the subdivided triangular facets are used as the center points of the spherical voxels, and the radius of the inscribed circle of the subdivided triangular facets is used as the radius of the spherical voxel to construct a spherical voxel, and finally, the collision detection between the two models to be detected is performed by using whether the spherical voxels intersect. In the above process, only the two models to be detected in the two layered sub-bounding boxes are subjected to collision detection (because the areas enclosed by the two layered sub-bounding boxes are the areas where collision is most likely to occur), and other models to be detected that do not belong to the two layered sub-bounding boxes are not considered, which greatly reduces the models to be detected that perform collision detection. part, that is, the calculation amount of subsequent collision detection is reduced; in addition, when collision detection is performed on two models to be detected in two layered sub-bounding boxes, the triangular faces on the surface of some models in the two layered sub-bounding boxes are subdivided, and based on the subdivided triangular faces, spherical voxels are constructed and the collision detection between the two models to be detected is performed in a manner of whether the spherical voxels intersect. The accuracy is good and the detection precision is high. Compared with the traditional method of performing collision detection between models by whether the triangular faces intersect, the method of the present invention has a small amount of calculation. Compared with the traditional method of directly performing collision detection between models by whether the bounding boxes intersect, the method of the present invention has good accuracy and high precision. That is, the method of the present invention takes into account both the calculation amount and the precision of collision detection, and can perform real-time collision detection on models in large-scale digital twin scenes, alleviating the technical problems of poor detection precision and large amount of calculation in traditional model collision detection methods, and cannot be applied to collision detection in large-scale digital twin scenes. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0058] Figure 1 A flow chart of a model collision detection method provided by an embodiment of the present invention;

[0059] Figure 2 A schematic diagram of synchronizing octree layers with bounding boxes provided by an embodiment of the present invention;

[0060] Figure 3 A schematic diagram of the layering of the bounding box asynchronous octree provided by an embodiment of the present invention;

[0061] Figure 4 A flowchart of another model collision detection provided by an embodiment of the present invention;

[0062] Figure 5 A schematic diagram of a collision detection device for a model provided by an embodiment of the present invention;

[0063] Figure 6 A schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0064] The technical solution of the present invention will be clearly and completely described below in conjunction with the embodiments. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0065] The traditional model collision detection method has technical problems such as poor detection accuracy and large computational complexity, and cannot be applied to collision detection in large-scale digital twin scenarios.

[0066] Based on this, in the collision detection method of the model of the present invention, two layered sub-bounding boxes whose minimum side lengths are both less than the preset side lengths are first determined by synchronously or asynchronously layering the two initial bounding boxes that collide and contain the models to be detected, and the two layered sub-bounding boxes are the areas where collision is most likely to occur, and then the triangular facets of the partial model surfaces of the two models to be detected in the layered sub-bounding boxes are subdivided, and then spherical voxels are constructed with the vertices of the subdivided triangular facets as the center points of the spherical voxels and the radius of the inscribed circle of the subdivided triangular facets as the radius of the spherical voxel, and finally, collision detection is performed between the two models to be detected by determining whether the spherical voxels intersect. In the above process, only the two models to be detected in the two layered sub-bounding boxes are subjected to collision detection (because the areas enclosed by the two layered sub-bounding boxes are the areas where collision is most likely to occur), and the other models to be detected that do not belong to the two layered sub-bounding boxes are subjected to collision detection. The detected model is not taken into consideration, which greatly reduces the part of the model to be detected for collision detection, that is, the amount of calculation for subsequent collision detection is reduced; in addition, when collision detection is performed on two models to be detected in two layered sub-bounding boxes, the triangular faces on the surface of some models in the two layered sub-bounding boxes are subdivided, and based on the subdivided triangular faces, spherical voxels are constructed and the collision detection between the two models to be detected is performed in a manner of whether the spherical voxels intersect. The accuracy is good and the detection precision is high. Compared with the traditional method of performing collision detection between models by whether the triangular faces intersect, the method of the present invention has a small amount of calculation. Compared with the traditional method of directly performing collision detection between models by whether the bounding boxes intersect, the method of the present invention has good accuracy and high precision. That is, the method of the present invention takes into account both the calculation amount and the precision of collision detection, and can perform real-time collision detection on models in large-scale digital twin scenes.

[0067] To facilitate understanding of this embodiment, a collision detection method for a model disclosed in an embodiment of the present invention is first introduced in detail.

[0068] Embodiment 1:

[0069] According to an embodiment of the present invention, an embodiment of a collision detection method for a model is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0070] Figure 1 is a flow chart of a model collision detection method according to an embodiment of the present invention. Figure 1 As shown, the method comprises the following steps:

[0071] Step S102, constructing an initial bounding box for each model to be detected, and determining at least one group of target initial bounding boxes that collide based on the initial bounding boxes, wherein a group of target initial bounding boxes includes two initial bounding boxes;

[0072] In an embodiment of the present invention, the collision detection method of the above-mentioned model can be applied to unity 3D software. For large-scale digital twin scenes (such as a virtual assembly scene of a machine equipment in a digital twin factory), it usually includes multiple models to be detected. An AABB-type initial bounding box is constructed for each model to be detected. In this way, multiple AABB-type initial bounding boxes are obtained. Then, at least one set of target initial bounding boxes that collide are determined by calculating whether any two AABB-type initial bounding boxes intersect.

[0073] Specifically, the initial bounding box is a cuboid. If any two initial bounding boxes intersect, it is determined that the two initial bounding boxes collide, and then the two intersecting initial bounding boxes are taken as a set of target initial bounding boxes.

[0074] Step S104, performing the following collision detection process on the two to-be-detected models in each group of target initial bounding boxes in parallel:

[0075] Calculate the radii of the circumscribed spheres of the two initial bounding boxes in the initial bounding box of the current group of targets respectively;

[0076] Specifically, the collision detection process is introduced by taking a set of target initial bounding boxes as an example:

[0077] After obtaining the initial bounding box of the current group of targets, first calculate the radius of the circumscribed sphere of the two initial bounding boxes, which is essentially the radius of the circumscribed sphere of the two cuboids.

[0078] Perform synchronous or asynchronous octree layering on two initial bounding boxes in the current group target initial bounding boxes according to the ratio of the radii of the circumscribed sphere, and determine the layered sub-bounding boxes retained by each of the two initial bounding boxes according to the angles between the vectors formed by the center points of the two initial bounding boxes and the three coordinate axes, wherein the three coordinate axes are the coordinate axes formed by the center point of the initial bounding box and the center points of three adjacent faces of the initial bounding box that share the same vertex, and the two layered sub-bounding boxes are the areas where collision is most likely to occur;

[0079] Specifically, after calculating the radius of the two circumscribed spheres, the two initial bounding boxes may be further subjected to synchronous or asynchronous octree stratification according to the ratio of the radii of the circumscribed spheres (i.e., the ratio of the radii of the two circumscribed spheres). When the ratio of the radii of the circumscribed spheres is less than a preset threshold (e.g., 1.5, which is not specifically limited in the embodiment of the present invention), the two initial bounding boxes are subjected to synchronous octree stratification. The so-called synchronous octree stratification refers to the simultaneous octree stratification of the two initial bounding boxes (e.g., Figure 2 As shown); when the ratio of the radius of the circumscribed sphere is not less than the preset threshold, the two initial bounding boxes are asynchronously layered by the octree. The so-called asynchronous octree layering means that only the larger initial bounding box of the two initial bounding boxes is layered by the octree, and the other smaller initial bounding box is not layered by the octree (such as Figure 3 As shown), keep the initial bounding box.

[0080] The so-called octree layering means dividing the initial bounding box of the cuboid into eight sub-bounding boxes through the lines connecting the center point of the initial bounding box of the cuboid and the center points of the three adjacent faces of the initial bounding box that share the same vertex, that is, the initial bounding box of a cuboid is layered to obtain 8 layered sub-bounding boxes.

[0081] For the eight layered sub-bounding boxes, it is necessary to determine the one layered sub-bounding box that should be retained by the initial bounding box composed of the eight layered sub-bounding boxes according to the angles between the vectors formed by the center points of the two initial bounding boxes and the three coordinate axes (e.g. Figure 2 and Figure 3 As shown in the figure, the cuboid surrounded by colored lines is the retained layered sub-bounding box), that is, one layered sub-bounding box to be retained is determined from the eight layered sub-bounding boxes. In this way, for the octree layering of the two initial bounding boxes, two layered sub-bounding boxes are finally obtained, and the two layered sub-bounding boxes are the areas where collision is most likely to occur. For asynchronous octree layering, since the smaller initial bounding box does not undergo octree layering, the smaller initial bounding box is directly used as the layered sub-bounding box of the smaller initial bounding box. After the larger initial bounding box undergoes octree layering, the layered sub-bounding box retained by the larger initial bounding box is determined based on the angle between the vector formed by the center points of the two initial bounding boxes and the three coordinate axes, and the layered sub-bounding box of the larger initial bounding box is obtained. In this way, two layered sub-bounding boxes can also be obtained, and the two layered sub-bounding boxes are also the areas where collision is most likely to occur.

[0082] The ratio of the radii of the circumscribed spheres is used to characterize the volume difference between the two initial bounding boxes. If the ratio of the radii of the circumscribed spheres is less than a preset threshold (such as 1.5), it means that the two initial bounding boxes belong to the same volume level, and the two initial bounding boxes are synchronized and hierarchized (such as Figure 2 As shown); if the ratio of the radii of the circumscribed spheres is not less than a preset threshold, it means that the two initial bounding boxes belong to different volume levels, and the two initial bounding boxes are asynchronously hierarched (as shown in Figure 3 as shown).

[0083] Determine whether the minimum side lengths of the two layered sub-bounding boxes are both smaller than the preset side lengths;

[0084] Specifically, after executing the above octree layering to obtain two layered sub-bounding boxes, it is determined whether the minimum side lengths of the two layered sub-bounding boxes are both less than a preset side length, and the preset side length can be set according to the requirements for collision detection accuracy.

[0085] If the minimum side lengths of the two layered sub-bounding boxes are both smaller than the preset side lengths, the octree layering ends, and the final two layered sub-bounding boxes are obtained (the minimum side lengths of the two layered sub-bounding boxes are both smaller than the preset side lengths).

[0086] If they are not both smaller than, the two layered sub-bounding boxes are used as the two initial bounding boxes in the current group target initial bounding box, and the step of respectively calculating the radii of the circumscribed spheres of the two initial bounding boxes in the current group target initial bounding box is returned to execute until the minimum side lengths of the two layered sub-bounding boxes are both smaller than the preset side lengths, and the two layered sub-bounding boxes are obtained;

[0087] Specifically, if they are not both smaller than, the next octree layering is performed on the two layered sub-bounding boxes. Specifically, the two layered sub-bounding boxes are used as the two initial bounding boxes in the current group target initial bounding box, and the steps of respectively calculating the radius of the circumscribed spheres of the two initial bounding boxes in the current group target initial bounding box are returned to execute until the minimum side lengths of the two layered sub-bounding boxes are both smaller than the preset side lengths, and two layered sub-bounding boxes are obtained (the minimum side lengths of the two layered sub-bounding boxes are both smaller than the preset side lengths).

[0088] Subdividing the triangular facets of the partial model surfaces of the two models to be detected in the two layered sub-bounding boxes, and constructing a spherical voxel with the vertices of the subdivided triangular facets as the center points of the spherical voxels and the radius of the inscribed circle of the subdivided triangular facets as the radius of the spherical voxel;

[0089] Specifically, since the above two layered sub-bounding boxes are the most likely areas for collision, when performing collision detection later, only the two parts of the models to be detected in the two layered sub-bounding boxes are subjected to collision detection (other parts are not considered), that is, only the partial model surfaces belonging to the two layered sub-bounding boxes are subjected to collision detection. When only the partial model surfaces belonging to the two layered sub-bounding boxes are subjected to collision detection, if the method of whether the triangular facets of the partial model surfaces intersect is still used to implement the collision detection, the amount of calculation is large, so the inventors designed a collision detection scheme for spherical voxels.

[0090] During implementation, the triangular patches on the surface of the partial model are subdivided, and the vertices of the subdivided triangular patches are used as the center points of the spherical voxels. The radius of the inscribed circle of the subdivided triangular patches is used as the radius of the spherical voxel to construct a spherical voxel, thereby realizing a spherical voxelized representation of the partial model surface. In other words, the partial model surface is represented by spherical voxels (instead of triangular patches). In this way, the process of collision detection on the partial model surface can be converted into the process of collision detection on spherical voxels, because the process of collision detection of spherical voxels is simple (it can be achieved by comparing the distance between the centers of the spheres with the sum of the radii of the two spheres) and the amount of calculation is small.

[0091] Whether the two models to be detected collide is determined by whether the spherical voxels intersect.

[0092] Specifically, whether the spherical voxels intersect refers to whether the spherical voxels on a partial model surface of one to-be-detected model intersect with the spherical voxels on a partial model surface of another to-be-detected model.

[0093] In an embodiment of the present invention, a model collision detection method is provided, comprising: constructing an initial bounding box for each model to be detected, and determining at least one group of target initial bounding boxes that collide based on the initial bounding boxes, wherein a group of target initial bounding boxes includes two initial bounding boxes; performing the following collision detection process on the two models to be detected in each group of target initial bounding boxes in parallel: calculating the radii of the circumscribed spheres of the two initial bounding boxes in the current group of target initial bounding boxes, respectively; performing synchronous or asynchronous octree layering on the two initial bounding boxes in the current group of target initial bounding boxes based on the ratio of the radii of the circumscribed spheres, and determining the layered sub-bounding boxes retained by each of the two initial bounding boxes based on the angles between the center points of the two initial bounding boxes and the three coordinate axes, wherein the three coordinate axes are the angles between the center points of the initial bounding boxes and the three axes that share the same vertex of the initial bounding boxes. The coordinate axis is formed by the center points of adjacent faces; whether the minimum side lengths of the two layered sub-bounding boxes are both less than the preset side lengths; if not, the two layered sub-bounding boxes are used as the two initial bounding boxes in the current group target initial bounding box, and the steps of respectively calculating the radii of the circumscribed spheres of the two initial bounding boxes in the current group target initial bounding box are returned to execute, until the minimum side lengths of the two layered sub-bounding boxes are both less than the preset side lengths, and the two layered sub-bounding boxes are obtained; the triangular facets of the partial model surfaces of the two models to be detected in the two layered sub-bounding boxes are subdivided, and the vertices of the subdivided triangular facets are used as the center points of the spherical voxels, and the radius of the inscribed circle of the subdivided triangular facets is used as the radius of the spherical voxel to construct a spherical voxel; whether the two models to be detected collide with each other is determined by whether the spherical voxels intersect.From the above description, it can be known that in the collision detection method of the model of the present invention, two layered sub-bounding boxes whose minimum side lengths are less than the preset side lengths are first determined by synchronously or asynchronously layering the two initial bounding boxes that collide and contain the models to be detected, and the two layered sub-bounding boxes are the areas where collision is most likely to occur, and then the triangular facets of the partial model surfaces of the two models to be detected in the layered sub-bounding boxes are subdivided, and then the vertices of the subdivided triangular facets are used as the center points of the spherical voxels, and the radius of the inscribed circle of the subdivided triangular facets is used as the radius of the spherical voxel to construct a spherical voxel, and finally, the collision detection between the two models to be detected is performed by using whether the spherical voxels intersect. In the above process, only the two models to be detected in the two layered sub-bounding boxes are subjected to collision detection (because the areas enclosed by the two layered sub-bounding boxes are the areas where collision is most likely to occur), and other models to be detected that do not belong to the two layered sub-bounding boxes are not considered, which greatly reduces the models to be detected that perform collision detection. part, that is, the calculation amount of subsequent collision detection is reduced; in addition, when collision detection is performed on two models to be detected in two layered sub-bounding boxes, the triangular faces on the surface of some models in the two layered sub-bounding boxes are subdivided, and based on the subdivided triangular faces, spherical voxels are constructed and the collision detection between the two models to be detected is performed in a manner of whether the spherical voxels intersect. The accuracy is good and the detection precision is high. Compared with the traditional method of performing collision detection between models by whether the triangular faces intersect, the method of the present invention has a small amount of calculation. Compared with the traditional method of directly performing collision detection between models by whether the bounding boxes intersect, the method of the present invention has good accuracy and high precision. That is, the method of the present invention takes into account both the calculation amount and the precision of collision detection, and can perform real-time collision detection on models in large-scale digital twin scenes, alleviating the technical problems of poor detection precision and large amount of calculation in traditional model collision detection methods, and cannot be applied to collision detection in large-scale digital twin scenes.

[0094] The above content briefly introduces the collision detection method of the model of the present invention, and the specific contents involved are described in detail below.

[0095] In an optional embodiment of the present invention, two initial bounding boxes in the current group of target initial bounding boxes are synchronously or asynchronously layered using an octree according to the ratio of the radii of the circumscribed spheres, and the layered sub-bounding boxes retained by the two initial bounding boxes are determined according to the angles between the vectors formed by the center points of the two initial bounding boxes and the three coordinate axes, specifically comprising the following steps:

[0096] (1) Determine whether the ratio of the radius of the circumscribed sphere is less than a preset threshold;

[0097] (2) If it is less than the preset threshold, the two initial bounding boxes in the current group of target initial bounding boxes are simultaneously layered by octree, and the layered sub-bounding boxes retained by each of the two initial bounding boxes are determined according to the angles between the vectors formed by the center points of the two initial bounding boxes and the three coordinate axes;

[0098] Specifically, Figure 2 As shown, the vector formed by the center points of the two initial bounding boxes is Figure 2 The blue dotted line in the figure has angles α, β and γ with the three coordinate axes below, α is greater than 90 degrees, β and γ are less than 90 degrees, and the corresponding determined retained sub-bounding box after layering is Figure 2 The cuboid surrounded by the red line in the figure is not explained one by one here. In essence, the layered sub-bounding box to be retained is determined based on the relationship between the angle between the vector formed by the center points of the two initial bounding boxes and the three coordinate axes and 90 degrees. In actual implementation, the correspondence between the three angles and the layered sub-bounding boxes to be retained is set, and the retained layered sub-bounding boxes can be determined based on the correspondence.

[0099] (3) If it is not less than the preset threshold, the larger initial bounding box in the initial bounding box of the current group of targets is layered using an octree, and the layered sub-bounding box retained by the larger initial bounding box is determined based on the angle between the vector formed by the center points of the two initial bounding boxes and the three coordinate axes, so as to obtain the layered sub-bounding box of the larger initial bounding box, and the smaller initial bounding box is used as the layered sub-bounding box of the smaller initial bounding box.

[0100] Specifically, Figure 3 As shown, only the larger initial bounding box is layered by the octree, and the layered sub-bounding box retained by the larger initial bounding box is determined according to the angle between the vector formed by the center points of the two initial bounding boxes and the three coordinate axes ( Figure 3 The process of determining the rectangle surrounded by the red line in the figure is similar to the above process and will not be repeated here).

[0101] In an optional embodiment of the present invention, subdividing the triangular facets of the partial model surfaces of the two to-be-detected models in the two layered sub-bounding boxes specifically includes the following steps:

[0102] (1) Calculate the length of each edge of the triangular patch on the partial model surface of the two models to be tested;

[0103] Specifically, in the software, various information of all the triangular facets constituting the model to be detected is recorded, including the vertex information of the triangular facets. In this way, the length of each side of the triangular facet can be calculated based on the vertex information.

[0104] (2) Determine whether the length of each edge of the same triangle is less than a preset edge length threshold;

[0105] (3) If the length of each edge of the same triangle is less than the preset edge length threshold, the triangle is not subdivided and the triangle is directly used as the subdivided triangle;

[0106] (4) If they are not all smaller than , calculate the tangent points between the inscribed circle of the triangle and each edge of the triangle;

[0107] Specifically, the number of tangent points between the inscribed circle of the triangular face and each edge of the triangular face is 3.

[0108] (5) Connect the tangent points to subdivide the triangular face to obtain the triangular face after the first subdivision;

[0109] Specifically, the three tangent points are connected to subdivide the triangular face into four first subdivided triangular facets.

[0110] After the subdivision is completed, the attribute information of the vertices and the attribute information of the triangles are updated according to the triangles after the first subdivision, wherein the attribute information of the vertices includes: vertex array, triangle composition array, vertex normal, vertex texture coordinates and vertex tangent array, and the attribute information of the triangles includes: face normal vector and vertex color of the triangles.

[0111] Specifically, the vertices of the first subdivided triangles are inserted into the vertex array and the triangle composition array in sequence, and the storage information of the original triangles is deleted in the vertex array and the triangle composition array, and the vertex normals, vertex texture coordinates and vertex tangent arrays of the model are updated.

[0112] (6) Determine whether the length of each edge of the same first subdivided triangle is less than a preset edge length threshold;

[0113] (7) If they are not all less than, the first subdivided triangle patch is taken as the triangle patch, and the step of calculating the tangent points of the incircle of the triangle patch and each edge of the triangle patch is returned to execute until the length of each edge of the same first subdivided triangle patch is less than the preset edge length threshold, and the first subdivided triangle patch finally obtained is taken as the subdivided triangle patch;

[0114] (8) If the length of each edge of the same first subdivided triangle is less than the preset edge length threshold, the first subdivided triangle is used as the subdivided triangle.

[0115] In an optional embodiment of the present invention, the spherical voxel is constructed by taking the vertex of the subdivided triangular facet as the center point of the spherical voxel and taking the radius of the inscribed circle of the subdivided triangular facet as the radius of the spherical voxel, which specifically includes the following steps:

[0116] (1) De-duplicate the vertices in the vertex array to obtain a de-duplicated vertex array;

[0117] Specifically, since the face normals, vertex colors and other attributes corresponding to different triangles may be different, in order to accurately calculate the attribute information of the triangles, it is necessary to repeatedly store the data of certain vertices in the vertex array. However, these repeated vertices are unnecessary for the voxelization process of some model surfaces. Therefore, it is necessary to deduplicate the vertices in the vertex array.

[0118] (2) The spherical voxel is constructed by taking the vertex in the deduplicated vertex array as the center point of the spherical voxel and taking the radius of the inscribed circle of the subdivided triangle facet corresponding to the vertex as the radius of the spherical voxel.

[0119] Specifically, the vertices in the deduplicated vertex array are taken as the center points of the spherical voxels. After obtaining the vertices in the deduplicated vertex array, the first subdivided triangle face composed of the vertices is determined in the triangle constituting array, and then the spherical voxel is constructed with the radius of the inscribed circle of the subdivided triangle face as the radius.

[0120] In an optional embodiment of the present invention, whether a collision occurs between two to-be-detected models is determined by determining whether spherical voxels intersect, which specifically includes the following steps:

[0121] (1) If the spherical voxels intersect, a collision occurs between the two models to be detected, and a collision response is performed.

[0122] (2) If the spherical voxels do not intersect, there is no collision between the two models to be detected.

[0123] In an optional embodiment of the present invention, the method further comprises the following steps:

[0124] (1) During the next collision detection, determine whether the two layered sub-bounding boxes of the center points of the two spherical voxels that intersected during the previous collision detection collide with each other;

[0125] Specifically, whether the layered sub-bounding boxes collide is determined by determining whether the layered sub-bounding boxes intersect.

[0126] (2) If a collision occurs, determine the index values ​​of the center points of the two intersecting spherical voxels in the deduplicated vertex array;

[0127] Specifically, the index value is express, , is the length of the vertex array after deduplication (that is, the total number of vertices in the vertex array after deduplication). There should be two center points of the two intersecting spherical voxels, so the index value is also 2, corresponding to the index values ​​of the vertices in the two models to be detected.

[0128] (3) Determine a first spherical voxel to be detected in one model to be detected and a second spherical voxel to be detected in another model to be detected based on the index value, wherein the index value of the center point of the first spherical voxel to be detected and the second spherical voxel to be detected is Spherical voxels within the range, Represents the index value of the center point of the two intersecting spherical voxels in the deduplicated vertex array. Indicates the preset value;

[0129] Specifically, if , then let , similarly, if , then let .

[0130] (4) performing collision detection on the first spherical voxel to be detected and the second spherical voxel to be detected;

[0131] To facilitate understanding, the following example illustrates the process:

[0132] Assume that there are 10 vertices in the deduplicated vertex array of one model to be detected (i.e. n=10), and there are 15 vertices in the deduplicated vertex array of another model to be detected (i.e. n=15). The index values ​​of the center points of the two spherical voxels that intersected in the last collision detection are 4 (corresponding to one model to be detected) and 6 (corresponding to another model to be detected) in the deduplicated vertex array, and m=2. Then, in the next collision detection, collision detection will be performed preferentially on the first spherical voxel to be detected whose center point has an index value of i-1~i+1=4-1~4+1=3~5 and the second spherical voxel to be detected whose center point has an index value of i-1~i+1=6-1~6+1=5~7.

[0133] If a collision is detected, a collision response is performed.

[0134] (5) If it is detected that the first spherical voxel to be detected and the second spherical voxel to be detected do not collide, a third spherical voxel to be detected in one model to be detected and a fourth spherical voxel to be detected in another model to be detected are determined based on the index value, wherein the index value of the third spherical voxel to be detected and the fourth spherical voxel to be detected as the center point is and Spherical voxels within the range, Represents the index value of the center point of the two intersecting spherical voxels in the deduplicated vertex array. Indicates the preset value;

[0135] Specifically, if , then let , similarly, if , then let .

[0136] (6) performing collision detection on the first spherical voxel to be detected and the fourth spherical voxel to be detected, the second spherical voxel to be detected and the third spherical voxel to be detected, and the third spherical voxel to be detected and the fourth spherical voxel to be detected;

[0137] Continuing with the above example:

[0138] If the first spherical voxel to be detected with a center point index value of 3 to 5 and the second spherical voxel to be detected with a center point index value of 5 to 7 do not collide, then the index value of the center point is determined to be =0~i-1-1=0~4-1-1=0~2, =i+1+1~10=4+1+1~10=6~10 The index value of the third spherical voxel and the center point to be detected is =0~i-1-1=0~6-1-1=0~4, =i+1+1~15=6+1+1~15=8~15, the fourth spherical voxel to be detected.

[0139] Furthermore, collision detection is performed on the first spherical voxel to be detected and the fourth spherical voxel to be detected, collision detection is performed on the second spherical voxel to be detected and the third spherical voxel to be detected, and collision detection is performed on the third spherical voxel to be detected and the fourth spherical voxel to be detected.

[0140] If a collision is detected, a collision response is performed.

[0141] (7) If it is detected that the first spherical voxel to be detected and the fourth spherical voxel to be detected, the second spherical voxel to be detected and the third spherical voxel to be detected, and the third spherical voxel to be detected and the fourth spherical voxel to be detected do not collide, it is determined that the two models to be detected do not collide.

[0142] In an optional embodiment of the present invention, the method further comprises the following steps:

[0143] (1) If there are no two intersecting spherical voxels in the last collision detection, return to the step of determining at least one set of target initial bounding boxes that collide based on the initial bounding box;

[0144] Specifically, the two spherical voxels that did not intersect in the last collision detection, that is, the last collision detection, detected that the two models to be detected did not collide. Then, in the next collision detection, the step of determining at least one set of target initial bounding boxes that collided based on the initial bounding box is returned to execute, and the subsequent collision detection processes are executed in sequence.

[0145] (2) If the two layered sub-bounding boxes where the center points of the two intersecting spherical voxels are located do not collide during the last collision detection, then the two layered sub-bounding boxes are restored one layer upward to obtain two new layered sub-bounding boxes;

[0146] Specifically, Figure 2 As shown, when the next collision detection is performed, if the two layered sub-bounding boxes (i.e. Figure 2 The cuboid enclosed by the red and green lines in the figure) does not collide, then the two layered sub-bounding boxes are restored one layer upward to obtain two layered new sub-bounding boxes (i.e. Figure 2 The two rectangles enclosed by the black line).

[0147] (3) The two layered new sub-bounding boxes are used as the two initial bounding boxes in the current group target initial bounding box, and the step of calculating the radius of the circumscribed spheres of the two initial bounding boxes in the current group target initial bounding box is returned.

[0148] Figure 4 The specific process of collision detection of the model of the present invention is shown in Figure 4 The flowchart in will not be repeated here.

[0149] In the collision detection method of the model of the present invention, the ratio of the radius of the circumscribed sphere of the initial bounding box is calculated to determine whether the two models to be detected are at the same level to perform the octree stratification of the initial bounding box, thereby reducing the number of unnecessary stratification times (if they are not at the same level, only the larger initial bounding box is stratified by the octree), thereby reducing the calculation amount of collision detection; in addition, by constructing spherical voxels at the vertex positions of the triangular facets on the surface of part of the model to replace the model for collision detection, it can be ensured that the constructed spherical voxels are all valid voxels, and there is no need to remove invalid voxels, thereby increasing the accuracy of collision detection while ensuring the calculation amount of collision detection. After a collision occurs, the model to be detected may move away from the collision area after the next movement, or may continue to collide near the area. Because the movement process of the model to be detected is continuous, the position where the collision occurs next time will not be greatly offset. If all the voxels of the two models to be detected are traversed again to determine whether a collision occurs, the calculation cost is relatively large. Therefore, the present invention predicts the position of the spherical voxel where the collision may occur next time by the position of the spherical voxel where the collision currently occurs, thereby reducing the calculation amount of collision detection during the operation of the system.

[0150] Embodiment 2:

[0151] An embodiment of the present invention further provides a model collision detection device, which is mainly used to execute the model collision detection method provided in the first embodiment of the present invention. The model collision detection device provided in the embodiment of the present invention is specifically introduced below.

[0152] Figure 5 is a schematic diagram of a collision detection device of a model according to an embodiment of the present invention, such as Figure 5 As shown, the device mainly includes: a construction and determination unit 10 and a collision detection unit 20, wherein:

[0153] A construction and determination unit, used to construct an initial bounding box for each model to be detected, and determine at least one group of target initial bounding boxes that collide according to the initial bounding boxes, wherein a group of target initial bounding boxes includes two initial bounding boxes;

[0154] The collision detection unit is used to perform the following collision detection process on the two to-be-detected models in each group of target initial bounding boxes in parallel:

[0155] Calculate the radii of the circumscribed spheres of the two initial bounding boxes in the initial bounding box of the current group of targets respectively;

[0156] Perform synchronous or asynchronous octree layering on two initial bounding boxes in the current group target initial bounding boxes according to the ratio of the radii of the circumscribed sphere, and determine the layered sub-bounding boxes retained by each of the two initial bounding boxes according to the angles between the vectors formed by the center points of the two initial bounding boxes and the three coordinate axes, wherein the three coordinate axes are the coordinate axes formed by the center point of the initial bounding box and the center points of three adjacent faces of the initial bounding box that share the same vertex, and the two layered sub-bounding boxes are the areas where collision is most likely to occur;

[0157] Determine whether the minimum side lengths of the two layered sub-bounding boxes are both smaller than the preset side lengths;

[0158] If they are not both smaller than, the two layered sub-bounding boxes are used as the two initial bounding boxes in the current group target initial bounding box, and the step of respectively calculating the radii of the circumscribed spheres of the two initial bounding boxes in the current group target initial bounding box is returned to execute until the minimum side lengths of the two layered sub-bounding boxes are both smaller than the preset side lengths, and the two layered sub-bounding boxes are obtained;

[0159] Subdividing the triangular facets of the partial model surfaces of the two models to be detected in the two layered sub-bounding boxes, and constructing a spherical voxel with the vertices of the subdivided triangular facets as the center points of the spherical voxels and the radius of the inscribed circle of the subdivided triangular facets as the radius of the spherical voxel;

[0160] Whether the two models to be detected collide is determined by whether the spherical voxels intersect.

[0161] In an embodiment of the present invention, a collision detection device for a model is provided, comprising: constructing an initial bounding box for each model to be detected, and determining at least one group of target initial bounding boxes that collide based on the initial bounding boxes, wherein a group of target initial bounding boxes includes two initial bounding boxes; performing the following collision detection process on the two models to be detected in each group of target initial bounding boxes in parallel: calculating the radii of the circumscribed spheres of the two initial bounding boxes in the current group of target initial bounding boxes, respectively; performing synchronous or asynchronous octree layering on the two initial bounding boxes in the current group of target initial bounding boxes based on the ratio of the radii of the circumscribed sphere, and determining the layered sub-bounding boxes retained by each of the two initial bounding boxes based on the angles between the vectors formed by the center points of the two initial bounding boxes and the three coordinate axes, wherein the three coordinate axes are the angles between the center points of the initial bounding boxes and the three axes that share the same vertex of the initial bounding boxes. The coordinate axis is formed by the center points of adjacent faces; whether the minimum side lengths of the two layered sub-bounding boxes are both less than the preset side lengths; if not, the two layered sub-bounding boxes are used as the two initial bounding boxes in the current group target initial bounding box, and the steps of respectively calculating the radii of the circumscribed spheres of the two initial bounding boxes in the current group target initial bounding box are returned to execute, until the minimum side lengths of the two layered sub-bounding boxes are both less than the preset side lengths, and the two layered sub-bounding boxes are obtained; the triangular facets of the partial model surfaces of the two models to be detected in the two layered sub-bounding boxes are subdivided, and the vertices of the subdivided triangular facets are used as the center points of the spherical voxels, and the radius of the inscribed circle of the subdivided triangular facets is used as the radius of the spherical voxel to construct a spherical voxel; whether the two models to be detected collide with each other is determined by whether the spherical voxels intersect.From the above description, it can be known that in the collision detection device of the model of the present invention, two layered sub-bounding boxes whose minimum side lengths are less than the preset side lengths are first determined by synchronously or asynchronously layering the two initial bounding boxes that collide and contain the models to be detected, and the two layered sub-bounding boxes are the areas where collision is most likely to occur, and then the triangular facets of the partial model surfaces of the two models to be detected in the layered sub-bounding boxes are subdivided, and then the vertices of the subdivided triangular facets are used as the center points of the spherical voxels, and the radius of the inscribed circle of the subdivided triangular facets is used as the radius of the spherical voxel to construct a spherical voxel, and finally, the collision detection between the two models to be detected is performed by using whether the spherical voxels intersect. In the above process, only the two models to be detected in the two layered sub-bounding boxes are subjected to collision detection (because the areas enclosed by the two layered sub-bounding boxes are the areas where collision is most likely to occur), and other models to be detected that do not belong to the two layered sub-bounding boxes are not considered, which greatly reduces the models to be detected that perform collision detection. part, that is, the calculation amount of subsequent collision detection is reduced; in addition, when collision detection is performed on two models to be detected in two layered sub-bounding boxes, the triangular faces on the surface of some models in the two layered sub-bounding boxes are subdivided, and based on the subdivided triangular faces, spherical voxels are constructed and the collision detection between the two models to be detected is performed in a manner of whether the spherical voxels intersect. The accuracy is good and the detection precision is high. Compared with the traditional method of performing collision detection between models by whether the triangular faces intersect, the method of the present invention has a small amount of calculation. Compared with the traditional method of directly performing collision detection between models by whether the bounding boxes intersect, the method of the present invention has good accuracy and high precision. That is, the method of the present invention takes into account both the calculation amount and the precision of collision detection, and can perform real-time collision detection on models in large-scale digital twin scenes, alleviating the technical problems of poor detection precision and large amount of calculation in traditional model collision detection methods, and cannot be applied to collision detection in large-scale digital twin scenes.

[0162] Optionally, the collision detection unit is also used to: determine whether the ratio of the radii of the circumscribed sphere is less than a preset threshold; if it is less than the preset threshold, octree layering is performed on the two initial bounding boxes in the current group target initial bounding boxes at the same time, and the layered sub-bounding boxes retained by each of the two initial bounding boxes are determined according to the angle between the vector formed by the center points of the two initial bounding boxes and the three coordinate axes; if it is not less than the preset threshold, octree layering is performed on the larger initial bounding box in the current group target initial bounding boxes, and the layered sub-bounding box retained by the larger initial bounding box is determined according to the angle between the vector formed by the center points of the two initial bounding boxes and the three coordinate axes, so as to obtain the layered sub-bounding box of the larger initial bounding box, and use the smaller initial bounding box as the layered sub-bounding box of the smaller initial bounding box.

[0163] Optionally, the collision detection unit is also used to: calculate the length of each side of the triangular facets on the partial model surfaces of the two models to be detected; determine whether the length of each side of the same triangular facet is less than a preset edge length threshold; if not, calculate the tangent points of the inscribed circle of the triangular facet and each edge of the triangular facet; connect the tangent points to subdivide the triangular facet to obtain the first subdivided triangular facet; determine whether the length of each side of the same first subdivided triangular facet is less than a preset edge length threshold; if not, take the first subdivided triangular facet as the triangular facet, and return to execute the step of calculating the tangent points of the inscribed circle of the triangular facet and each edge of the triangular facet, until the length of each side of the same first subdivided triangular facet is less than the preset edge length threshold, and take the finally obtained first subdivided triangular facet as the subdivided triangular facet.

[0164] Optionally, the collision detection unit is also used to: if the length of each edge of the same triangular facet is less than a preset edge length threshold, then the triangular facet is used as a subdivided triangular facet; if the length of each edge of the same first subdivided triangular facet is less than a preset edge length threshold, then the first subdivided triangular facet is used as a subdivided triangular facet.

[0165] Optionally, the collision detection unit is also used to: after each subdivision, update the attribute information of the vertices and the attribute information of the triangles according to the triangles after the first subdivision, wherein the attribute information of the vertices includes: vertex array, triangle composition array, vertex normal, vertex texture coordinates and vertex tangent array, and the attribute information of the triangles includes: face normal vector and vertex color of the triangles.

[0166] Optionally, the collision detection unit is also used to: deduplicate vertices in the vertex array to obtain a deduplicated vertex array; construct a spherical voxel using the vertices in the deduplicated vertex array as the center points of the spherical voxel and using the radius of the inscribed circle of the subdivided triangle facet corresponding to the vertex as the radius of the spherical voxel.

[0167] Optionally, the collision detection unit is further configured to: if the spherical voxels intersect, a collision occurs between the two models to be detected.

[0168] Optionally, the collision detection unit is further used to: during the next collision detection, determine whether two layered sub-bounding boxes where the center points of two intersecting spherical voxels during the previous collision detection are located collide; if a collision occurs, determine the index value of the center point of the two intersecting spherical voxels in the deduplicated vertex array; based on the index value, determine a first spherical voxel to be detected in a model to be detected and a second spherical voxel to be detected in another model to be detected, wherein the index values ​​of the center points of the first spherical voxel to be detected and the second spherical voxel to be detected are in Spherical voxels within the range, Represents the index value of the center point of the two intersecting spherical voxels in the deduplicated vertex array. represents a preset value; performing collision detection on the first spherical voxel to be detected and the second spherical voxel to be detected; if it is detected that the first spherical voxel to be detected and the second spherical voxel to be detected do not collide, then determining the third spherical voxel to be detected in one model to be detected and the fourth spherical voxel to be detected in another model to be detected based on the index value, wherein the index value of the third spherical voxel to be detected and the fourth spherical voxel to be detected as the center point is and Spherical voxels within the range, Represents the index value of the center point of the two intersecting spherical voxels in the deduplicated vertex array. Represents a preset value; collision detection is performed on the first spherical voxel to be detected and the fourth spherical voxel to be detected, the second spherical voxel to be detected and the third spherical voxel to be detected, and the third spherical voxel to be detected and the fourth spherical voxel to be detected; if it is detected that the first spherical voxel to be detected and the fourth spherical voxel to be detected, the second spherical voxel to be detected and the third spherical voxel to be detected, and the third spherical voxel to be detected and the fourth spherical voxel to be detected do not collide, it is determined that the two models to be detected do not collide.

[0169] Optionally, the collision detection unit is also used to: if there are no intersecting spherical voxels in the last collision detection, then return to execute the step of determining at least one group of target initial bounding boxes that collided based on the initial bounding box; if the two layered sub-bounding boxes where the center points of the two intersecting spherical voxels are located do not collide in the last collision detection, then restore the two layered sub-bounding boxes one layer upward to obtain two layered new sub-bounding boxes; use the two layered new sub-bounding boxes as the two initial bounding boxes in the current group of target initial bounding boxes, and return to execute the step of respectively calculating the radii of the circumscribed spheres of the two initial bounding boxes in the current group of target initial bounding boxes.

[0170] The device provided in the embodiment of the present invention has the same implementation principle and technical effects as those of the aforementioned method embodiment. For the sake of brief description, for matters not mentioned in the device embodiment, reference may be made to the corresponding contents in the aforementioned method embodiment.

[0171] like Figure 6 As shown, an electronic device 600 provided in an embodiment of the present application includes: a processor 601, a memory 602 and a bus, wherein the memory 602 stores machine-readable instructions executable by the processor 601. When the electronic device is running, the processor 601 communicates with the memory 602 through the bus, and the processor 601 executes the machine-readable instructions to perform the steps of the collision detection method as in the above-mentioned model.

[0172] Specifically, the memory 602 and the processor 601 can be general-purpose memories and processors, which are not specifically limited here. When the processor 601 runs the computer program stored in the memory 602, the collision detection method of the above model can be executed.

[0173] The processor 601 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 601. The above processor 601 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module may be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 602, and the processor 601 reads the information in the memory 602 and completes the steps of the above method in combination with its hardware.

[0174] Corresponding to the collision detection method of the above-mentioned model, an embodiment of the present application also provides a computer-readable storage medium, which stores machine-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to execute the steps of the collision detection method of the above-mentioned model.

[0175] The collision detection device of the model provided in the embodiment of the present application can be specific hardware on the device or software or firmware installed on the device. The device provided in the embodiment of the present application, its implementation principle and the technical effect produced are the same as those in the aforementioned method embodiment. For the sake of brief description, the parts not mentioned in the device embodiment can refer to the corresponding contents in the aforementioned method embodiment. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, devices and units described above can all refer to the corresponding processes in the aforementioned method embodiment, and will not be repeated here.

[0176] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0177] For another example, the flowchart and block diagram in the accompanying drawings show the possible architecture, function and operation of the device, method and computer program product according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of the boxes in the block diagram and / or the flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0178] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0179] In addition, each functional unit in the embodiments provided in the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0180] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions for enabling an electronic device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the collision detection method of the model described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, and other media that can store program codes.

[0181] It should be noted that similar numbers and letters represent similar items in the following figures. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. In addition, the terms "first", "second", "third", etc. are only used to distinguish the description and are not to be understood as indicating or implying relative importance.

[0182] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solution of the present application, rather than to limit it. The protection scope of the present application is not limited thereto. Although the present application is described in detail with reference to the aforementioned embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solution recorded in the aforementioned embodiments within the technical scope disclosed in the present application, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solution deviate from the scope of the technical solution of the embodiment of the present application. They should all be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.

Claims

1. A collision detection method for a model, characterized in that: include: Constructing an initial bounding box for each model to be detected respectively, and determining at least one group of target initial bounding boxes that collide based on the initial bounding boxes, wherein a group of target initial bounding boxes includes two initial bounding boxes, and the model to be detected is a virtual model in the digital twin system; The following collision detection process is performed in parallel on the two models to be detected in each group of the target initial bounding box: Calculate the radii of the circumscribed spheres of two of the target initial bounding boxes in the current group respectively; Performing synchronous or asynchronous octree layering on two of the target initial bounding boxes in the current group according to the ratio of the radii of the circumscribed sphere, and determining the layered sub-bounding boxes retained by each of the two initial bounding boxes according to the angles between the vectors formed by the center points of the two initial bounding boxes and the three coordinate axes, wherein the three coordinate axes are the coordinate axes formed by the center point of the initial bounding box and the center points of three adjacent faces of the initial bounding box that share the same vertex, and the two layered sub-bounding boxes are the areas where collision is most likely to occur; Determine whether the minimum side lengths of the two layered sub-bounding boxes are both smaller than a preset side length; If they are not both smaller than, the two layered sub-bounding boxes are used as the two initial bounding boxes in the target initial bounding box of the current group, and the step of respectively calculating the radii of the circumscribed spheres of the two initial bounding boxes in the target initial bounding box of the current group is returned to, until the minimum side lengths of the two layered sub-bounding boxes are both smaller than the preset side length, thereby obtaining the two layered sub-bounding boxes; Subdividing the triangular facets of the partial model surfaces of the two models to be detected in the two layered sub-bounding boxes, and constructing a spherical voxel with the vertices of the subdivided triangular facets as the center points of the spherical voxels and the radius of the inscribed circle of the subdivided triangular facets as the radius of the spherical voxel; Whether a collision occurs between the two models to be detected is determined by determining whether the spherical voxels intersect.

2. The method according to claim 1, characterized in that According to the ratio of the radii of the circumscribed sphere, two of the target initial bounding boxes in the current group are synchronously or asynchronously octree layered, and according to the angles between the vectors formed by the center points of the two initial bounding boxes and the three coordinate axes, the layered sub-bounding boxes retained by each of the two initial bounding boxes are determined, including: Determining whether the ratio of the radius of the circumscribed sphere is less than a preset threshold; If it is less than the preset threshold, the two initial bounding boxes in the current group of the target initial bounding boxes are simultaneously octree layered, and the layered sub-bounding boxes retained by each of the two initial bounding boxes are determined according to the angles between the vectors formed by the center points of the two initial bounding boxes and the three coordinate axes; If it is not less than the preset threshold, the larger initial bounding box in the target initial bounding box of the current group is layered by octree, and the layered sub-bounding box retained by the larger initial bounding box is determined according to the angle between the vector formed by the center points of the two initial bounding boxes and the three coordinate axes, so as to obtain the layered sub-bounding box of the larger initial bounding box, and the smaller initial bounding box is used as the layered sub-bounding box of the smaller initial bounding box.

3. The method according to claim 1, characterized in that: Subdividing the triangular facets of the partial model surfaces of the two models to be detected in the two layered sub-bounding boxes, comprising: Calculating the length of each side of the triangular facets on the partial model surfaces of the two models to be detected; Determine whether the length of each side of the same triangular face is less than a preset edge length threshold; If they are not all smaller than , then calculate the tangent points between the inscribed circle of the triangular patch and each edge of the triangular patch; Connect the tangent points to subdivide the triangular face to obtain a first subdivided triangular face; Determine whether the length of each side of the same first subdivided triangular face is less than the preset edge length threshold; If they are not all less than, then the first subdivided triangle patch is used as the triangle patch, and the step of calculating the tangent points of the inscribed circle of the triangle patch and each edge of the triangle patch is returned to execute, until the length of each edge of the same first subdivided triangle patch is less than the preset edge length threshold, and the first subdivided triangle patch finally obtained is used as the subdivided triangle patch.

4. The method according to claim 3, characterized in that The method further comprises: If the length of each side of the same triangular face is less than the preset edge length threshold, the triangular face is used as the subdivided triangular face; If the length of each side of the same first-subdivided triangular facet is less than the preset side length threshold, the first-subdivided triangular facet is used as the subdivided triangular facet.

5. The method according to claim 3, characterized in that: The method further comprises: After each subdivision, the attribute information of the vertices and the attribute information of the triangles are updated according to the first subdivided triangles, wherein the attribute information of the vertices includes: vertex array, triangle composition array, vertex normal, vertex texture coordinates and vertex tangent array, and the attribute information of the triangles includes: face normal vector and vertex color of the triangles.

6. The method according to claim 5, characterized in that The spherical voxel is constructed by taking the vertex of the subdivided triangular facet as the center point of the spherical voxel and taking the radius of the inscribed circle of the subdivided triangular facet as the radius of the spherical voxel, including: Deduplicating vertices in the vertex array to obtain a deduplicated vertex array; The spherical voxel is constructed by taking the vertex in the deduplicated vertex array as the center point of the spherical voxel and taking the radius of the inscribed circle of the subdivided triangular facet corresponding to the vertex as the radius of the spherical voxel.

7. The method according to claim 1, characterized in that Determining whether a collision occurs between the two models to be detected by determining whether the spherical voxels intersect, includes: If the spherical voxels intersect, a collision occurs between the two models to be detected.

8. The method according to claim 7, characterized in that The method further comprises: During the next collision detection, it is determined whether two of the layered sub-bounding boxes where the center points of the two spherical voxels intersecting during the previous collision detection are located collide with each other; If a collision occurs, determining the index values ​​of the center points of the two intersecting spherical voxels in the deduplicated vertex array; Based on the index value, a first spherical voxel to be detected in one of the models to be detected and a second spherical voxel to be detected in another model to be detected are determined, wherein the index values ​​of the center points of the first spherical voxel to be detected and the second spherical voxel to be detected are in Spherical voxels within the range, Represents the index value of the center point of the two intersecting spherical voxels in the deduplicated vertex array, Indicates the preset value; Performing collision detection on the first to-be-detected spherical voxel and the second to-be-detected spherical voxel; If it is detected that the first spherical voxel to be detected and the second spherical voxel to be detected do not collide, a third spherical voxel to be detected in one of the models to be detected and a fourth spherical voxel to be detected in another model to be detected are determined based on the index value, wherein the index values ​​of the center points of the third spherical voxel to be detected and the fourth spherical voxel to be detected are in and Spherical voxels within the range, Represents the index value of the center point of the two intersecting spherical voxels in the deduplicated vertex array, Indicates the preset value; performing collision detection on the first spherical voxel to be detected and the fourth spherical voxel to be detected, the second spherical voxel to be detected and the third spherical voxel to be detected, and the third spherical voxel to be detected and the fourth spherical voxel to be detected; If it is detected that the first to-be-detected spherical voxel and the fourth to-be-detected spherical voxel, the second to-be-detected spherical voxel and the third to-be-detected spherical voxel, and the third to-be-detected spherical voxel and the fourth to-be-detected spherical voxel do not collide, it is determined that the two to-be-detected models do not collide.

9. The method according to claim 8, characterized in that The method further comprises: If there are no two intersecting spherical voxels in the last collision detection, returning to the step of determining at least one set of target initial bounding boxes that collide according to the initial bounding boxes; If the two layered sub-bounding boxes where the center points of the two intersecting spherical voxels are located do not collide during the last collision detection, the two layered sub-bounding boxes are restored upward by one layer to obtain two layered new sub-bounding boxes; The two layered new sub-bounding boxes are used as the two initial bounding boxes in the target initial bounding box of the current group, and the step of respectively calculating the radii of the circumscribed spheres of the two initial bounding boxes in the target initial bounding box of the current group is returned to be executed.

10. A collision detection device for a model, characterized in that: include: A construction and determination unit, configured to construct an initial bounding box for each model to be detected, and determine at least one group of target initial bounding boxes that collide according to the initial bounding boxes, wherein a group of target initial bounding boxes includes two initial bounding boxes, and the model to be detected is a virtual model in the digital twin system; The collision detection unit is used to perform the following collision detection process on the two models to be detected in each group of the target initial bounding box in parallel: Calculate the radii of the circumscribed spheres of two of the target initial bounding boxes in the current group respectively; Performing synchronous or asynchronous octree layering on two of the target initial bounding boxes in the current group according to the ratio of the radii of the circumscribed sphere, and determining the layered sub-bounding boxes retained by each of the two initial bounding boxes according to the angles between the vectors formed by the center points of the two initial bounding boxes and the three coordinate axes, wherein the three coordinate axes are the coordinate axes formed by the center point of the initial bounding box and the center points of three adjacent faces of the initial bounding box that share the same vertex, and the two layered sub-bounding boxes are the areas where collision is most likely to occur; Determine whether the minimum side lengths of the two layered sub-bounding boxes are both smaller than a preset side length; If they are not both smaller than, the two layered sub-bounding boxes are used as the two initial bounding boxes in the target initial bounding box of the current group, and the step of respectively calculating the radii of the circumscribed spheres of the two initial bounding boxes in the target initial bounding box of the current group is returned to, until the minimum side lengths of the two layered sub-bounding boxes are both smaller than the preset side length, thereby obtaining the two layered sub-bounding boxes; Subdividing the triangular facets of the partial model surfaces of the two models to be detected in the two layered sub-bounding boxes, and constructing a spherical voxel with the vertices of the subdivided triangular facets as the center points of the spherical voxels and the radius of the inscribed circle of the subdivided triangular facets as the radius of the spherical voxel; Whether a collision occurs between the two models to be detected is determined by determining whether the spherical voxels intersect.

Citation Information

Patent Citations

  • Collision detecting method based on distance precedence and space-time relevancy

    CN104200031A

  • Prior safety predicting method for operation of double-arm service robot under dynamic environment

    CN109465835A

  • Collision detection method and apparatus for objects, and device and storage medium

    WO2022227489A1