GPU-based three-dimensional grid model BVH rapid construction method and system

By combining Morton coding and GPU sorting algorithms with a bottom-up parallel strategy, the problem of low efficiency in BVH tree construction on GPUs is solved, achieving efficient and fast BVH tree construction and optimization, which is suitable for rendering and collision detection in complex scenes.

CN121482331APending Publication Date: 2026-02-06ZHEJIANG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511668666.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-14
Publication Date
2026-02-06

AI Technical Summary

Technical Problem

Existing technologies struggle to achieve efficient and fully parallelized construction methods while maintaining high-quality BVH tree structures, especially when constructing BVH trees for 3D mesh models on GPUs, which suffers from uneven load distribution, thread synchronization issues, and inefficient memory access.

Method used

Using Morton coding and GPU sorting algorithms, the deduplication and sorting are performed by mapping triangular facets to Morton code sequences. The separation level of the BVH tree is calculated, and the BVH tree is constructed by combining a bottom-up parallel strategy, including node degradation optimization, to form a complete BVH tree structure.

Benefits of technology

It enables fast parallel construction of high-quality BVH trees on GPUs, improving construction and access efficiency, and is suitable for rendering and collision detection in complex scenes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121482331A_ABST
    Figure CN121482331A_ABST
Patent Text Reader

Abstract

The invention discloses a three-dimensional grid model BVH rapid construction method and system based on a GPU. The method comprises the following steps: firstly, performing data conversion on a three-dimensional grid model; then calculating the Morton code of each triangular patch and sorting the Morton code, and deducing hierarchical structure metadata of the generated BVH based on the number of leading zeros of a unique Morton code sequence; and finally, establishing a tree structure through a non-recursive sorting method, and carrying out node degradation optimization. According to the method, the parallel computing capacity of the GPU is fully utilized, the scale of a tree structure is reduced through Morton code deduplication and dynamic leaf node combination, recursion operation is avoided through an implicit tree building method based on sorting, and the traversal performance is optimized through node degradation, so that on the premise that the BVH quality is guaranteed, the BVH efficiency is improved, and the BVH efficiency is improved. Efficient parallel construction of the large-scale three-dimensional grid model BVH is achieved, and the method is suitable for scenes such as real-time rendering and physical simulation which have harsh performance requirements.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the fields of computer graphics, physical simulation and high-performance computing technology, and in particular relates to a method and system for rapid construction of a GPU-based 3D mesh model BVH. Background Technology

[0002] Bounding Volume Hierarchy (BVH) is a core data structure for accelerating computation in computer graphics and computational geometry, widely used in ray tracing, collision detection, and frustum clipping. Its core idea is to recursively organize geometric primitives (such as triangles) in a scene into a binary tree. Each tree node represents a bounding box (such as an axis-aligned bounding box AABB), which completely contains the geometric primitives represented by all its child nodes. This hierarchical spatial partitioning transforms the detection that previously required examining all primitives (such as finding the intersection of rays and triangles) into an efficient traversal along the BVH tree, reducing the computational complexity from O(N) to O(log N), significantly improving performance.

[0003] As applications such as virtual reality, augmented reality, high-fidelity rendering, autonomous driving simulation, and scientific visualization place increasingly higher demands on rendering quality and real-time performance, scene complexity is growing, potentially containing millions or even billions of primitives. This makes the build speed and quality of BVH (Browser Virtual Machine) a critical bottleneck in the entire graphics processing pipeline.

[0004] Traditional BVH construction methods are primarily based on CPU-based recursive algorithms, such as the top-down "split-select" method and the bottom-up "layer-by-layer merging" method. While these methods can build high-quality BVHs on a single-core CPU, their inherent recursive and sequential execution characteristics, along with frequent pointer jumps and memory access patterns, make it difficult to fully utilize the massively parallel computing capabilities of modern GPUs. Directly porting these algorithms to GPUs leads to severe load imbalance, thread synchronization problems, and inefficient memory access patterns, leaving many computational units idle and resulting in low construction efficiency.

[0005] Existing GPU-parallel BVH construction methods, such as those based on linear BVH (LBVH), achieve high parallelism by sorting primitives using space-filling curves (e.g., Morton codes), but the quality of the constructed BVH trees (considering tree traversal efficiency) is often low. Therefore, achieving an efficient and thoroughly parallel construction method while maintaining a high-quality BVH tree structure remains a pressing technical challenge in this field. Summary of the Invention

[0006] The purpose of this invention is to solve the problems existing in the prior art and to provide a method and system for rapid construction of a GPU-based 3D mesh model BVH.

[0007] To achieve the above-mentioned objectives, the present invention specifically adopts the following technical solution: In a first aspect, the present invention provides a method for rapid construction of a GPU-based 3D mesh model BVH, comprising the following steps: S1. Obtain the 3D mesh model of the mechanical part for which a bounding box hierarchy needs to be established, and then convert the 3D mesh model into a normalized form suitable for GPU massive parallel processing to obtain a triangular mesh representation composed of triangular facets; S2. Map all triangular faces to a fixed-length one-dimensional original Morton code sequence according to their spatial positions, so that spatially adjacent triangular faces are also adjacent in the sequence; S3. Identify the triangular facets with the same Morton code based on the original Morton code sequence to form a deduplicated Morton code sequence; S4. Calculate the separation level of the two leaf nodes corresponding to adjacent Morton codes in the BVH tree by the number of leading zeros of the XOR values ​​of adjacent Morton codes in the deduplicated Morton code sequence, and calculate the internal node metadata of each level of the BVH tree based on the separation level. Then, convert the leaf node metadata into a data format suitable for BVH construction, and together they form the BVH node metadata. S5. Using dual-key sorting, establish parent-child relationship links between nodes in the BVH tree based on the BVH node metadata to form an initial BVH tree structure. Then, perform node downgrading optimization on the initial BVH tree structure to obtain an optimized BVH tree structure. Obtain the leaf node axial bounding boxes based on the Morton code mapping information before and after deduplication. Then, use a bottom-up parallel strategy to obtain the internal node axial bounding boxes. Add the two types of node axial bounding boxes to the optimized BVH tree structure to form a complete BVH tree structure with pointers and axial bounding boxes.

[0008] Based on the above scheme, each step can be implemented in the following preferred manner.

[0009] As a preferred embodiment of the first aspect above, in S1, the vertices of each triangular facet are stored in a vertex buffer; a triplet formed by the indices of the three vertices of each triangular facet in the vertex buffer is stored as an element in an index buffer.

[0010] As a preferred embodiment of the first aspect mentioned above, the specific implementation process in S2 is as follows: S21. Divide the vertex buffer into blocks, and compute the local minimum bounding box and the local maximum bounding box in parallel through reduction operations within each thread block. Then, recursively merge the local bounding boxes of different thread blocks to obtain the global axial bounding box represented by the triangular mesh. S22. Parallel Startup Each GPU thread processes a triangular facet, calculates its centroid coordinates, and normalizes these coordinates using a global axis bounding box. This represents the number of triangular facets. S23. Calculate the Morton code for each triangular facet based on its normalized barycentric coordinates, and sort all the obtained Morton codes in parallel to obtain the original Morton code sequence.

[0011] As a preferred embodiment of the first aspect mentioned above, the specific implementation process in S3 is as follows: S31. Parallel Startup There are 10 GPU threads, each of which calculates whether the Morton code of its corresponding triangle is the same as the Morton code of the previous triangle, and stores the calculation result in a memory location of length 1. In the marker buffer; S32. Perform a parallel prefix sum scan on the marker buffer, store the scan results in the scan buffer, and store the scan results in the scan buffer. S33. When the number of unique Morton codes is When, allocate two lengths of The buffers are the unique Morton code buffers. and range mapping start index buffer Then start in parallel The thread; for the first thread One thread, when the mark buffer... The Middle When an element has a value of 0, its position in the deduplicated Morton code sequence is calculated, the Morton code value at that position is stored in a unique Morton code buffer, and the position of the first occurrence of that Morton code value in the deduplicated Morton code sequence is stored in a range mapping start index buffer; where, Indicates the first in the scan buffer Each element.

[0012] As a preferred embodiment of the first aspect mentioned above, the specific process for obtaining the BVH node metadata in S4 is as follows: S41. Parallel Startup The thread, the first The first thread first processes the deduplicated Morton code sequence into the... The and the first A Morton code is formed by a Morton code pair. The XOR value of the Morton code pair is then calculated to obtain the number of leading zeros in the XOR value. This number is used as the common level number of the two leaf nodes corresponding to the Morton code pair in the BVH tree. The number of leading zeros plus 1 is used as the level number at the first separation point of the two leaf nodes in the BVH tree. Then Stored in data pair buffer The element middle, Indicates the number of significant bits in the Morton code. They represent The first in One data pair; S42. Sort all data pairs in the data pair buffer, with the primary key being the level number and the secondary key being the index value. Both primary and secondary keys are in ascending order, forming a sorted buffer. S43. Traverse the sorted buffer. For two adjacent elements in the sorted buffer: if they have the same level in the BVH tree, then build an intermediate node at that level; if they do not have the same level, then build two intermediate nodes at that level. Finally, the BVH node metadata is composed of all generated internal node metadata and leaf node metadata.

[0013] As a preferred option in the first aspect mentioned above, the specific process of optimizing the node degradation of the initial BVH tree structure in S5 is as follows: a bottom-up parallel strategy is adopted, and the nodes are started in parallel. There are 12 threads, each traversing the path of the initial BVH tree structure upwards level by level. For each node in the current path, if the left and right child nodes of the node are the same, the parent node corresponding to the node is obtained, the node is deleted, and a new parent-child relationship is established between the parent node and the left child node, or between the parent node and the right child node. If the left and right child nodes of the node are not the same, the process continues to the next node in the current path.

[0014] Secondly, the present invention provides a GPU-based collision detection system, comprising: The tree structure acquisition module is used to acquire one or more vehicle 3D mesh models to be collision detected and one or more object 3D mesh models in the vehicle driving environment. It adopts the GPU-based 3D mesh model BVH fast construction method as described in any of the solutions in the first aspect above to generate the BVH tree structure corresponding to the vehicle 3D mesh model and the object 3D mesh model. The collision detection module is used to perform parallel traversal detection of the BVH tree structure of the vehicle 3D mesh model and the object 3D mesh model in the GPU. By determining whether the bounding boxes between different BVH tree nodes intersect, it filters out triangle facet pairs that may collide. The result generation module is used to perform precise geometric intersection detection on pairs of triangular facets to determine whether an actual collision has occurred, and to generate a collision detection result containing collision information; the collision information includes at least one of the following: collision object identifier, collision state, collision position, and collision depth. The safety response control module is used to output collision warning information to the driver in real time after generating collision detection results, or to send control commands to the active safety control system of the vehicle involved in the collision in real time, or to record collision detection results for safety assessment of the autonomous driving system; the warning information includes at least one of visual warning and auditory warning; the control commands are used to trigger at least one of automatic emergency braking, steering obstacle avoidance, or seat belt pretensioning.

[0015] Thirdly, the present invention provides a computer program product, including a computer program / instruction, which, when executed by a processor, enables the GPU-based rapid construction method for a three-dimensional mesh model BVH as described in any of the solutions of the first aspect above.

[0016] Fourthly, the present invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the GPU-based method for rapid construction of a three-dimensional mesh model (BVH) as described in any of the solutions of the first aspect above.

[0017] Fifthly, the present invention provides a computer electronic device, which includes a memory and a processor; The memory is used to store computer programs; The processor is configured to, when executing the computer program, implement the GPU-based rapid construction method for the BVH three-dimensional mesh model as described in any of the embodiments of the first aspect above.

[0018] Compared with the prior art, the present invention has the following advantages: This invention, based on Merton coding and GPU sorting algorithms, enables the rapid parallel construction of BVHs conforming to a triangular spatial distribution on a GPU. Furthermore, to further optimize the constructed BVH structure and improve access efficiency, this invention proposes methods for Merton code deduplication and BVH downgrading, which facilitate efficient access to the BVHs. Attached Figure Description

[0019] Figure 1 This is a flowchart of the method of the present invention; Figure 2 This is a schematic diagram of a first type of automobile model provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of a second type of car model provided in an embodiment of the present invention; Figure 4 This is a diagram showing the result of constructing the BVH (Browser Volume Hatch) of the first type of car model using the method of this invention. Figure 5 This is a diagram showing the result of constructing the BVH (Browser Volume Hatch) of a second car model using the method of this invention. Figure 6 This is a system block diagram of the present invention. Detailed Implementation

[0020] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. Many specific details are set forth in the following description to provide a thorough understanding of the present invention. However, the present invention can be practiced in many other ways different from those described herein, and those skilled in the art can make similar modifications without departing from the spirit of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below. Technical features in the various embodiments of the present invention can be combined accordingly without mutual conflict.

[0021] In the description of this invention, it should be understood that the terms "first" and "second" are used only for descriptive purposes and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Therefore, a feature defined with "first" and "second" may explicitly or implicitly include at least one of those features.

[0022] like Figure 1 As shown, in a preferred embodiment of the present invention, the GPU-based method for rapid construction of a 3D mesh model (BVH) includes the following steps S1 to S5. The specific implementation process of each step is described in detail below.

[0023] S1. Obtain the 3D mesh model of the mechanical part for which a bounding box hierarchy needs to be established, and then convert the 3D mesh model into a normalized form suitable for GPU massive parallel processing to obtain a triangular mesh representation composed of triangular facets.

[0024] It should be noted that in S1 of the present invention, the vertices of each triangular facet are stored in the vertex buffer; the triplet formed by the indices of the three vertices of each triangular facet in the vertex buffer is stored as an element in the index buffer.

[0025] It should be noted that S1 in this invention refers to model reading and data conversion. The converted triangular mesh representation of the mechanical part is specifically implemented in the program as a standardized mesh object, which should contain... vertices and It consists of triangular facets and is suitable for massively parallel processing on GPUs. Its data organization is as follows: Vertex buffer A length of A linear array, where each element It is a three-dimensional vector used to store the first... The coordinates of each vertex ,Right now .

[0026] Index Buffer A length of A linear array, where each element It is a triple used to store the components of the first... The three vertices of the triangular facet exist The index in, i.e. ,in .

[0027] Using the two buffers above, we can obtain the vertex coordinates of all triangles represented by the triangular mesh. It's important to note that the data organization process must ensure that the memory layout of the two buffers is contiguously aligned to enable efficient access to GPU memory in subsequent steps.

[0028] S2. Map all triangular faces to a fixed-length one-dimensional original Morton code sequence based on their spatial positions, such that spatially adjacent triangular faces are also adjacent in the sequence.

[0029] It should be noted that the specific implementation process in S2 of this invention is as follows: S21. Divide the vertex buffer into blocks, and compute the local minimum bounding box and the local maximum bounding box in parallel through reduction operations within each thread block. Then, recursively merge the local bounding boxes of different thread blocks to obtain the global axial bounding box (AABB) represented by the triangular mesh.

[0030] In this embodiment S21, the method for calculating the global axial bounding box is existing technology. The process will be briefly described below.

[0031] In this embodiment, two reduction operators are first defined: in, Indicates to and Take the minimum value in each dimension; Indicates to and Take the maximum value in each dimension; This indicates taking the minimum value; This indicates taking the maximum value; and for The elements in.

[0032] Then the vertex buffer Divide the code into blocks, and compute the local minimum bounding box in parallel within each thread block using the reduction operations described above. and local maximum bounding box These local results are then recursively merged to finally obtain the global axial bounding box. : in, These are the minimum and maximum points in the global axial bounding box, respectively.

[0033] S22. Parallel Startup Each GPU thread processes a triangular facet, calculates its centroid coordinates, and normalizes these coordinates using a global axis bounding box. This represents the number of triangular facets.

[0034] In this embodiment S22, for the first Each thread first obtains the three vertices of its corresponding triangle. : Secondly, calculate the first The centroid coordinates of the triangular facets Next, the centroid coordinates of each triangular facet are normalized to the global axial bounding box. The range is used to obtain the normalized barycentric coordinates. : It is important to note that the division performed during normalization is vector component division.

[0035] S23. Calculate the Morton code for each triangular facet based on its normalized barycentric coordinates, and sort all the obtained Morton codes in parallel to obtain the original Morton code sequence.

[0036] In this embodiment S23, the calculation of the Morton code for the triangular facet includes three stages: quantization, bit expansion, and bit interleaving. First, the normalized barycentric coordinates are quantized, mapping each of their dimensional components. Bit unsigned integer (e.g.) The range is 0 to ): in, This represents the three dimensional components of the centroid coordinates after quantization.

[0037] Secondly, A bit unsigned integer is expanded to Morton codes of 124 digits. This is a crucial operation that ensures each dimension of space is uniformly distributed in the code by alternately encoding the three dimensional components of the barycentric coordinates. For In this embodiment, each bit is processed through bit operations. The bit integer is extended to 30 bits, meaning each bit is followed by two zeros. This results in the Morton code. It is a 32-bit integer, which is formed by combining the three dimensional components of the expanded barycentric coordinates through a bitwise OR operation, and encodes the spatial position of the triangular facet: in, This represents the three-dimensional components of the expanded centroid coordinates.

[0038] After obtaining the Morton code for each triangular facet, a Morton code buffer is created. Each element in the set represents the Morton code of a triangular facet. Create an index mapping buffer. initialize it to Using the GPU radix sorting algorithm, with Morton code buffers... For key, for key-value pairs Sort the codes. After sorting, the Morton code buffer... The original Morton code sequence is transformed into an ascending order, while the index mapping buffer... These are the corresponding triangular facet indices arranged in Morton code order, and the sorted Morton code buffer is denoted as... Let the sorted index mapping buffer be . .

[0039] S3. Identify the triangular facets with the same Morton code based on the original Morton code sequence to form a deduplicated Morton code sequence.

[0040] It should be noted that due to quantization errors, triangular facets that are very close in spatial location may have the same Morton code. To address this, this invention designs step S3 to perform Morton code deduplication and leaf node merging. This step determines the unique Morton code and its starting position in the sorted triangular facet sequence through parallel comparison and prefix sum scanning, and merges these triangular facets into the same BVH leaf node.

[0041] To facilitate understanding by those skilled in the art, the specific process of S3 above is described below: S31. Parallel Startup There are 10 GPU threads, each of which calculates whether the Morton code of its corresponding triangle is the same as the Morton code of the previous triangle, and stores the calculation result in a memory location of length 1. The mark buffer middle.

[0042] In this embodiment S31, the element value of the marker buffer is 0 or 1, used to mark whether the Morton code of the current triangular facet is the same as the Morton code of the previous triangular facet. Specifically, in this embodiment, the element value is set to 1 when they are the same, and the element value is set to 1 when they are different. For the first One thread executes: in, Represents the tag buffer The first in One element; and These represent the sorted Morton code buffers. The first in The element and the first The element refers to the nth element in the original Morton code sequence. The Morton code of the triangular facet and the first Morton code for a triangular facet.

[0043] It should be noted that, considering the first The Morton codes of the triangular facets do not need to be involved in the above calculations; therefore, this embodiment only activates... Each GPU thread sets the first element of the flag buffer to 0 directly, i.e., a special convention. .

[0044] S32. Mark buffer Perform a parallel prefix sum scan, store the scan results in the scan buffer, and store the scan results in the scan buffer. The first scan in the buffer element The calculation method is as follows: in, Represents the tag buffer The first in Each element.

[0045] In this embodiment S32, The physical meaning is: in position How many repeated Morton codes were there before? Therefore, It is the new position of the current Morton code in the deduplicated Morton code sequence.

[0046] S33. When the number of unique Morton codes is When, allocate two lengths of The buffers are the unique Morton code buffers. and range mapping start index buffer Then start in parallel One thread; For the One thread, when the mark buffer... The Middle When an element has a value of 0, its position in the deduplicated Morton code sequence is calculated, and the Morton code value at that position is stored in a unique Morton code buffer. The position of the first occurrence of that Morton code value in the deduplicated Morton code sequence is stored in a range mapping start index buffer. Indicates the first in the scan buffer Each element.

[0047] In this embodiment S33, for the first One thread, when When (indicating the start of a new code), calculate its position in the deduplicated Morton code sequence. At the same time, , used to store unique Morton code values; let This is used to store the position of the first occurrence of this value in the deduplicated Morton code sequence. Among them, Indicates the position in the unique Morton code buffer. Morton code value; express The Middle Each element value; Indicates position The position of the first occurrence of the Morton code value in the deduplicated Morton code sequence.

[0048] at this time, It is the first A unique Morton code, and It specifies all codes with Morton codes. The triangular facets in The starting index in the matrix. The ending index of these triangular faces is... It should be noted that for the last unique Morton code... The ending index is .

[0049] S4. Calculate the separation level of the two leaf nodes corresponding to adjacent Morton codes in the BVH tree by the number of leading zeros of the XOR values ​​of adjacent Morton codes in the deduplicated Morton code sequence. Calculate the internal node metadata of each level of the BVH tree based on the separation level, and then convert the leaf node metadata into a data format suitable for BVH construction to form the BVH node metadata.

[0050] It should be noted that, in S4 of this invention, the specific process of obtaining BVH node metadata is as follows: S41. Parallel Startup The thread, the first The first thread first processes the deduplicated Morton code sequence into the... The and the first A Morton code is formed by a Morton code pair. The XOR value of the Morton code pair is then calculated to obtain the number of leading zeros in the XOR value. This number is used as the common level number of the two leaf nodes corresponding to the Morton code pair in the BVH tree. The number of leading zeros plus 1 is used as the level number at the first separation point of the two leaf nodes in the BVH tree. Then Stored in data pair buffer The element middle, Indicates the number of significant bits in the Morton code. They represent The first in One data pair.

[0051] In this embodiment S41, the first Each thread processes the unique Morton code buffer. The first in Morton code and the Morton code First calculate and The XOR value, calculate the number of leading zeros in the XOR value. Number of leading zeros mean and From highest to lowest The positions differ from one another. In this method, the Morton code is used to reflect the spatial position of the centroid coordinates of the triangular facet. The greater the difference in the Morton code, the more significant the difference. The smaller the value, the earlier the leaf nodes corresponding to these two Morton codes are separated in the tree. (Number of leading zeros) for and The common level number of the corresponding leaf nodes in the BVH tree. This represents the level number at the point where the two leaf nodes first separate in the BVH tree. Finally, Store data in buffer The element middle, This represents the number of significant bits in the Morton code, which is also the number of levels in the BVH tree. The size of the data pair buffer is... .

[0052] S42. Sort all data pairs in the data pair buffer by using the level number as the primary key and the index value as the secondary key, with both primary and secondary keys in ascending order, to form a sorted buffer.

[0053] In this embodiment S42, it is necessary to adjust the data pair buffer. All data pairs Sort the data. The primary key for sorting is... Secondary key is The primary and secondary keys are in ascending order. This sorting determines the splitting order of nodes during BVH tree construction: the higher the level (…). Nodes with smaller index values ​​are split first; among intermediate nodes of the same level, those with smaller corresponding leaf node index values ​​are split first.

[0054] S43. Traverse the sorted buffer. For two adjacent elements in the sorted buffer: if they have the same level in the BVH tree, then build an intermediate node at that level; if they do not have the same level, then build two intermediate nodes at that level. Finally, the BVH node metadata is composed of all generated internal node metadata and leaf node metadata.

[0055] In this embodiment S43, the sorted buffer Each element in This represents a BVH internal node interval. When constructing BVH internal nodes, it is necessary to consider... Two adjacent elements in the middle, i.e. and If both If the values ​​are the same, then in the BVH tree The layer constructs a corresponding leaf node index range of The middle node, where, Indicates the starting index (i.e., the starting value of the leaf node index range). express In value, This indicates the end index (i.e., the end value of the leaf node index range). express In Value. It should be noted that if... and of If the values ​​are different, two intermediate nodes need to be constructed. The index range of the leaf node corresponding to the first intermediate node is... The index range of the leaf node corresponding to the second intermediate node is... Thus, the metadata of all generated internal nodes... and leaf node metadata Together, they form the BVH node metadata and are stored in the node metadata buffer in order. .

[0056] S5. Using dual-key sorting, establish parent-child relationship links between nodes in the BVH tree based on the BVH node metadata to form an initial BVH tree structure. Then, perform node downgrading optimization on the initial BVH tree structure to obtain an optimized BVH tree structure. Obtain the leaf node axial bounding boxes based on the Morton code mapping information before and after deduplication. Then, use a bottom-up parallel strategy to obtain the internal node axial bounding boxes. Add the two types of node axial bounding boxes to the optimized BVH tree structure to form a complete BVH tree structure with pointers and axial bounding boxes.

[0057] It should be noted that the specific process of constructing the initial BVH tree structure in S5 of this invention is as follows: First of all, with Using the key, sort all BVH node metadata in ascending order. After sorting, for any two adjacent consecutive nodes... and ,if of and of Same, that is ,but yes The left child node, yes The parent node, which means The range of managed leaf nodes starts from The corresponding range begins, and the level is deeper; otherwise, It is a leaf node in a BVH tree, because if If it is an intermediate node, then It must equal . and They are respectively and of .

[0058] Secondly, with Using the key, sort all BVH node metadata in ascending order. After sorting, for any two adjacent consecutive nodes... and ,if of and of Same, that is ,but yes The right child node, yes The parent node, which means The managed leaf node range terminates at The corresponding range ends, and the level is deeper; otherwise, This is a leaf node in a BVH tree. and They are respectively and of .

[0059] By sorting and assigning pointers twice, using the starting index and level as keys and the ending index and level as keys, the parent-child pointer relationship between internal nodes is implicitly established, and the initial BVH tree structure can be constructed without recursive traversal.

[0060] It should be noted that, in S5 of this invention, the specific process of optimizing the node degradation of the initial BVH tree structure is as follows: a bottom-up parallel strategy is adopted, and the nodes are started in parallel. There are 12 threads, each traversing the path of the initial BVH tree structure upwards level by level. For each node in the current path, if the left and right child nodes of the node are the same, the parent node corresponding to the node is obtained, the node is deleted, and a new parent-child relationship is established between the parent node and the left child node, or between the parent node and the right child node. If the left and right child nodes of the node are not the same, the process continues to the next node in the current path.

[0061] In this embodiment, due to the uneven spatial distribution of triangular facets, there may be intermediate nodes with only one child node. This situation occurs frequently when the data volume is large, and this redundant data will affect the query efficiency of BVH. Therefore, it is necessary to reasonably degrade BVH nodes. Specifically, this invention adopts a bottom-up parallel strategy to start in parallel. There are 10 threads, each thread traversing the path of the initial BVH tree structure upwards, level by level. For each node in the current path... ,if left child node and right child node If they are the same, then obtain the parent node corresponding to that node. , and delete And then and To establish a new father-son relationship, or in and A new parent-child relationship is established between the nodes. If the left and right child nodes of the current node are different, the process continues to the next node in the current path. This step removes duplicate nodes in the BVH that have only one valid child node, shortening the search path length during BVH queries and improving query efficiency.

[0062] It should be noted that in S5 of this invention, after obtaining the optimized BVH tree structure, a bottom-up parallel strategy is adopted to perform parallel hierarchical AABB computation.

[0063] Leaf node axial bounding boxes: Parallel processing of each unique Morton code, the first Accessed by a thread Zhong Cong arrive Given all the triangular facet indices, retrieve the corresponding triangular facets and calculate the minimum and maximum coordinates of the vertices of these triangular facets to form the axial bounding box of the leaf node.

[0064] It is worth noting that the axial bounding box of each triangular facet should have already been calculated in S2. Therefore, this step only involves merging the axial bounding boxes of the triangular facets. Considering that the BVH structure establishment and optimization in S5 has no synchronous dependency with the leaf nodes, the axial bounding box calculation task of the leaf nodes can be performed after S4. This allows the GPU to construct the BVH in parallel with higher efficiency.

[0065] Internal node axial bounding boxes: After the parent-child relationship is established, the axial bounding boxes of internal nodes can be obtained by merging the axial bounding boxes of their left and right child nodes. This process can be arranged in a parallel upward propagation step: starting from the leaf node with the largest depth, proceeding upwards level by level, each internal node waits for the axial bounding boxes of its child nodes to be calculated before calculating its own axial bounding box (i.e., ...). This can be achieved through dynamic parallelism or work queues on the GPU. The axial bounding box representing the child nodes of a merged internal node; The axial bounding box representing the left child node. Represents the axial bounding box of the right child node.

[0066] It is worth noting that the axial bounding boxes of leaf nodes and internal nodes in S5 are calculated in a completely parallel manner. The axial bounding box of leaf nodes is calculated by merging the vertex coordinates of the triangular facets to which they belong, and the axial bounding box of internal nodes is calculated by merging the axial bounding boxes of their child nodes.

[0067] Thus, the method for rapid BVH construction of a GPU-based 3D mesh model has been described in detail. This method achieves efficient BVH construction of 3D mesh models.

[0068] To better demonstrate the specific implementation and technical effects of the present invention, the GPU-based BVH rapid construction method for 3D mesh models shown in steps S1 to S5 of the above preferred implementation is applied to a specific example.

[0069] Example The specific implementation process of the GPU-based 3D mesh model BVH rapid construction method used in this embodiment is as described above and will not be repeated here.

[0070] To demonstrate the feasibility and practical effectiveness of the GPU-based BVH rapid construction method for 3D mesh models shown in S1-S5 above, this invention selected some automotive 3D mesh models from a physical simulation platform for algorithm verification. Figure 2 and Figure 3 Two car models with different complexities are shown: Model M1 contains 3568 triangular faces, and Model M2 contains 197045 triangular faces. The bounding box distributions in the 6th layer of the BVH constructed on the two models using the method of this invention are as follows: Figure 4 and Figure 5 As shown, even in complex geometric regions of the model, the bounding boxes can still fit tightly to the model surface, while maintaining a small overlap between bounding boxes at the same level, demonstrating a good spatial partitioning effect.

[0071] Table 1 further lists the statistical results of the effective bounding box counts at each level of the BVH in both models. The data shows that the number of bounding boxes between adjacent levels generally exhibits a strict multiple relationship, reflecting the good balance of the constructed binary tree structure. This characteristic helps to achieve more efficient spatial culling during collision detection, thereby significantly improving detection speed.

[0072] Table 1. Number of effective bounding boxes in the model It should also be noted that the GPU-based rapid construction method for the BVH 3D mesh model in the above embodiments can essentially be executed by a computer program or module. Therefore, similarly, based on the same inventive concept, another preferred embodiment of the present invention also provides a GPU-based collision detection system corresponding to the GPU-based rapid construction method for the BVH 3D mesh model provided in the above embodiments, such as... Figure 6 As shown, it includes: The tree structure acquisition module is used to acquire one or more vehicle 3D mesh models to be collision detected and one or more object 3D mesh models in the vehicle driving environment. It uses the GPU-based 3D mesh model BVH fast construction method described in the above embodiment to generate the BVH tree structure corresponding to the vehicle 3D mesh model and the object 3D mesh model. The collision detection module is used to perform parallel traversal detection of the BVH tree structure of the vehicle 3D mesh model and the object 3D mesh model in the GPU. By determining whether the bounding boxes between different BVH tree nodes intersect, it filters out triangle facet pairs that may collide. The result generation module is used to perform precise geometric intersection detection on pairs of triangular facets to determine whether an actual collision has occurred, and to generate a collision detection result containing collision information; the collision information includes at least one of the following: collision object identifier, collision state, collision position, and collision depth. The safety response control module is used to output collision warning information to the driver in real time after generating collision detection results, or to send control commands to the active safety control system of the vehicle involved in the collision in real time, or to record collision detection results for safety assessment of the autonomous driving system; the warning information includes at least one of visual warning and auditory warning; the control commands are used to trigger at least one of automatic emergency braking, steering obstacle avoidance, or seat belt pretensioning.

[0073] It's important to note that the collision status in the collision information indicates "whether a collision occurred." During the precise detection phase, as long as at least one pair of triangular facets are found to have geometrically intersected, the collision status is set to "true" or "collision." If no intersection is found, it's set to "false" or "safe," eliminating the need for subsequent calculations of collision location and depth, thus saving computational resources. The collision location indicates "where the collision occurred," referring to the three-dimensional spatial coordinates of the collision. This location can be a point (usually the first point of contact or the point of deepest penetration) or a small area. The collision depth indicates "how severe the collision was," quantifying the distance one object penetrates into the interior of another. The greater the depth, the more severe the collision and the greater the potential damage. Different collision depths may trigger different processing mechanisms. For example, a very small collision depth (e.g., a minor scratch) might only trigger a warning, while a very large collision depth (e.g., a severe rear-end collision) will immediately trigger the highest level of response, such as full braking and airbag deployment. The collision object identifier indicates "who collided with whom", which can uniquely identify each object involved in the collision. When a collision is detected, it will record which part of which object the colliding triangle belongs to.

[0074] It should be noted that visual warnings can be flashing icons / symbols, such as a red collision warning icon suddenly lighting up and flashing on the dashboard or head-up display; they can also be light indicators, such as a red or amber light emitted by an LED light strip installed below the windshield; or they can be enhanced head-up display, such as a red warning box or exclamation mark directly superimposed on the obstacle in front of the windshield in a virtual image; or they can be text information, such as "Collision Warning! Please Brake!" displayed on the dashboard. Auditory warnings can be beeps / alarms; or they can be voice prompts, such as "Brake! Brake!" or "Collision Ahead!".

[0075] It's important to note that seatbelt pretensioning is a core function of modern vehicle passive safety systems. It refers to the system rapidly tightening the seatbelt within tens of milliseconds of a collision, eliminating any slack between the seatbelt and the occupant's body, and firmly securing the occupant to the seat. Automatic emergency braking refers to the system actively and forcibly applying the brakes when the vehicle determines there is a very high risk of collision with a vehicle, pedestrian, or other obstacle ahead, and the driver has not taken any braking action or the braking force is insufficient, in order to avoid a collision or mitigate its consequences. Steering avoidance refers to the system actively controlling the steering wheel to steer the vehicle around obstacles when facing a collision risk, provided that braking may not be sufficient to avoid a collision and there is safe lateral space.

[0076] It should also be noted that the collision detection module and result generation module mentioned above have already disclosed algorithms for collision detection based on the BVH tree structure in the prior art, and they are relatively mature. They are not the core improvement point of this invention, so the specific implementation logic will not be described in this embodiment.

[0077] It is understood that the GPU-based BVH rapid construction method for 3D mesh models described in S1-S5 above can essentially be implemented by a computer program. Therefore, based on the same inventive concept, another preferred embodiment of the present invention also provides a computer program product corresponding to the GPU-based BVH rapid construction method for 3D mesh models provided in the above embodiments. This product includes a computer program / instruction, which, when executed by a processor, can implement the GPU-based BVH rapid construction method for 3D mesh models as described in the above embodiments.

[0078] Similarly, based on the same inventive concept, another preferred embodiment of the present invention also provides a computer electronic device corresponding to the GPU-based BVH rapid construction method for three-dimensional mesh models provided in the above embodiments, which includes a memory and a processor; The memory is used to store computer programs; The processor is configured to implement the GPU-based rapid construction method for the BVH three-dimensional mesh model in the above embodiments when executing the computer program.

[0079] Furthermore, the logical instructions in the aforementioned memory can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention.

[0080] Therefore, based on the same inventive concept, another preferred embodiment of the present invention also provides a computer-readable storage medium corresponding to the GPU-based rapid construction method for BVH three-dimensional mesh models provided in the above embodiments. The storage medium stores a computer program, which, when executed by a processor, can realize the GPU-based rapid construction method for BVH three-dimensional mesh models in the above embodiments.

[0081] Specifically, in the computer-readable storage medium of the above three embodiments, the stored computer program is executed by a processor, which can perform the aforementioned steps S1 to S5.

[0082] It is understood that the aforementioned storage media may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Furthermore, the storage media may also be various media capable of storing program code, such as USB flash drives, external hard drives, magnetic disks, or optical discs.

[0083] It is understood that the processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0084] It should also be noted that those skilled in the art will understand that, for the sake of convenience and brevity, the specific working process of the system described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here. In the embodiments provided in this application, the division of steps or modules in the system and method is merely a logical functional division, and there may be other division methods in actual implementation. For example, multiple modules or steps may be combined or integrated together, and a module or step may also be split.

[0085] The embodiments described above are merely preferred embodiments of the present invention and are not intended to limit the invention. Those skilled in the art can make various changes and modifications without departing from the spirit and scope of the invention. Therefore, all technical solutions obtained through equivalent substitution or transformation fall within the protection scope of the present invention.

Claims

1. A GPU-based method for rapid construction of a 3D mesh model (BVH), characterized in that, Includes the following steps: S1. Obtain the 3D mesh model of the mechanical part for which a bounding box hierarchy needs to be established, and then convert the 3D mesh model into a normalized form suitable for GPU massive parallel processing to obtain a triangular mesh representation composed of triangular facets; S2. Map all triangular faces to a fixed-length one-dimensional original Morton code sequence according to their spatial positions, so that spatially adjacent triangular faces are also adjacent in the sequence; S3. Identify the triangular facets with the same Morton code based on the original Morton code sequence to form a deduplicated Morton code sequence; S4. Calculate the separation level of the two leaf nodes corresponding to adjacent Morton codes in the BVH tree by the number of leading zeros of the XOR values ​​of adjacent Morton codes in the deduplicated Morton code sequence, and calculate the internal node metadata of each level of the BVH tree based on the separation level. Then, convert the leaf node metadata into a data format suitable for BVH construction, and together they form the BVH node metadata. S5. Using dual-key sorting, establish parent-child relationship links between nodes in the BVH tree based on the BVH node metadata to form an initial BVH tree structure. Then, perform node downgrading optimization on the initial BVH tree structure to obtain an optimized BVH tree structure. Obtain the leaf node axial bounding boxes based on the Morton code mapping information before and after deduplication. Then, use a bottom-up parallel strategy to obtain the internal node axial bounding boxes. Add the two types of node axial bounding boxes to the optimized BVH tree structure to form a complete BVH tree structure with pointers and axial bounding boxes.

2. The GPU-based method for rapid construction of a BVH 3D mesh model as described in claim 1, characterized in that, In S1, the vertices of each triangle are stored in the vertex buffer; the triples formed by the indices of the three vertices of each triangle in the vertex buffer are stored as an element in the index buffer.

3. The GPU-based method for rapid construction of a BVH 3D mesh model as described in claim 1, characterized in that, In S2, the specific implementation process is as follows: S21. Divide the vertex buffer into blocks, and compute the local minimum bounding box and the local maximum bounding box in parallel through reduction operations within each thread block. Then, recursively merge the local bounding boxes of different thread blocks to obtain the global axial bounding box represented by the triangular mesh. S22. Parallel Startup Each GPU thread processes a triangular facet, calculates its centroid coordinates, and normalizes these coordinates using a global axis bounding box. This represents the number of triangular facets. S23. Calculate the Morton code for each triangular facet based on its normalized barycentric coordinates, and sort all the obtained Morton codes in parallel to obtain the original Morton code sequence.

4. The GPU-based method for rapid construction of a BVH 3D mesh model as described in claim 3, characterized in that, In S3, the specific implementation process is as follows: S31. Parallel Startup There are 10 GPU threads, each of which calculates whether the Morton code of its corresponding triangle is the same as the Morton code of the previous triangle, and stores the calculation result in a memory location of length 1. In the marker buffer; S32. Perform a parallel prefix sum scan on the marker buffer, store the scan results in the scan buffer, and store the scan results in the scan buffer. S33. When the number of unique Morton codes is When, allocate two lengths of The buffers are the unique Morton code buffers. and range mapping start index buffer Then start in parallel The thread; for the first thread One thread, when the mark buffer... The Middle When an element has a value of 0, its position in the deduplicated Morton code sequence is calculated, the Morton code value at that position is stored in a unique Morton code buffer, and the position of the first occurrence of that Morton code value in the deduplicated Morton code sequence is stored in a range mapping start index buffer; where, Indicates the first in the scan buffer Each element.

5. The GPU-based method for rapid construction of a BVH 3D mesh model as described in claim 4, characterized in that, In S4, the specific process of obtaining BVH node metadata is as follows: S41. Parallel Startup The thread, the first The first thread first processes the deduplicated Morton code sequence into the... The and the first A Morton code is formed by a Morton code pair. The XOR value of the Morton code pair is then calculated to obtain the number of leading zeros in the XOR value. This number is used as the common level number of the two leaf nodes corresponding to the Morton code pair in the BVH tree. The number of leading zeros plus 1 is used as the level number at the first separation point of the two leaf nodes in the BVH tree. Then Stored in data pair buffer The element middle, Indicates the number of significant bits in the Morton code. They represent The first in One data pair; S42. Sort all data pairs in the data pair buffer, with the primary key being the level number and the secondary key being the index value. Both primary and secondary keys are in ascending order, forming a sorted buffer. S43. Traverse the sorted buffer. For two adjacent elements in the sorted buffer: if they have the same level in the BVH tree, then build an intermediate node at that level; if they do not have the same level, then build two intermediate nodes at that level. Finally, the BVH node metadata is composed of all generated internal node metadata and leaf node metadata.

6. The GPU-based method for rapid construction of a BVH 3D mesh model as described in claim 5, characterized in that, In S5, the specific process of optimizing node degradation in the initial BVH tree structure is as follows: A bottom-up parallel strategy is adopted, and nodes are started in parallel. There are 12 threads, each traversing the path of the initial BVH tree structure upwards level by level. For each node in the current path, if the left and right child nodes of the node are the same, the parent node corresponding to the node is obtained, the node is deleted, and a new parent-child relationship is established between the parent node and the left child node, or between the parent node and the right child node. If the left and right child nodes of the node are not the same, the process continues to the next node in the current path.

7. A GPU-based collision detection system, characterized in that, include: The tree structure acquisition module is used to acquire one or more vehicle 3D mesh models to be collision detected and one or more object 3D mesh models in the vehicle driving environment, and to generate the BVH tree structure corresponding to the vehicle 3D mesh model and the object 3D mesh model using the GPU-based 3D mesh model BVH fast construction method described in any one of claims 1 to 6. The collision detection module is used to perform parallel traversal detection of the BVH tree structure of the vehicle 3D mesh model and the object 3D mesh model in the GPU. By determining whether the bounding boxes between different BVH tree nodes intersect, it filters out triangle facet pairs that may collide. The result generation module is used to perform precise geometric intersection detection on pairs of triangular facets to determine whether an actual collision has occurred, and to generate a collision detection result containing collision information; the collision information includes at least one of the following: collision object identifier, collision state, collision position, and collision depth. The safety response control module is used to output collision warning information to the driver in real time after generating collision detection results, or to send control commands to the active safety control system of the vehicle involved in the collision in real time, or to record collision detection results for safety assessment of the autonomous driving system; the warning information includes at least one of visual warning and auditory warning; the control commands are used to trigger at least one of automatic emergency braking, steering obstacle avoidance, or seat belt pretensioning.

8. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, they can implement the GPU-based method for rapid construction of the BVH three-dimensional mesh model as described in any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, implements the GPU-based rapid construction method for the BVH three-dimensional mesh model as described in any one of claims 1 to 6.

10. A computer electronic device, characterized in that, Including memory and processor; The memory is used to store computer programs; The processor is configured to implement the GPU-based rapid construction method for a three-dimensional mesh model BVH as described in any one of claims 1 to 6 when executing the computer program.