Parallel Rigid Body Collision Detection Method and Device Based on Sparse Octree

The Z-SFC-based sparse octree method addresses inefficiencies in GPU collision detection by enabling parallel processing, enhancing real-time collision detection efficiency for large-scale rigid bodies.

CN114820830BActive Publication Date: 2025-07-15INST OF SOFTWARE - CHINESE ACAD OF SCI
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110112295.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-01-27
Publication Date
2025-07-15
Estimated Expiration
2041-01-27

AI Technical Summary

Technical Problem

The traditional rigid body collision detection algorithm is inefficient and cannot effectively use the GPU for parallel computing, resulting in insufficient efficiency in large-scale rigid body collision detection.

Method used

The sparse octree construction method is adopted, combined with Z-space fill curves and indexes, and a compressed octree is built from the bottom up to generate a complete octree in parallel, which is suitable for parallel GPU computing.

Benefits of technology

The complexity of collision detection is significantly reduced, real-time detection and calculation of large-scale rigid body collisions is realized, and the efficiency is improved by two orders of magnitude.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114820830B_ABST
    Figure CN114820830B_ABST
Patent Text Reader

Abstract

The present invention discloses a parallel rigid body collision detection method and device based on a sparse octree, including: constructing an enclosing box tree according to the rigid bodies to be collision-detected, dividing the generated collision regions, and obtaining the indexes of each small unit space; constructing the leaf nodes of a compressed octree based on the center of gravity of the rigid bodies to be collision-detected and the indexes of each small unit space; sorting the generated internal nodes to generate a post-order traversal of the compressed octree; combining the internal nodes with the post-order traversal of the compressed octree to generate a compressed octree; obtaining intermediate nodes by calculating the depth difference between each node in the compressed octree and its parent node, and generating a complete octree; starting from the leaf nodes of the complete octree, querying the overlapping regions from bottom to top to find the pairs of leaf nodes that collide. The present invention effectively linearizes the collision regions using a Z-space filling curve (Z-SFC), greatly reducing the computational overhead and enabling real-time detection and calculation of large-scale rigid body collisions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the fields of computer graphics and human-computer interaction, and particularly relates to a parallel rigid body collision detection method and device based on a sparse octree. Background Art

[0002] An octree is a very common data structure in the field of computer simulation, and is widely used in fields such as collision detection, ray tracing, and simplification of three-dimensional scenes. With the increasing demand for simulation realism and frame rate, more and more simulation algorithms are no longer satisfied with the computing power of the CPU and begin to use GPU parallel acceleration to solve problems. Although the GPU has a relatively fast parallel computing speed, the current GPU design architecture does not support recursive algorithms and dynamic memory allocation, resulting in significant differences between some GPU algorithms and CPU algorithms in the implementation process. Many complex data structures and algorithms are not suitable for implementation using the GPU. The traditional octree is constructed in a top-down manner, which is difficult to parallelize using the GPU. Ferrando proposed an algorithm for creating an octree by combining the different advantages of the CPU and the GPU [Ferrando N, M. A. Gosálvez, J. Cerdá, et al. Octree-based, GPU implementation of a continuous cellular automaton for the simulation of complex, evolving surfaces [J]. Computer Physics Communications, 2011, 182(3): 628-640.]. The structure of the octree is created by the CPU, and the data between nodes is calculated and transmitted by the GPU. This method makes up for the respective shortcomings of the CPU and the GPU to a certain extent, but also causes communication overhead between the CPU and the GPU. Xiong et al. proposed a dynamic object collision detection algorithm based on a hybrid octree [Xiong Xinyi, Yao Yu. Dynamic object collision detection algorithm based on hybrid octree [J]. Journal of Computer Applications, 2019(A01): 96-99.]. This algorithm combines the characteristics of static octrees and dynamic octrees, and reduces the space consumption to a certain extent, but this algorithm cannot be applied to real-time calculations, and its efficiency needs to be improved. Summary of the Invention

[0003] The present invention mainly aims at the problem of low efficiency of traditional rigid body collision detection algorithms, and proposes a parallel rigid body collision detection method and device based on a sparse octree. By using the Z-space filling curve (Z-SFC) and indexes, an octree is constructed from bottom to top, thus greatly reducing the complexity of collision detection. At the same time, this method is suitable for parallel solution using a GPU, making real-time detection and calculation of large-scale rigid body collisions possible.

[0004] Specifically, the technical solution of the present invention is as follows:

[0005] A parallel rigid body collision detection method based on a sparse octree, the steps of which include:

[0006] 1) Construct a bounding box tree according to the rigid bodies to be collision-detected, generate a collision region based on the root node of the bounding box tree, divide the collision region, encode each obtained small unit space, and generate indexes for each small unit space;

[0007] 2) Construct leaf nodes of a compressed octree based on the center of gravity of the rigid bodies to be collision-detected and the indexes of each small unit space;

[0008] 3) Take the lowest common ancestor of two adjacent leaf nodes as an internal node, perform parallel sorting on internal nodes of different layers, generate a post-order traversal of the compressed octree, and combine the internal nodes with the post-order traversal of the compressed octree to generate a compressed octree;

[0009] 4) Obtain intermediate nodes by calculating the depth difference between each node in the compressed octree and its parent node, and generate a complete octree;

[0010] 5) Start querying the overlapping region from the leaf nodes of the complete octree from bottom to top, and find pairs of leaf nodes where collisions occur.

[0011] Further, the bounding box tree includes: an axis-aligned bounding box tree and an oriented bounding box tree.

[0012] Further, the bounding box tree is constructed through the following steps:

[0013] 1) Reconstruct the contour of each rigid body P i to be collision-detected, where i is the serial number of the rigid body to be collision-detected;

[0014] 2) Take the rigid body P1 to be collision-detected as the root node of the bounding box tree, and take other rigid bodies P i to be collision-detected as a node of the bounding box tree;

[0015] 3) Judge whether there is an intersection in the regions where the rigid body P1 to be collision-detected and other rigid bodies P i to be collision-detected are located;

[0016] 4) If there is an intersection and the other rigid body P to be collision - detected i has an intersection with the subset of the rigid body P1 to be collision - detected, then add the corresponding nodes of the other rigid body P to be collision - detected i after the smallest common sub - nodes of the corresponding nodes of the subset of the rigid body P1 to be collision - detected; if there is no intersection, generate a common region according to the rigid body P1 to be collision - detected and the other rigid body P to be collision - detected i and generate common nodes.

[0017] Furthermore, the method for dividing the collision region includes: Z - space filling curve.

[0018] Furthermore, the encoding method includes: Morton code.

[0019] Furthermore, construct the leaf nodes of the compressed octree through the following steps:

[0020] 1) Obtain the centroid of the rigid body to be collision - detected to get the coordinates of the leaf nodes;

[0021] 2) According to the index of each small unit space, represent the coordinates of the leaf nodes in index form;

[0022] 3) Save the coordinates of the leaf nodes in index form in an array A with a length of 2n - 1, where n is the number of rigid bodies P to be collision - detected i ;

[0023] 4) Sort the n elements in the array A according to the leaf nodes in index form to construct the leaf nodes of the compressed octree.

[0024] Furthermore, obtain the post - order traversal of the compressed octree through the following steps:

[0025] 1) Allocate n - 1 GPU threads;

[0026] 2) For the internal nodes generated by two adjacent leaf nodes A[i] and A[i + 1] in the first half of the array A, store them in the array A[n + i];

[0027] 3) According to the index of each small unit space, perform parallel sorting on the internal nodes of different layers and delete the duplicates in the second half of the array A; for every two adjacent internal nodes without the same index, start traversing the second half of the array A from the current node in parallel and delete the duplicates;

[0028] 4) Perform parallel sorting on the array A according to the index of each small unit space to obtain the post - order traversal of the compressed octree.

[0029] Furthermore, generate the compressed octree through the following steps:

[0030] 1) Allocate an array B that is twice the size of array A, and copy the data in array A to array B;

[0031] 2) Allocate p + q - 1 GPU threads, where p is the number of leaf nodes and q is the number of internal nodes;

[0032] 3) For every two adjacent leaf nodes B[i] and B[i + 1] in the first half of array B, generate internal nodes in parallel and store them in B[n + i];

[0033] 4) Sort the generated results in parallel according to the indices of the small cell spaces;

[0034] 5) For nodes with the same index and at least one of them not being a copy, establish the parent - child relationship of the internal nodes to generate a compressed octree.

[0035] Furthermore, a complete octree is generated through the following steps:

[0036] 1) Allocate threads whose number is not less than the length of array A;

[0037] 2) Calculate and accumulate the depth difference between each node and its parent node to obtain the total memory required for inserting internal nodes;

[0038] 3) Calculate the depth difference between each node and its parent node in parallel, and when the depth difference is greater than a set threshold, insert intermediate nodes between each node and its parent node in parallel to generate a complete octree.

[0039] A storage medium stores a computer program, wherein the computer program is set to execute the above - mentioned method when running.

[0040] An electronic device includes a memory and a processor. The memory stores a computer program, and the processor is set to run the computer program to execute the above - mentioned method.

[0041] Compared with the prior art, the present invention has the following advantages:

[0042] (1) The present invention proposes a parallel rigid - body collision detection method based on a sparse octree, which uses the Z - space filling curve (Z - SFC) to effectively linearize the collision area, thus greatly reducing the computational overhead;

[0043] (2) Each step in the present invention has high parallelism, so it is applicable to the existing GPU architecture, and can utilize hardware acceleration to achieve real - time detection and calculation of large - scale rigid - body collisions;

[0044] (3) Compared with the traditional single-threaded CPU for recursive octree construction, in the case of large-scale collision scenarios, the efficiency can be increased by two orders of magnitude. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] Figure 1 It is a flowchart of the method.

[0046] Figure 2A It is a diagram of the spatial positions of rigid bodies 1-9.

[0047] Figure 2B It is a diagram of the constructed AABB tree.

[0048] Figure 3A It is a schematic diagram of the division of the Z-space filling curve (Z-SFC) in two-dimensional space.

[0049] Figure 3B It is a schematic diagram of marking the results of the division of the Z-space filling curve (Z-SFC).

[0050] Figure 4 It is a schematic diagram of the spatial division of rigid bodies 1-9.

[0051] Figure 5 It is a schematic diagram of the Z-space filling curve index.

[0052] Figure 6 It is a schematic diagram of the Z-space filling curves at different levels.

[0053] Figure 7 It is a schematic diagram of the construction of a parallel octree based on GPU.

[0054] Figure 8 It is a schematic diagram of the parent-child relationship of internal nodes.

[0055] Figure 9 It is a schematic diagram of the generated compressed octree.

[0056] Figure 10 It is a schematic diagram of generating a complete octree from the compressed octree.

[0057] Figure 11 It is a schematic diagram of the complete octree structure.

[0058] Figure 12 It is a schematic diagram of bottom-up parallel collision detection in the octree.

[0059] Figure 13 It is a schematic diagram of fine-grained detection of the collision area. DETAILED DESCRIPTION OF THE INVENTION

[0060] To make the above objects, features, and advantages of the present invention more obvious and understandable, the present invention will be described in detail below through specific implementations and drawings, but it does not constitute a limitation to the present invention.

[0061] The hardware platform of the method of the present invention uses a CPU with the model of Intel i7-8700, the main frequency is 3.2 GHz, an NVIDIA GeForce GTX 1080Ti graphics card, and the video memory is 8 GB. The system program is written in C++. For the parallel computing part, the CUDA language is used for acceleration, and the program is compiled and executed with the help of Microsoft Visual Studio 2017. Open source libraries such as OpenGL and Freeglut are used during the development process.

[0062] The flow chart of the method of the present invention is as Figure 1 shown, and the whole process is mainly divided into five parts. First, build a bounding box tree for n rigid bodies that may collide (including: AABB tree (axis-aligned bounding box tree, Aixe align bounding boxtree) and OBB tree (oriented bounding box tree). The following will take the AABB tree as an example), and take the area corresponding to the root node of the AABB tree as the collision area; then, use the Z-space filling curve (Z-SFC) to divide the collision area to generate a unit space, and use the Morton code to encode the unit space to generate a Z-space filling curve (Z-SFC) index for subsequent construction of the adjacency relationship of internal nodes; then, build a compressed octree from bottom to top and in parallel according to the generated Z-space filling curve (Z-SFC) index; secondly, further restore the constructed compressed octree into a complete octree structure in parallel; finally, perform parallel collision detection from bottom to top according to the complete octree. Next, we will introduce the specific implementation solutions of each step in detail.

[0063] 1. Build an AABB tree. Each child node in the AABB tree is also in the structure of an AABB tree, and it only takes a time complexity of log(n) to complete the node search process. Suppose we want to detect the collision of rigid bodies 1-9. Generate an AABB bounding box according to the contours of rigid bodies 1-9. Next, build an AABB tree by performing the following operations (as Figure 2A and Figure 2B shown):

[0064] (a) Take rigid body 1 as the root node of the AABB tree;

[0065] (b) Compare rigid body 2 with rigid body 1 to determine whether there is an intersection between the areas where rigid body 2 and rigid body 1 are located. If there is an intersection, continue to determine whether rigid body 2 has an intersection with the subset of rigid body 1, and add it after the smallest common child node of the subset that has a common intersection with node 1. If there is no intersection between rigid body 2 and rigid body 1, generate a new common area according to the areas of rigid body 1 and rigid body 2 as the common node of node 1 and node 2;

[0066] (c) Repeat step b) until all nodes are added to the AABB tree, and use the region corresponding to the root node of the AABB tree as the collision region.

[0067] 2. Construct the Z - space filling curve (Z - SFC) and index. The Z - space filling curve (Z - SFC) technology is easy to implement and highly parallelizable, and can be used to effectively linearize regions in two - dimensional or three - dimensional space. Assume that in a D - dimensional space, each dimension of the space is evenly divided into k parts, then there will be 2 dk equal non - overlapping small space units. For example, using the Z - space filling curve (Z - SFC) to divide a two - dimensional square region, the result is as Figure 3A shown; according to Figure 3A the division result, mark them in order, and the result is as Figure 3B shown:

[0068] For example, after dividing the rigid bodies 1 - 9 in step 1, the Figure 4 result can be obtained:

[0069] Usually, the small unit space at the lower - left corner of the division result is set as the starting point of the Z - space filling curve (Z - SFC), and Morton code encoding is performed on the region. In a two - dimensional space, assume that the coordinates of the center - of - gravity position of a rigid body P are (x, y), then these coordinates are used as the coordinates of the leaf node. After division by the Z - space filling curve (Z - SFC), the cell to which this point belongs will be For the rigid body 9 that spans multiple regions, duplicate removal operations are required. At this time, the Z - space filling curve index of the rigid body 9 is set to the region with the smallest value, that is, 11110000, and the information of these regions is saved. For example, create a Z - space filling curve index for the Figure 3A two - dimensional space shown as Figure 5 shown.

[0070] According to the Z - space filling curve (Z - SFC) index, we can create Z - space filling curves (Z - SFC) at different levels, as Figure 6 shown.

[0071] 3. Construction of a parallel compressed octree based on GPU. Different from the construction of an octree on CPU, the construction of a parallel octree based on GPU is bottom - up. According to the positions of the leaf nodes, generate internal nodes in reverse, and then determine the relationships of the internal nodes, thereby determining the structure of the tree. The process of generating the tree bottom - up is suitable for GPU parallel computing. The specific implementation process is as Figure 7 shown:

[0072] (1). Construct leaf nodes

[0073] (a) Use the rigid bodies 1-9 to be detected as input points, and use an array A with a length of 2n-1 (n represents the number of rigid bodies) to store these 9 input points as leaf nodes.

[0074] (b) Generate a Z-space filling curve (Z-SFC) index based on the coordinates of the leaf nodes.

[0075] (c) According to the Z-space filling curve (Z-SFC) index of the leaf nodes, sort the 9 elements in array A in parallel.

[0076] (2). Generate the post-order traversal of the internal nodes and the octree: For each pair of adjacent leaves, use the common bits in the Z-space filling curve (Z-SFC) index to find the lowest common ancestor (LCA) in parallel. For example, the Z-space filling curve (Z-SFC) indexes of adjacent leaf nodes 1 and 2 are 11000001 and 11000010 respectively, and the lowest common ancestor of nodes 1 and 2 can be obtained as 11000000.

[0077] (a) Allocate n-1 GPU threads.

[0078] (b) For each pair of adjacent leaves in array A (such as A[i] and A[i+1]), generate the lowest common ancestor in parallel. The Z-space filling curve index of its lowest common node is the largest common part of the Z-space filling curve indexes of leaf nodes A[i] and A[i+1], and store its value in A[n+i].

[0079] (c) According to the Z-space filling curve index of the common node, sort the internal nodes at different levels in parallel. If element L1 is included in element L2, place element L2 before element L1; otherwise, place element L1 before element L2. Figure 7 (c) in shows the sorted internal nodes, where duplicates (N2 and N3) may be generated.

[0080] (d) In the second half of array A, delete the duplicates.

[0081] (e) For two adjacent internal nodes without the same Z-space filling curve (Z-SFC) index, traverse the second half of array A starting from the current node in parallel and delete their duplicate items. Sort array A in parallel according to the Z-space filling curve (Z-SFC) index, and then the post-order traversal of the compressed octree can be obtained.

[0082] (3). Generate a compressed octree. We can notice that there may be some empty elements at the end of array A. This is inevitable because CUDA does not support dynamic memory allocation and deallocation, so an array of size 2n - 1 must be created at compile time. However, just getting the post-order traversal of the octree is not enough to determine the tree structure. Figure 8 In the case shown in (a) of Figure 8 , nodes A and B are at the same level, so their common parent node is C; Figure 8 In the case shown in (b) of Figure 8 , node B is a child node of node N and is an adjacent node to node A. Figure 8 In the case shown in (c) of Figure 8 , node B is the parent node of node A.

[0083] To further determine the internal structure of the octree, perform the following steps:

[0084] (a) Allocate an array B of twice the size of the number of leaf and internal nodes (at most 4n - 2). Copy array A to array B.

[0085] (b) Allocate (number of leaf nodes + number of internal nodes - 1) GPU threads.

[0086] (c) For every two adjacent nodes in the first half of array B, generate the lowest common parent node in parallel according to the Z - space filling curve (Z - SFC) index. For example, for every two adjacent leaf nodes B[i] and B[i + 1] in array B, generate an internal node in parallel and store it in B[n + i]. The result is as shown in Figure 7 (f) of Figure 7 .

[0087] (d) Sort the generated results in parallel according to the Z - space filling curve (Z - SFC) index, and merge all the internal nodes and their copies together. The result is as shown in Figure 7 (g) of Figure 7 .

[0088] (e) For nodes with the same Z - space filling curve (Z - SFC) index and at least one of which is not a copy, establish the parent - child relationship of the internal nodes ( Figure 7 in (h) of Figure 7 and Figure 7 in (i) of Figure 7 ). The finally generated compressed octree is as shown in Figure 9 :

[0089] 4. Recover the complete octree from the compressed octree. As shown in Figure 9Two adjacent nodes, node N4 and node 3, are shown, where node 3 is a child node of node N4. The depth difference between the two nodes is calculated through the Z - space filling curve (Z - SFC) index. For example, if the Z - space filling curve (Z - SFC) indices of node N4 and node 3 are 11000000 and 11001101 respectively, the depth difference is 2 (assuming the root depth is 0, node N4 is at depth 1 and node 3 is at depth 3). This difference indicates that intermediate nodes between node N4 and node 3 are missing in the compressed octree, as Figure 10 shown.

[0090] To generate a complete octree structure, the following steps are performed:

[0091] (a) Allocate threads with a size equal to the length of array A, that is, (the number of leaf nodes + the number of internal nodes).

[0092] (b) Calculate the depth difference between each node and its parent node and accumulate it to obtain the total memory required to insert internal nodes (since dynamic memory allocation cannot be performed on the GPU).

[0093] (c) Add new nodes according to the depth difference between each node and its parent node. When the depth difference is greater than 1, insert new nodes in parallel in the middle. As Figure 11 shown, an internal node CH1 is inserted between node N4 and node 3 to obtain a complete octree structure.

[0094] 5. Use the octree structure to perform parallel collision detection on rigid bodies from bottom to top. As Figure 12 shown, start the detection from the leaf nodes from bottom to top. When a collision point is found, further perform fine - grained detection until the pair of leaf nodes where the collision occurs is found.

[0095] (a) Assume that a collision occurs between rigid body 2 and rigid body 3. For the rigid bodies to be detected for collision, calculate all the octree levels and corresponding leaf nodes of the rigid bodies, and use the octree to query the AABB bounding boxes of all overlapping regions of the corresponding rigid bodies from bottom to top in step 4.

[0096] (b) If a collision bounding box is found, further perform precise collision detection on the boundaries of rigid body 2 and rigid body 3 for the AABB bounding boxes obtained in step (a) above. The result is as Figure 13 shown.

[0097] The above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit them. Those of ordinary skill in the art can modify or equivalently replace the technical solutions of the present invention without departing from the spirit and scope of the present invention. The protection scope of the present invention shall be subject to the claims.

Claims

1. A parallel rigid body collision detection method based on a sparse octree, the steps of which include: 1) Construct a bounding box tree according to the rigid bodies to be collision - detected, generate a collision region based on the root node of the bounding box tree, divide the collision region, encode each obtained small - unit space, and generate the index of each small - unit space; 2) Construct the leaf nodes of the compressed octree based on the center of gravity of the rigid bodies to be collision - detected and the indexes of each small - unit space; wherein, constructing the leaf nodes of the compressed octree based on the center of gravity of the rigid bodies to be collision - detected and the indexes of each small - unit space includes: Obtain the center of gravity of the rigid bodies to be collision - detected to get the coordinates of the leaf nodes; Express the coordinates of the leaf nodes in index form according to the indexes of each small - unit space; Save the leaf node coordinates in index form in an array A with a length of 2n - 1, where n is the number of rigid bodies P i to be collision detected; Sort the n elements in array A according to the leaf nodes in index form, and construct the leaf nodes of the compressed octree; 3) Take the lowest common parent node of two adjacent leaf nodes as an internal node, perform parallel sorting on the internal nodes of different layers, generate the post - order traversal of the compressed octree, and combine the internal nodes with the post - order traversal of the compressed octree to generate the compressed octree; 4) Obtain the intermediate nodes by calculating the depth difference between each node in the compressed octree and its parent node, and generate the complete octree; 5) Start querying the overlapping regions from the leaf nodes of the complete octree from bottom to top, and find the pairs of leaf nodes that collide.

2. The method according to claim 1, characterized in that, The bounding box tree includes: an axis - parallel bounding box tree and an oriented bounding box tree; the bounding box tree is constructed through the following steps: 1) Reconstruct the contour of each rigid body P to be collision-detected, where i is the serial number of the rigid body to be collision-detected; i ​ 2) Use the rigid body P1 to be collision - detected as the root node of the bounding - box tree, and use other rigid bodies P i to be collision - detected as a node of the bounding - box tree; 3) Determine whether there is an intersection in the regions where the rigid body P1 to be collision-detected and other rigid bodies P to be collision-detected are located; i are located; 4) If there is an intersection and the other rigid body P to be collision-detected i has an intersection with a subset of the rigid body P1 to be collision-detected, then add the corresponding nodes of the other rigid body P to be collision-detected i after the smallest common sub-node of the subset of the corresponding nodes of the rigid body P1 to be collision-detected; if there is no intersection, then generate a common area according to the rigid body P1 to be collision-detected and the other rigid body P to be collision-detected i and generate common nodes.

3. The method according to claim 1, wherein The method for dividing the collision region includes: Z - space filling curve.

4. The method according to claim 1, wherein The method for encoding includes: Morton code.

5. The method according to claim 1, wherein The post - order traversal of the compressed octree is obtained through the following steps: 1) Allocate n - 1 GPU threads; 2) For the internal nodes generated from two adjacent leaf nodes A[i] and A[i + 1] in the first half of array A, store them in array A[n + i]; 3) According to the indexes of each small - unit space, perform parallel sorting on the internal nodes of different layers and delete the duplicates in the second half of array A; for every two adjacent internal nodes without the same index, traversing the second half of array A starting from the current node in parallel and deleting the duplicates; 4) Perform parallel sorting on array A according to the indexes of each small - unit space to obtain the post - order traversal of the compressed octree.

6. The method according to claim 1, wherein The compressed octree is generated through the following steps: 1) Allocate array B with twice the size of array A, and copy the data in array A to array B; 2) Allocate p + q - 1 GPU threads, where p is the number of leaf nodes and q is the number of internal nodes; 3) For every two adjacent leaf nodes B[i] and B[i + 1] in the first half of array B, generate internal nodes in parallel and store them in B[n + i]; 4) Perform parallel sorting on the generation results according to the indexes of the small - unit space; 5) For the nodes with the same index and at least one of which is not a duplicate, establish the parent - child relationship of the internal nodes to generate the compressed octree.

7. The method according to claim 1, characterized in that, The complete octree is generated through the following steps: 1) Allocate threads with a length not less than that of array A; 2) Calculate the depth difference between each node and its parent node and accumulate it to obtain the total memory required for inserting internal nodes; 3) Calculate the depth difference between each node and its parent node in parallel, and when the depth difference is greater than a set threshold, insert intermediate nodes between each node and its parent node in parallel to generate a complete octree.

8. A storage medium storing a computer program therein, wherein, The computer program is configured to perform the method according to any one of claims 1-7 when running.

9. An electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to perform the method according to any one of claims 1-7.

Citation Information

Patent Citations

  • Method for processing cosmically complex three-dimensional scene based on eight-fork tree

    CN101281654A

  • Mechanical arm collision detection method

    CN112179602A