Spatial approaching inspection method of model and related device
By using CUDA parallel computing on the GPU, the proximity check of objects in three-dimensional scenes is solved, and the traditional method requires high CPU computing capabilities is achieved, and efficient and real-time model proximity check is achieved.
Patent Information
- Application Number
- CN202411931358.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-26
- Publication Date
- 2025-04-18
AI Technical Summary
Traditional model proximity inspection methods require high CPU computing capabilities, resulting in performance problems in large gaming worlds.
By utilizing the powerful ability of CUDA parallel computing, we can check the proximity of a large number of objects in complex three-dimensional scenarios, and use the GPU to judge the intersection of voxel mesh and patches.
It significantly reduces computing time, improves the efficiency of model proximity checking, can quickly adapt to dynamic scene changes and provide real-time response capabilities without high computing power requirements for the CPU.
Smart Images

Figure CN119850711A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a spatial proximity inspection method for a model and a related device. Background Art
[0002] In the fields of game development, computer graphics, and virtual reality (VR), model proximity checking is a critical task. As the complexity of games and virtual scenes continues to increase, the number and details of 3D models are also increasing. Model overlap checking is to determine whether two or more 3D objects are close in space. Traditional model proximity checking methods usually rely on CPU (Central Processing Unit) serial calculations, such as fast elimination methods based on axis-aligned bounding boxes (AABBs), triangle collision detection, octrees or BVH (bounding volume hierarchy), etc. However, all of the above methods involve complex linear algebra calculations and mathematical operations, so they require high CPU computing power. In large game worlds, this may lead to performance issues. Summary of the invention
[0003] The embodiments of the present application provide a spatial proximity check method and related device for a model, which fully utilizes the powerful capabilities of CUDA parallel computing to achieve proximity checks on a large number of objects in complex three-dimensional scenes, significantly reduce calculation time, and do not require high computing power from the CPU.
[0004] The embodiments of the present application can be implemented as follows:
[0005] In a first aspect, an embodiment of the present application provides a spatial proximity inspection method for a model, which is applied to a GPU, and the method includes:
[0006] Determine a plurality of target models in a target space, and obtain geometric data of each target model, wherein the target space is divided into a plurality of voxel grids, the voxel grids are cubes, the target model includes a plurality of facets, and the geometric data includes position information of each facet of the target model;
[0007] By computing unified device architecture CUDA parallel operations, it is determined whether each face of the multiple target models intersects with each voxel grid to obtain a check result, wherein the check result is used to indicate whether any model among the multiple target models is close.
[0008] In a second aspect, an embodiment of the present application provides a spatial proximity inspection method for a model, which is applied to an inspection device, wherein the inspection device includes a GPU and a CPU that are communicatively connected, and the method includes:
[0009] The GPU determines a plurality of target models in a target space, and obtains geometric data of each target model, wherein the target space is divided into a plurality of voxel grids, the voxel grids are cubes, the target model includes a plurality of face patches, and the geometric data includes position information of each face patch of the target model;
[0010] The GPU determines whether each face of the multiple target models intersects with each voxel grid through CUDA parallel computing to obtain a check result, wherein the check result is used to indicate whether any model among the multiple target models is close;
[0011] The CPU receives the inspection result sent by the GPU, and analyzes the inspection result to obtain an analysis result, wherein the analysis result includes whether a model among the multiple target models is approaching or no model is approaching.
[0012] In a third aspect, an embodiment of the present application provides a spatial proximity inspection device for a model, which is applied to a GPU, and the device includes:
[0013] An information determination module, used for determining a plurality of target models in a target space, and obtaining geometric data of each target model, wherein the target space is divided into a plurality of voxel grids, the voxel grids are cubes, the target model includes a plurality of facets, and the geometric data includes position information of each facet of the target model;
[0014] The checking module is used to determine whether each face of the multiple target models intersects with each voxel grid through CUDA parallel computing to obtain a checking result, wherein the checking result is used to indicate whether any model among the multiple target models is close.
[0015] In a fourth aspect, an embodiment of the present application provides an electronic device, including a GPU and a memory, wherein the memory stores machine executable instructions that can be executed by the GPU, and the GPU can execute the machine executable instructions to implement the spatial proximity inspection method of the model described in the aforementioned embodiment.
[0016] In a fifth aspect, an embodiment of the present application provides a readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the spatial proximity inspection method of the model as described in the aforementioned embodiment is implemented.
[0017] The spatial proximity inspection method and related device of the model provided in the embodiment of the present application, the GPU first determines multiple target models in the target space, and obtains the geometric data of each target model, the target space is divided into multiple voxel grids, the voxel grid is a cube, the target model includes multiple facets, and the geometric data includes the position information of each facet of the target model; then, through CUDA parallel computing, it is determined whether each facet of the multiple target models intersects with each voxel grid to obtain the inspection result, and the inspection result is used to indicate whether there is a model approaching in the multiple target models. In this way, by making full use of the powerful ability of CUDA parallel computing, the proximity inspection of a large number of objects in complex three-dimensional scenes is realized, and the calculation time is significantly reduced, so that it can quickly adapt to dynamic changes and provide real-time response capabilities of the system, and there is no need to have high computing power requirements on the CPU. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0019] Figure 1 A block diagram of an electronic device provided in an embodiment of the present application;
[0020] Figure 2 One of the flow charts of the spatial proximity inspection method of the model provided in the embodiment of the present application;
[0021] Figure 3 for Figure 2 One of the flowchart diagrams of the sub-steps included in step S120;
[0022] Figure 4 A second flow chart of a spatial proximity inspection method for a model provided in an embodiment of the present application;
[0023] Figure 5 for Figure 2 The second flowchart of the sub-steps included in step S120;
[0024] Figure 6 A third flowchart of the spatial proximity inspection method for a model provided in an embodiment of the present application;
[0025] Figure 7 A fourth flowchart of the spatial proximity inspection method for a model provided in an embodiment of the present application;
[0026] Figure 8One of the schematic block diagrams of the spatial proximity inspection device of the model provided in the embodiment of the present application;
[0027] Fig. 9 The second block diagram of the spatial proximity inspection device of the model provided in the embodiment of the present application.
[0028] Icons: 100 - electronic device; 110 - memory; 120 - GPU; 130 - communication unit; 200 - spatial proximity inspection device of the model; 210 - information determination module; 220 - inspection module; 230 - processing module. DETAILED DESCRIPTION
[0029] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations.
[0030] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for which protection is sought, but merely represents selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application.
[0031] It should be noted that relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0032] The following is an explanation of the terms involved in this article.
[0033] CUDA (Compute Unified Device Architecture) parallel computing: CUDA parallel computing is a computing architecture developed by NVIDIA that allows developers to use graphics processing units (GPUs) for parallel computing. With CUDA, programmers can write code that executes on the GPU, greatly accelerating computationally intensive tasks. GPUs are good at handling a large number of parallel tasks, so when large amounts of data need to be processed, CUDA parallel computing can provide higher performance than traditional CPUs.
[0034] Voxelization: Voxelization refers to the process of converting a 3D model into a voxel representation. A voxel is a volume unit in a 3D space, which can be understood as a 3D pixel. By voxelizing the model, complex geometric shapes can be divided into uniform voxel grids, thereby simplifying computational tasks such as spatial overlap checks. This representation method is widely used in computer graphics, physical simulation, and spatial analysis.
[0035] In conjunction with the accompanying drawings, some embodiments of the present application are described in detail below. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.
[0036] Please refer to Figure 1 , Figure 1 A block diagram of an electronic device 100 provided in an embodiment of the present application. The electronic device 100 may be, but is not limited to, a smart phone, a computer, a server, etc. The electronic device 100 includes a memory 110, a GPU 120, and a communication unit 130. The memory 110, the GPU 120, and the communication unit 130 are electrically connected to each other directly or indirectly to achieve data transmission or interaction. For example, these components can be electrically connected to each other via one or more communication buses or signal lines.
[0037] The memory 110 is used to store programs or data. The memory 110 may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), etc.
[0038] The GPU 120 is used to read / write data or programs stored in the memory 110 and execute corresponding functions. For example, the memory 110 stores a spatial proximity check 200 of a model, and the spatial proximity check 200 of the model includes at least one software function module that can be stored in the memory 110 in the form of software or firmware. The GPU 120 executes various functional applications and data processing by running software programs and modules stored in the memory 110, such as the spatial proximity check device 200 of the model in the embodiment of the present application, that is, realizing the spatial proximity check method of the model in the embodiment of the present application.
[0039] The communication unit 130 is used to establish a communication connection between the GPU 120 and other communication terminals through a network, and to send and receive data through the network.
[0040] It should be understood that Figure 1 The structure shown is only a schematic diagram of the structure of the electronic device 100. The electronic device 100 may also include Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown. Figure 1 Each component shown in the figure can be implemented by hardware, software or a combination thereof.
[0041] Please refer to Figure 2 , Figure 2 One of the flow diagrams of the spatial proximity checking method for a model provided in an embodiment of the present application. The method is applied to a GPU. The specific flow of the spatial proximity checking method for a model is described in detail below. In this embodiment, the method may include steps S110 to S120.
[0042] Step S110, determining a plurality of target models in the target space, and obtaining geometric data of each target model.
[0043] In this embodiment, the size of the target space is determined based on the capabilities of the GPU. The GPU can determine multiple target models in the target space in any manner and obtain the geometric data of each target model. For example, the GPU can obtain the above information by performing data analysis on itself, or the GPU can receive the above information obtained by analysis of other devices to obtain the above information. The specific manner in which the GPU determines the target model and obtains the geometric data of the target model is not limited here. Among them, since the size of the target space is limited, the target model in the target space may be a complete model or a partial model of a complete model, which is specifically determined by the actual target space size and model size.
[0044] The target space is divided into a plurality of voxel grids, and the voxel grids are cubes. The voxel grids may be cuboids or cubes, which may be determined according to actual needs. The target model includes a plurality of facets, and the geometric data includes position information of each facet of the target model, and the position information of a facet may be represented by the coordinates of each vertex of the facet. For example, the geometric data includes the position information of each triangular facet of the target model, and the position information of each triangular facet may be represented by the coordinates of the three vertices of the triangular facet.
[0045] Step S120 , through CUDA parallel computing, it is determined whether each face of the plurality of target models intersects with each voxel grid to obtain a check result.
[0046] The GPU can start the CUDA kernel function, allocate multiple thread blocks, and then determine whether each face of the multiple target models intersects with each voxel grid through parallel operations of multiple thread blocks to obtain the inspection result. In the parallel operation process, each thread block can be responsible for checking a part of the face and a part of the voxel grid respectively, and the inspection result can be quickly obtained through multi-threaded parallel operations. It can be understood that if a thread block checks whether a face intersects with a voxel grid, the thread block and other thread blocks will no longer check whether the face intersects with the voxel grid. The inspection result is used to indicate whether any model in the multiple target models is close.
[0047] In this way, by using the high parallel computing characteristics of the GPU to perform close inspections of complex models, the calculation time can be significantly reduced, thereby quickly adapting to dynamic changes and providing real-time responsiveness of the system without requiring high computing power from the CPU.
[0048] As a possible implementation manner, the CPU may determine multiple target models in the target space through data preprocessing, obtain geometric data of each target model, and send the above information to the GPU.
[0049] The CPU may first determine whether the size of the scene is greater than the size of the target space. The scene uses a world coordinate system, and the scene includes models (i.e., objects). If the size of the scene is less than or equal to the size of the target space, that is, the target space can accommodate the scene, then all models in the scene can be used as target models.
[0050] If the size of the scene is larger than the size of the target space, the target space is moved in the scene. When the target space is at its current position, determine whether the model in the scene intersects with the target space. Optionally, the CPU can read the original geometric data of each model in the scene, and determine the bounding box of each model based on the original geometric data of each model. If the bounding box of a model intersects with the current target space, it can be determined that the model intersects with the target space; conversely, if the bounding box of a model does not intersect with the current target space, it can be determined that the model does not intersect with the target space. Among them, the original geometric data of a model may include the position information of each facet of the model in the world coordinate system.
[0051] In the case where at least two models intersect with the target space, multiple target models in the target space can be determined based on the multiple models intersecting with the target space, and then a proximity check can be performed on the multiple target models. For example, among the multiple models intersecting with the target space, if one model is entirely in the target space, the model can be directly used as one target model; if one model is partially in the target space, the local model in the target space can be used as one target model. The above method is only an example, and the specific method can be determined in combination with actual needs. In the case where only one or no model intersects with the target space, the target space can continue to be moved to determine the target model. In this way, by dividing the scene according to the size of the target space, and then judging whether a model proximity check is needed for each local scene, and if necessary, performing a check, the model proximity check of the entire scene can be completed.
[0052] For example, the size of the scene is 10000×10000×10000, the lower left corner is the origin, and the size of the target space is 100×100×100. Then, the lower left corner of the target space can be aligned with the origin of the world coordinate system of the scene, and then it is determined whether the current target space intersects with multiple models, and if so, multiple target models are determined, and then a spatial proximity check is performed on multiple target models. After that, the lower left corner of the target space can be aligned with (0,100,0), (0,200,0), etc. in the world coordinate system of the scene in turn, thereby completing the model proximity check for the entire scene.
[0053] When multiple target models are determined to be in the target space, for each target model, based on the original geometric data of the model, the coordinate system used by the original geometric data of the target model can be changed from the world coordinate system to the local coordinate system of the target space through coordinate system conversion, and the converted data can be used as the geometric data of the target model. This facilitates the subsequent intersection check between the face patch and the voxel grid.
[0054] The target space is the space to be voxelized. The number of voxel grids can be determined in advance according to the size of the video memory, the size of the scene, and the accuracy requirements, and then the target space is voxelized. The accuracy requirement refers to the accuracy of the proximity inspection. For example, if the distance is less than 2 meters, the length, width and height of the voxel grid are all less than 2 meters.
[0055] The CPU can initialize an initial inspection result based on the number of voxel grids in the target space, which is used to record the intersection of the face patch and the voxel grid. The initial inspection result can be represented by an array. The CPU can transmit the position information of each voxel grid, the geometric data of each target model, the initial inspection result, etc. to the GPU through the PCIe bus. At this time, the data structure is converted from the array in the CPU memory to the global memory in CUDA for parallel calculation on the GPU. The GPU can adjust the content in the initial inspection result according to the inspection situation to obtain the inspection result. Among them, the position information of each voxel grid can send specific position coordinates (the coordinates use the local coordinate system of the target space), or the size of the target space, the voxel grid size, etc. can be sent to indicate the position information of each voxel grid.
[0056] Optionally, as another possible implementation, the GPU may determine multiple target models in the target space through data preprocessing, obtain geometric data of each target model, and may also obtain an initial inspection result through initialization.
[0057] In this method, when the size of the scene is larger than the size of the target space, the GPU may move the target space in the scene, and when the target space is at the current position in the scene, determine whether each model in the scene intersects with the target space; if at least two models intersect with the target space, determine the multiple target models based on the multiple models intersecting with the target space. When multiple target models are determined to be in the current target space, the original geometric data of each target model may be converted to the local coordinate system used by the target space through coordinate system conversion to obtain the geometric data of each target model.
[0058] Optionally, as a possible implementation, Figure 3The inspection results are obtained in the manner shown. Figure 3 , Figure 3 for Figure 2 One of the flowcharts of the sub-steps included in step S120 of FIG. 1. In this embodiment, step S120 may include sub-steps S121 to S123.
[0059] Sub-step S121, obtaining a first initial inspection result obtained through initialization.
[0060] In this embodiment, the initial inspection result obtained by initialization is used as the first initial inspection result. The first initial inspection result includes multiple initial information sets, one initial information set corresponds to one voxel grid, one initial information set includes multiple first initial values, and the number of initial values in one initial information set is the same as the number of target models. The first initial inspection result can be used to record the filling status of each target model in each voxel grid. The first initial value can be determined in combination with actual needs and is not specifically limited here.
[0061] For example, the first initial inspection result is a two-dimensional buffer array, the number of elements of the buffer array is equal to the number of voxel grids, and the number of bits of each element of the buffer array is equal to the number of target models. For example, if the multiple target models currently determined are model A and model B, then each element of the buffer array is two bits, and the buffer array is used to record the filling status of model A and model B in each voxel grid.
[0062] Sub-step S122, when it is determined that a voxel grid intersects with a patch of a target model, updating the first initial value corresponding to the voxel grid and the target model in the current first initial inspection result to the first value.
[0063] Sub-step S123, when it is determined that a voxel grid does not intersect with a patch of a target model, the first initial value corresponding to the voxel grid and the target model in the current first initial inspection result is updated to a second value.
[0064] In this embodiment, for each first initial value corresponding to each voxel grid, the GPU thread can update the first initial value according to the geometric data of the multiple target models, thereby obtaining the inspection result. The CUDA kernel can project the face of each target model into the corresponding voxel grid, and optimize the access efficiency of the voxel grid through shared memory, so as to quickly update the first initial inspection result to quickly obtain the inspection result.
[0065] Through the parallel operation of CUDA, when it is determined that a voxel grid intersects with a patch of a target model, the first initial value corresponding to the voxel grid and the target model in the current first initial inspection result can be updated to a first value used to indicate the intersection. When it is determined that a voxel grid does not intersect with a patch of a target model, the first initial value corresponding to the voxel grid and the target model in the current first initial inspection result can be updated to a second value used to indicate the non-intersection. The first value and the second value can be specifically determined in combination with actual needs. For example, the first value is 1, and the second value is 0. The first initial inspection result at the end of the operation is the inspection result, that is, after completing the intersection check of each patch of the multiple target models and each voxel grid, the inspection result can be obtained. The inspection result is the first initial inspection result after all voxel grids are processed.
[0066] For example, the multiple target models currently determined are model A and model B, and the first initial inspection result is a buffer array, each element of which is two bits; if the geometric information of model A is filled into a certain voxel grid (that is, it intersects with a certain voxel grid), the GPU can set the first bit (bit 0) of the buffer of the voxel grid to 1; if the geometric information of model B is filled into a certain voxel grid, the GPU sets the second bit (bit 1) of the buffer of the voxel grid to 1.
[0067] Please refer to Figure 4 , Figure 4 The second flowchart of the spatial proximity inspection method of the model provided in the embodiment of the present application is as follows: When step S120 includes sub-steps S121 to S123, the method may further include step S131.
[0068] Step S131, obtaining a first analysis result according to the number of first values in each information set in the inspection result; or, sending the inspection result to a CPU so that the CPU obtains the first analysis result based on the inspection result.
[0069] In this embodiment, after obtaining the inspection result, the GPU can count the number of first values in each information set in the inspection result; if the number of first values in the information set is greater than or equal to 2, the state of the voxel grid corresponding to the information set can be marked as "close". For example, continuing with the above example about model A and model B, if the first and second bits in the buffer of a voxel grid are both 1, the GPU will mark this voxel grid as "close".
[0070] Optionally, when the number of voxel grids with a status of "close" is greater than 1, it can be determined that there is a spatially close model among the multiple target models, that is, there is a target model approaching. The specific number of voxel grids with a status of "close" can also be counted, the position distribution of the voxel grids with a status of "close" can also be obtained, and the model identification of the target model with a spatially close relationship can also be obtained. For example, continuing with the above example about model A and model B, if the first and second bits in the buffer of a certain voxel grid are both 1, it can be determined that model A and model B are in a spatially close relationship.
[0071] In this way, the GPU can obtain a first analysis result through the above analysis. The first analysis result includes at least one of whether there is a target model approaching, the total number of voxel grids in the approaching state, the distribution of voxel grids in the approaching state, and the model identification of the target model in a spatially approaching relationship. The GPU can send the above first analysis result to the CPU, and the CPU can trigger corresponding events or further processing based on the above first analysis result, such as triggering collision detection, generating alarms, or planning paths.
[0072] Alternatively, after obtaining the inspection result, the GPU may send the inspection result to the CPU. After the CPU performs the same analysis, it may obtain the first analysis result, and then trigger a corresponding event or further processing, such as triggering collision detection, generating an alarm, or planning a path.
[0073] Alternatively, as another possible implementation, Figure 5 The inspection results are obtained in the manner shown. Figure 5 , Figure 5 for Figure 2 FIG. 2 is a flow chart of sub-steps included in step S120 of FIG. 1. In this embodiment, step S120 may include sub-steps S125 to S126.
[0074] Sub-step S125, obtaining a second initial inspection result obtained through initialization.
[0075] In this embodiment, the initial inspection result obtained by initialization is used as the second initial inspection result. The second initial inspection result includes multiple initial information, one initial information corresponds to a voxel grid, and one initial information includes a second initial value. The second initial inspection result can be used to subsequently record the filling status of the multiple target models in each voxel grid. The second initial value can be determined in combination with actual needs, such as being set to 0, and is not specifically limited here.
[0076] Sub-step S126, when it is determined that a voxel grid intersects with a patch of a target model, the value in the information corresponding to the voxel grid in the current second initial inspection result is updated by adding 1.
[0077] In this embodiment, when the GPU determines that a voxel grid intersects with a patch of a target model, the GPU may update the value in the information corresponding to the voxel grid of the current second initial inspection result by adding 1 to indicate that the voxel grid has been filled once with a patch of a target model. When the GPU determines that a voxel grid does not intersect with a patch of a target model, it may not perform any processing and make an intersection judgment on the next group of objects (the voxel grids and patches included in the next group of objects are different from the voxel grid and the patch of a target model this time). The second initial inspection result at the end of the operation is the inspection result. Among them, due to multi-threaded parallel operation, when the value is updated by adding 1, atomicAdd can be used to ensure the accuracy of the value in the information.
[0078] For example, the second initial check result is a buffer array, the number of elements in the buffer array is equal to the number of voxel grids, and the value of each element in the buffer array is a numerical value, which is initially 0. The type of the element can be uint8. In subsequent checks, for a certain voxel grid, each time it is determined that the voxel grid intersects with a patch, an operation is added to the numerical value, so that the numerical value at the end of the operation can be used to represent the number of times the voxel grid corresponding to the element is filled by multiple target models.
[0079] Please refer to Figure 6 , Figure 6 The third flowchart of the spatial proximity inspection method of the model provided in the embodiment of the present application: In the case where step S120 includes sub-steps S125 and S126, the method may further include step S133.
[0080] Step S133, for each information in the inspection result, determine whether the value in the information is greater than a preset value. If greater than, mark the state of the voxel grid corresponding to the information as close, and obtain the second analysis result based on the voxel grid with the state of close; or, send the inspection result to the CPU, so that the CPU obtains the second analysis result based on the inspection result.
[0081] In this embodiment, after obtaining the inspection result, the GPU may determine whether the value in each information in the inspection result is greater than a preset value. The preset value is the sum of the second initial value and 1. If the value in a piece of information is greater than the preset value, it may be determined that the state of the voxel grid corresponding to the information is marked as "close".
[0082] Optionally, when the number of voxel grids in the "close" state is greater than 1, it can be determined that there is a spatially close model among the multiple target models, that is, there is a target model close. The specific number of voxel grids in the "close" state can also be obtained by counting, and the position distribution of the voxel grids in the "close" state can also be obtained.
[0083] In this way, the GPU can obtain a second analysis result through the above analysis. The second analysis result includes at least one of whether there is a target model approaching, the total number of voxel grids in the approaching state, and the distribution of voxel grids in the approaching state. The GPU can send the above second analysis result to the CPU, and the CPU can trigger corresponding events or further processing based on the above second analysis result, such as triggering collision detection, generating alarms, or planning paths.
[0084] Alternatively, after obtaining the inspection result, the GPU may send the inspection result to the CPU. After the CPU performs the same analysis, it may obtain the second analysis result, and then trigger a corresponding event or further processing, such as triggering collision detection, generating an alarm, or planning a path.
[0085] The spatial proximity check method of the above-mentioned model provided in this embodiment has the following characteristics: improving the computational efficiency of proximity check: by making full use of the powerful capabilities of CUDA parallel computing, real-time proximity check of a large number of objects in complex three-dimensional scenes is realized, significantly reducing the calculation time; quickly adapting to dynamic scene changes: being able to efficiently handle dynamic proximity relationships and quickly adapt to the movement and changes of objects in the scene; improving the real-time response capability of the system: ensuring that in complex and high-density three-dimensional scenes, the system can quickly respond to the proximity relationship between objects, thereby triggering appropriate behaviors or events.
[0086] Please refer to Figure 7 , Figure 7 The fourth flowchart of the spatial proximity inspection method of the model provided in the embodiment of the present application is shown in FIG. The method is applied to an inspection device, and the inspection device includes a GPU and a CPU connected in communication. In this embodiment, the method may include steps S210 to S230.
[0087] In step S210, the GPU determines a plurality of target models in the target space, and obtains geometric data of each target model.
[0088] The target space is divided into a plurality of voxel grids, the voxel grids are cubes, the target model includes a plurality of facets, and the geometric data includes position information of each facet of the target model.
[0089] In step S220, the GPU determines whether each face of the plurality of target models intersects with each voxel grid through CUDA parallel computing to obtain a check result.
[0090] Wherein, the inspection result is used to indicate whether any model among the multiple target models is close;
[0091] Step S230: the CPU receives the inspection result sent by the GPU, and analyzes the inspection result to obtain an analysis result.
[0092] The analysis result includes whether there are models approaching or no models approaching among the multiple target models. The analysis result obtained by the CPU through analysis may be the first analysis result or the second analysis result mentioned above. For the specific description of steps S210 to S230, please refer to the previous description of the spatial proximity check of the model applied to the CPU, which will not be repeated here. This method is based on the GPU to perform model proximity check. Since the GPU naturally supports large-scale parallel computing, it can perform intersection analysis on different patches and voxel grids at the same time, which is particularly useful in large-scale game worlds and helps to reduce calculation time and improve real-time performance.
[0093] In order to perform the corresponding steps in the above embodiments and various possible methods, a method for implementing the spatial proximity inspection device 200 of a model is provided below. Optionally, the spatial proximity inspection device 200 of the model can adopt the above Figure 1 Please refer to the device structure of the electronic device 100 shown in FIG. Figure 8 , Figure 8 One of the block diagrams of the spatial proximity inspection device 200 of the model provided in the embodiment of the present application. It should be noted that the basic principle and technical effects of the spatial proximity inspection device 200 of the model provided in this embodiment are the same as those of the above-mentioned embodiments. For the sake of brief description, for the parts not mentioned in this embodiment, reference can be made to the corresponding contents in the above-mentioned embodiments. In this embodiment, the spatial proximity inspection device 200 of the model may include: an information determination module 210 and an inspection module 220.
[0094] The information determination module 210 is used to determine multiple target models in the target space and obtain geometric data of each target model. The target space is divided into multiple voxel grids, each voxel grid is a cube, the target model includes multiple facets, and the geometric data includes position information of each facet of the target model.
[0095] The checking module 220 is used to determine whether each face of the plurality of target models intersects with each voxel grid through CUDA parallel computing to obtain a checking result, wherein the checking result is used to indicate whether any model among the plurality of target models is close.
[0096] Please refer to Fig. 9 , Fig. 9 The second block diagram of the spatial proximity inspection device 200 of the model provided in the embodiment of the present application. The spatial proximity inspection device 200 of the model may include a processing module 230. The processing module 230 is used to analyze the inspection result to obtain an analysis result; or send the inspection result to the CPU so that the CPU obtains the analysis result through analysis.
[0097] Optionally, the above modules can be stored in the form of software or firmware. Figure 1 The memory 110 shown in the figure may be fixed in the operating system (OS) of the electronic device 100 and may be Figure 1 Meanwhile, the data and program codes required for executing the above modules may be stored in the memory 110.
[0098] An embodiment of the present application also provides a readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the spatial proximity inspection method of the model is implemented.
[0099] In summary, the embodiment of the present application provides a spatial proximity check method and related device for a model. The GPU first determines multiple target models in the target space and obtains the geometric data of each target model. The target space is divided into multiple voxel grids, and the voxel grids are cubes. The target model includes multiple facets, and the geometric data includes the position information of each facet of the target model. After that, through CUDA parallel computing, it is determined whether each facet of the multiple target models intersects with each voxel grid to obtain a check result, which is used to indicate whether there is a model approaching among the multiple target models. In this way, by making full use of the powerful capabilities of CUDA parallel computing, proximity checks on a large number of objects in complex three-dimensional scenes are realized, and the computing time is significantly reduced, so that it can quickly adapt to dynamic changes and provide real-time response capabilities of the system, and there is no need to have high computing power requirements on the CPU.
[0100] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0101] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0102] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0103] The above description is only an optional embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A spatial proximity inspection method for a model, characterized in that: Applied to a GPU, the method comprises: Determine a plurality of target models in a target space, and obtain geometric data of each target model, wherein the target space is divided into a plurality of voxel grids, the voxel grids are cubes, the target model includes a plurality of facets, and the geometric data includes position information of each facet of the target model; By computing unified device architecture CUDA parallel operations, it is determined whether each face of the multiple target models intersects with each voxel grid to obtain a check result, wherein the check result is used to indicate whether any model among the multiple target models is close.
2. The method according to claim 1, characterized in that The determining, by CUDA parallel computing, whether each face of the plurality of target models intersects with each voxel grid to obtain a check result includes: Obtaining a first initial inspection result obtained by initialization, wherein the first initial inspection result includes a plurality of initial information sets, one initial information set corresponds to a voxel grid, one initial information set includes a plurality of first initial values, and the number of initial values in one initial information set is the same as the number of target models; When it is determined that a voxel grid intersects with a patch of a target model, updating a first initial value corresponding to the voxel grid and the target model in the current first initial inspection result to a first value; When it is determined that a voxel grid does not intersect a face of a target model, the first initial value corresponding to the voxel grid and the target model in the current first initial inspection result is updated to a second value, wherein the first initial inspection result at the end of the operation is the inspection result.
3. The method according to claim 2, characterized in that The method further comprises: A first analysis result is obtained according to the number of first values in each information set in the inspection result, wherein the first analysis result includes at least one of whether there is a target model approaching, the total number of voxel grids in a state of approaching, the distribution of voxel grids in a state of approaching, and a model identifier of a target model in a spatially approaching relationship, and at least two first values exist in the information set corresponding to the voxel grids in a state of approaching; or The inspection result is sent to a CPU, so that the CPU obtains the first analysis result based on the inspection result.
4. The method according to claim 1, characterized in that The determining, by CUDA parallel computing, whether each face of the plurality of target models intersects with each voxel grid to obtain a check result includes: Obtaining a second initial inspection result obtained by initialization, wherein the second initial inspection result includes a plurality of pieces of initial information, one piece of initial information corresponds to one voxel grid, and one piece of initial information includes one second initial value; When it is determined that a voxel grid intersects with a face of a target model, the value in the information corresponding to the voxel grid in the current second initial inspection result is updated by adding 1, wherein the second initial inspection result at the end of the operation is the inspection result.
5. The method according to claim 4, characterized in that The method further comprises: For each information in the inspection result, determine whether a value in the information is greater than a preset value, wherein the preset value is the sum of the second initial value and 1; If it is greater than, the state of the voxel grid corresponding to the information is marked as close; Obtain a second analysis result according to the voxel grids in the state of being close, wherein the second analysis result includes at least one of whether there is a target model close, the total number of voxel grids in the state of being close, and the distribution of voxel grids in the state of being close; or The inspection result is sent to a CPU, so that the CPU obtains the second analysis result based on the inspection result.
6. The method according to claim 1, characterized in that The determining of a plurality of target models in the target space comprises: Move the target space in the scene, and when the target space is at a current position in the scene, determine whether each model in the scene intersects with the target space; If at least two models intersect with the target space, determining the multiple target models based on the multiple models intersecting with the target space; and / or, The step of obtaining geometric data of each target model includes: By means of coordinate system conversion, the original geometric data of each target model is converted to the local coordinate system used in the target space to obtain the geometric data of each target model.
7. A spatial approach inspection method for a model, characterized in that: Applied to an inspection device, the inspection device includes a GPU and a CPU that are communicatively connected, and the method includes: The GPU determines a plurality of target models in a target space, and obtains geometric data of each target model, wherein the target space is divided into a plurality of voxel grids, the voxel grids are cubes, the target model includes a plurality of face patches, and the geometric data includes position information of each face patch of the target model; The GPU determines whether each face of the multiple target models intersects with each voxel grid through CUDA parallel computing to obtain a check result, wherein the check result is used to indicate whether any model among the multiple target models is close; The CPU receives the inspection result sent by the GPU, and analyzes the inspection result to obtain an analysis result, wherein the analysis result includes whether a model among the multiple target models is approaching or no model is approaching.
8. A model space proximity inspection device, characterized in that, Applied to a GPU, the device comprises: An information determination module, used for determining a plurality of target models in a target space, and obtaining geometric data of each target model, wherein the target space is divided into a plurality of voxel grids, the voxel grids are cubes, the target model includes a plurality of facets, and the geometric data includes position information of each facet of the target model; The checking module is used to determine whether each face of the multiple target models intersects with each voxel grid through CUDA parallel computing to obtain a checking result, wherein the checking result is used to indicate whether any model among the multiple target models is close.
9. An electronic device, characterized in that: It comprises a GPU and a memory, wherein the memory stores machine executable instructions that can be executed by the GPU, and the GPU can execute the machine executable instructions to implement the spatial proximity inspection method of the model described in any one of claims 1-6.
10. A readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the spatial proximity inspection method of the model as described in any one of claims 1 to 6 is implemented.