Method, system, server and computer readable storage medium for ray detection by using voxel data

文档序号:1959068 发布日期:2021-12-14 浏览:12次 中文

阅读说明:本技术 应用体素数据进行射线检测的方法、系统、服务器及计算机可读存储介质 (Method, system, server and computer readable storage medium for ray detection by using voxel data ) 是由 廖焕华 熊鑫 李志凯 赵浩南 于 2021-09-30 设计创作,主要内容包括:本发明提供了一种应用体素数据进行射线检测的方法、系统、服务器及计算机可读存储介质,将像素数据转化为体素数据,从而与GPU运算高度契合,相对于既有的CPU运算模式,以GPU为基础的数据运算方案性能要高2到3个数量级;使用体素数据进行高性能射线检测,用以感知环境,运算效率高。(The invention provides a method, a system, a server and a computer readable storage medium for ray detection by using voxel data, which convert pixel data into voxel data so as to be highly matched with GPU operation, and compared with the existing CPU operation mode, the performance of a data operation scheme based on GPU is 2 to 3 orders of magnitude higher; the voxel data is used for high-performance ray detection for sensing the environment, and the operation efficiency is high.)

1. A method for ray detection using voxel data, wherein a path formed by a start point and an end point is ray detected, comprising the steps of:

calculating and acquiring n points which are passed by the path in a voxel scene;

simultaneously calculating the n points to index the corresponding point of each point in the voxel scene and detecting whether the point is a solid point; if solid points are detected in the n points, outputting a first detection result; otherwise, outputting a second detection result;

and acquiring whether the path is blocked or not according to the first detection result and the second detection result.

2. The method of claim 1, applied to a pixel scene comprising scene elements of several different data types, the step of converting the pixel scene into a voxel scene comprising:

respectively deriving original data of a plurality of scene elements;

setting the side length of an expected unit voxel, and respectively converting the original data of a plurality of scene elements into voxel data by combining the side length of the unit voxel, wherein the voxel data is expressed as a voxel module in the voxel scene;

and according to the relative positions of the voxel modules of all the scene elements in the pixel scene, splicing the voxel modules of all the scene elements to obtain the voxel scene.

3. The method of claim 2, wherein the pixel scene is a game world applied in a game, the scene elements including terrain, vegetation, buildings, and outdoor furnishings;

the respectively deriving the raw data of the plurality of scene elements comprises:

exporting 3D model file format data and coordinate information of the outdoor ornament and the building;

exporting comma separated value file format data of the vegetation;

the images are taken orthogonally by a depth camera to derive a picture of the terrain, which contains surface height data of the terrain.

4. The method of claim 3, wherein the setting of the desired side length of the unit voxel, and the converting of the original data of the scene elements into voxel modules respectively according to the side lengths of the unit voxel comprises:

converting the 3D model file format data of the outdoor ornament and the building into voxel data through a read-write triangular mesh function and a slave triangular mesh creating function in an open source library;

acquiring the size of a collider of the vegetation, and calculating and acquiring the number and the shape of voxels needing to be occupied by the vegetation in the voxel scene by combining the side length of the unit voxel;

sampling point by point according to the side length of a unit voxel according to the picture storing the surface height data of the terrain to convert the surface height data of the terrain into voxel data.

5. The method of claim 1, further comprising: ray detection is carried out on the m paths in the GPU:

the m paths comprise m starting points and m end points; simultaneously calculating and acquiring n points of each path passing through in a voxel scene;

the n points in the m paths are simultaneously calculated: indexing a corresponding point of each point in the voxel scene according to coordinates in the voxel scene, and detecting whether the point is a solid point; if detecting that the n points have solid points, outputting the first detection result of the path; otherwise, outputting the second detection result of the path to obtain the detection results of the m paths.

6. The method of claim 5, further comprising:

a detection area comprises x detection targets and y nodes, and dynamic planning is carried out on the detection area, wherein the dynamic planning comprises the following steps:

simultaneously carrying out ray detection on x-y paths formed by the x detection targets and the y nodes, and storing detection results;

and calling the detection results of different paths at different times for the detection area so as to carry out the dynamic planning.

7. The method of claim 6, further comprising:

dynamically planning a plurality of detection regions, comprising:

simultaneously carrying out ray detection on x-y paths of different detection areas, storing detection results and forming a detection result table divided by the detection areas;

and when the dynamic planning is carried out on a detection area, the detection result of the detection area is called from the detection result table.

8. The method according to claim 1, characterized in that in the GPU the n points are calculated simultaneously: indexing a corresponding point of each point in the voxel scene according to coordinates in the voxel scene, and detecting whether the point is a solid point; if solid points are detected in the n points, outputting a first detection result; otherwise, outputting a second detection result.

9. A system for ray detection by using voxel data is characterized in that ray detection is carried out on a path formed by a starting point and an end point, and comprises a point capturing module, a contrast index module and a judgment module;

the point capturing module calculates n points which are passed by the acquisition path in the voxel scene;

calculating the n points simultaneously, indexing the corresponding point of each point in the voxel scene through the contrast index module, and detecting whether the point is a solid point through the judgment module; if solid points are detected in the n points, outputting a first detection result; otherwise, outputting a second detection result;

and acquiring whether the path is blocked or not according to the first detection result and the second detection result.

10. A server for ray detection by using voxel data is characterized in that ray detection is carried out on a path formed by a starting point and an end point, and the server comprises a point capturing module, a contrast index module and a judgment module;

the point capturing module calculates n points which are passed by the acquisition path in the voxel scene;

calculating the n points simultaneously, indexing the corresponding point of each point in the voxel scene through the contrast index module, and detecting whether the point is a solid point through the judgment module; if solid points are detected in the n points, outputting a first detection result; otherwise, outputting a second detection result;

and acquiring whether the path is blocked or not according to the first detection result and the second detection result.

11. A computer readable storage medium storing instructions for ray detection using voxel data, the instructions when executed performing ray detection of a path formed by a start point and an end point, comprising the steps of:

calculating and acquiring n points which are passed by the path in a voxel scene;

simultaneously calculating the n points to index the corresponding point of each point in the voxel scene and detecting whether the point is a solid point; if solid points are detected in the n points, outputting a first detection result; otherwise, outputting a second detection result;

and acquiring whether the path is blocked or not according to the first detection result and the second detection result.

Technical Field

The invention relates to the technical field of game data processing, in particular to a method, a system, a server and a computer readable storage medium for ray detection by using voxel data.

Background

At present, in order to realize parallelization of data operation requirements, a related new data structure is created, and dynamic update is rapidly carried out in real time to serve various related algorithms. The creation, updating and modification of these new data structures are also required to adapt to massive parallel acceleration.

The game scene is a set of all scene elements in a virtual space in the electronic game, and comprises contents such as map landform, buildings, game roles, equipment props and the like. The interface of the game scene seen by the game user is often displayed in a pixel scene mode, namely, the content of the game scene is displayed on the display screen according to the data format of the pixels. In a multiplayer competitive game, functions such as detection and judgment of behavior and movement of a character in a game scene, detection of a game target object, path navigation and the like are required, and a large amount of data calculation is involved. The realization of the above functions requires detection of the path between the starting point and the target point.

In the prior art, the logic judgment in the calculation task and the image data pre-processing before rendering are carried out by using a CPU (central processing unit), and for high-real-time competitive games, the calculation efficiency is low, and the business requirements cannot be met.

Disclosure of Invention

In order to overcome the technical defects, the invention aims to provide a method, a system, a server and a computer-readable storage medium for ray detection by using voxel data with higher operation efficiency.

The invention discloses a method for ray detection by using voxel data, which is used for ray detection of a path formed by a starting point and an end point and comprises the following steps: calculating and acquiring n points which are passed by the path in a voxel scene; simultaneously calculating the n points to index the corresponding point of each point in the voxel scene and detecting whether the point is a solid point; if solid points are detected in the n points, outputting a first detection result; otherwise, outputting a second detection result; and acquiring whether the path is blocked or not according to the first detection result and the second detection result.

Preferably, the step of converting the pixel scene into a voxel scene is applied to a pixel scene, the pixel scene including scene elements of several different data types, and the step of converting the pixel scene into a voxel scene includes: respectively deriving original data of a plurality of scene elements; setting the side length of an expected unit voxel, and respectively converting the original data of a plurality of scene elements into voxel data by combining the side length of the unit voxel, wherein the voxel data is expressed as a voxel module in the voxel scene; and according to the relative positions of the voxel modules of all the scene elements in the pixel scene, splicing the voxel modules of all the scene elements to obtain the voxel scene.

Preferably, the pixel scene is a game world applied in a game, and the scene elements comprise terrain, vegetation, buildings and outdoor ornaments; the respectively deriving the raw data of the plurality of scene elements comprises: exporting 3D model file format data and coordinate information of the outdoor ornament and the building; exporting comma separated value file format data of the vegetation; the images are taken orthogonally by a depth camera to derive a picture of the terrain, which contains surface height data of the terrain.

Preferably, the setting of the desired side length of the unit voxel, and the converting of the original data of the scene elements into voxel modules respectively by combining the side lengths of the unit voxel includes: converting the 3D model file format data of the outdoor ornament and the building into a voxel module through a read-write triangular mesh function and a secondary triangular mesh creating function in an open source library; acquiring the size of a collider of the vegetation, and calculating and acquiring the number and the shape of voxels needing to be occupied by the vegetation in the voxel scene by combining the side length of the unit voxel; sampling point by point according to the side length of a unit voxel according to the picture storing the surface height data of the terrain to convert the surface height data of the terrain into a voxel module.

Preferably, the method further comprises the following steps: ray detection is carried out on the m paths in the GPU: the m paths comprise m starting points and m end points; simultaneously calculating and acquiring n points of each path passing through in a voxel scene; the n points in the m paths are simultaneously calculated: indexing a corresponding point of each point in the voxel scene according to coordinates in the voxel scene, and detecting whether the point is a solid point; if the n points are detected to have solid points, outputting the first detection result of the path; otherwise, outputting the detection result of the path to obtain the detection results of the m paths.

Preferably, a detection area includes x detection targets and y nodes, and dynamically planning the detection area includes: simultaneously carrying out ray detection on x-y paths formed by the x detection targets and the y nodes, and storing detection results; and calling the detection results of different paths at different times for the detection area so as to carry out the dynamic planning.

Preferably, the dynamically planning the plurality of detection regions includes: simultaneously carrying out ray detection on x-y paths of different detection areas, storing detection results and forming a detection result table divided by the detection areas; and when the dynamic planning is carried out on a detection area, the detection result of the detection area is called from the detection result table.

Preferably, in the GPU, the n points are calculated simultaneously: indexing a corresponding point of each point in the voxel scene according to coordinates in the voxel scene, and detecting whether the point is a solid point; if solid points are detected in the n points, outputting a first detection result; otherwise, outputting a second detection result.

The invention also discloses a system for ray detection by using the voxel data, which is used for ray detection of a path formed by a starting point and an end point and comprises a point capturing module, a contrast index module and a judgment module; the point capturing module calculates n points which are passed by the acquisition path in the voxel scene; in the GPU, the n points are simultaneously calculated, the corresponding point of each point in the voxel scene is indexed through the comparison index module, and whether the point is a solid point is detected through the judgment module; if solid points are detected in the n points, outputting a first detection result; otherwise, outputting a second detection result; and acquiring whether the path is blocked or not according to the first detection result and the second detection result.

The invention also discloses a server for ray detection by using the voxel data, which is used for ray detection of a path formed by a starting point and an end point and comprises a point capturing module, a contrast index module and a judgment module; the point capturing module calculates n points which are passed by the acquisition path in the voxel scene; simultaneously calculating the n points, indexing the corresponding point of each point in the voxel scene through the contrast index module, and detecting whether the point is a solid point through the judgment module; if solid points are detected in the n points, outputting a first detection result; otherwise, outputting a second detection result; and acquiring whether the path is blocked or not according to the first detection result and the second detection result.

The invention also discloses a computer readable storage medium storing instructions for ray detection using voxel data, the instructions when executed perform ray detection on a path formed by a start point and an end point, comprising the steps of: calculating and acquiring n points which are passed by the path in a voxel scene; simultaneously calculating the n points to index the corresponding point of each point in the voxel scene and detecting whether the point is a solid point; if solid points are detected in the n points, outputting a first detection result; otherwise, outputting a second detection result; and acquiring whether the path is blocked or not according to the first detection result and the second detection result.

After the technical scheme is adopted, compared with the prior art, the method has the following beneficial effects:

1. for the calculation of spatial data, the spatial data are converted into voxel data, so that the calculation is highly matched with the GPU, and compared with the existing CPU operation mode, the performance of a data operation scheme based on the GPU is 2 to 3 orders of magnitude higher; the voxel data is used for high-performance ray detection for sensing the environment, and the operation efficiency is high.

Drawings

FIG. 1 is a flow chart of a method for ray detection using voxel data according to the present invention;

FIG. 2 is a flow chart of the present invention for converting a pixel scene to a voxel scene;

FIG. 3 is a prior art pixel scene;

fig. 4 is a voxel scene converted from the pixel scene of fig. 3 according to the present invention.

Detailed Description

The advantages of the invention are further illustrated in the following description of specific embodiments in conjunction with the accompanying drawings.

Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.

The terminology used in the present disclosure is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. As used in this disclosure and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.

It is to be understood that although the terms first, second, third, etc. may be used herein to describe various information, such information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, first information may also be referred to as second information, and similarly, second information may also be referred to as first information, without departing from the scope of the present disclosure. The word "if" as used herein may be interpreted as "at … …" or "when … …" or "in response to a determination", depending on the context.

In the description of the present invention, it is to be understood that the terms "longitudinal", "lateral", "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", and the like, indicate orientations or positional relationships based on those shown in the drawings, and are used merely for convenience of description and for simplicity of description, and do not indicate or imply that the referenced devices or elements must have a particular orientation, be constructed in a particular orientation, and be operated, and thus, are not to be construed as limiting the present invention.

In the description of the present invention, unless otherwise specified and limited, it is to be noted that the terms "mounted," "connected," and "connected" are to be interpreted broadly, and may be, for example, a mechanical connection or an electrical connection, a communication between two elements, a direct connection, or an indirect connection via an intermediate medium, and specific meanings of the terms may be understood by those skilled in the art according to specific situations.

In the following description, suffixes such as "module", "component", or "unit" used to denote elements are used only for facilitating the explanation of the present invention, and have no specific meaning in themselves. Thus, "module" and "component" may be used in a mixture.

Referring to FIG. 1, the present invention discloses a method for ray detection using voxel data, for starting point (x)1,y1,z1) And end point (x)2,y2,z2) The formed path is subjected to ray detection, and the method comprises the following steps:

s100, calculating n points (a) passed by the acquisition path in the voxel scene1,b1,c1)、(a2,b2,c2)、...、(an,bn,cn);

S200, simultaneously calculating n points to index the corresponding point of each point in the voxel scene and detecting whether the point is a solid point; if solid points are detected in the n points, outputting a first detection result; otherwise, outputting a second detection result;

s300, whether the path is blocked or not is obtained according to the first detection result and the second detection result.

The voxel is short for volume element, and the solid containing the voxel can be represented by solid rendering or by extracting a polygonal isosurface of a given threshold contour. The voxel is the minimum unit of digital data on three-dimensional space segmentation, and the unit voxel mentioned in the invention can be understood as a single voxel. Voxels are used in the fields of three-dimensional imaging, scientific data, medical imaging, and the like. Conceptually similar to the minimum unit of a two-dimensional space: pixels, which are used on image data of a two-dimensional computer image. Some true three-dimensional displays use voxels to describe their resolution, for example: a display of 512 x 512 voxels may be displayed.

The voxel scene is a three-dimensional space composed of unit voxels, and each spatial element is represented by a unit voxel in the three-dimensional space.

Starting point (x)1,y1,z1) And end point (x)2,y2,z2) The paths between them being collinear, so-called ray detection, i.e. from the starting point (x)1,y1,z1) Towards the end point (x)2,y2,z2) And emitting a ray, and making the two points travel a ray path.

The index can be understood as a search, and when detecting and judging whether n points are solid points, the n points need to be "reached" first, and the index is the step of "reaching". May be understood as a proprietary step in a computer process.

Generally, the first detection result shows a blocking and non-blocking meaning, and the second detection result shows a path through which no blocking object can pass. The passing can be understood as the passing of the target object in a spatial sense, and the target object can be an element which can perform dynamic motion, such as a game role and the like in a game; but also the ease of transmission of the signal.

For example, in the game process, it is necessary to determine whether the character holding the gun can hit a distant target object, and then the detection starting point is the character and the end point is the distant target object. If the detection result is that no blocking object exists, the gun is normally opened to hit the distant target object under the current aiming path; if the detection result is that the obstacle exists, the gun cannot hit the distant target object even if the gun is normally fired under the current aiming path.

In addition, usually, in the CPU, each of the n points is sequentially calculated in order or at random: indexing a corresponding point of each point in a voxel scene according to coordinates x, y and z, and detecting whether the point is a solid point; if the solid point is detected, stopping calculation and outputting a first detection result; if all the n points are calculated, and no solid point is detected, outputting a second detection result, and obtaining whether the path is blocked or not according to the first detection result and the second detection result.

In the field of three-dimensional imaging technology, an operation mode mainly using a CPU is generally adopted, that is, various types of logic task operations and data preprocessing are performed on the CPU, and a GPU is more suitable for concurrent data operations, such as image rendering. The combination effect of the existing space data structure and the GPU is not ideal, so that the existing space data structure cannot reflect the high concurrent operation performance of the GPU, the space data used for three-dimensional imaging is converted into voxel data, so that the space data is highly matched with the high concurrent operation characteristic of the GPU to carry out various operations, and compared with the existing CPU operation mode, the performance of a data operation scheme based on the GPU is 2 to 3 orders of magnitude higher. Therefore, the voxel data is used for high-performance ray detection for sensing the environment, and the operation efficiency is high.

Specifically, referring to fig. 2, the present invention provides an embodiment for converting a pixel scene into a voxel scene, and the step of converting the pixel scene into the voxel scene is "calculating n points (a) of the path passing through the voxel scene" in the step of the corresponding embodiment of fig. 11,b1,c1)、(a2,b2,c2)、...、(an,bn,cn) "before, specifically include:

s400, respectively deriving original data of scene elements of a plurality of different data types included in a pixel scene;

s500, setting the side length of an expected unit voxel, and respectively converting the original data of a plurality of scene elements into voxel data by combining the side length of the unit voxel, wherein the voxel data is expressed as a voxel module in a voxel scene;

s600, according to the relative positions of the voxel modules of all scene elements in the pixel scene, the voxel modules of all scene elements are spliced to obtain the voxel scene.

In this embodiment, the pixel scene is a game world of a game established by the UE4 game engine, and the game is an electronic game and can be run on a mobile phone, a tablet computer, a computer, or the like. Referring to fig. 3, in the game world, scene elements include terrain, vegetation, buildings, and outdoor furnishings. Terrains such as earth slopes, hills, rivers, etc.; vegetation such as trees, flowers, shrubs, and the like; buildings such as houses, warehouses, etc.; outdoor furnishings such as tanks, platforms, and the like. All scenes in fig. 3 are presented in pixels, each element being composed of a single block of pixels.

And the type of data used in the construction of different scene elements is different. The raw data for different scene elements are derived separately from the UE4 game engine in different ways depending on the type of scene element and its characteristics. Specifically, the method comprises the following steps:

the outdoor ornament and the building belong to an Actor type containing StaticMesh in a UE4 game engine, an OBJ file can be directly exported, and coordinate information of the Actor is synchronously exported; the OBJ file is a 3D model file;

vegetation does not belong to an independent Actor type in the UE4, so a mode of recording coordinates and shapes needs to be adopted to be exported to be a CSV information file; the CSV information file is a comma separated value file;

the terrain only utilizes the surface height information in the voxel scene, and the invention can derive the image data of the terrain by adopting a mode of orthogonal shooting by a depth camera.

Because the types and features of scene elements are different, different conversion methods are required to convert various types of original data of different scene elements into voxel data expressed as voxel modules in a voxel scene, firstly, the desired side length of a unit voxel needs to be set, one voxel module comprises one or a plurality of unit voxels, and the data of a plurality of scene elements are respectively converted into the voxel modules by combining the side lengths of the unit voxels, specifically:

for an OBJ file, the OBJ file can be directly converted into a voxel module by means of a "read-write triangle mesh" function and a "create from triangle mesh" function in an OPEN source library, OPEN 3D; OPEN3D is not a limiting OPEN source library of the present invention, and other OPEN source libraries that can perform the above two functions can be used for data transformation;

for vegetation, the number and the shape of voxel modules occupied by the vegetation in a voxel scene are directly calculated according to the size of a collision body of the vegetation and the side length of a voxel;

the terrain occupies only one layer in the voxel scene, see region D in fig. 4, and samples point by point according to the side length of the unit voxel to convert it into a voxel module according to the picture data storing the height information.

All data for establishing the voxel scene are obtained, and finally the voxel modules of all scene elements are needed to be spliced to obtain the voxel scene of all scene elements.

The voxel scene is represented as a large number of three-dimensional coordinate points in a program, the principle of splicing voxel modules is that coordinate point information representing the voxel modules is integrated into the same data structure according to the relative positions of the voxel modules in a game map, and the UE4 game engine contains the position information and rotation information of each module, so that the problem that the Euler angle rotation transformation of a 3D model is different in rules in different systems needs to be particularly noticed during splicing.

The voxel scene shown in fig. 4 is obtained through stitching, and in the voxel scene, the spatial information of the three-dimensional world is expressed by using the complete three-dimensional tensor, and the sampling precision of the spatial information determines the spatial resolution. The voxel data format is standard and regular, and is easy to calculate, especially parallel calculation, so the invention applies the voxel data to GPU ray detection, can realize high-speed multipath concurrent operation, and can be understood that in the GPU, the time for using the voxel data to detect a plurality of rays is the same as the time for detecting one ray, so the time for detecting a plurality of rays can be greatly shortened.

In other embodiments, the voxel scene may also be other application scenes in which the scene elements will include not only or other scene elements distinct from terrain, vegetation, buildings, and outdoor furnishings. Correspondingly, the data derivation and voxel data conversion for the other scene elements may adopt a method different from the embodiment, and is not limited herein.

It should be noted that voxel data is not meant to be used only for calculation in the GPU, but the CPU can still perform calculation using voxel data, but only a plurality of path detection tasks are sequentially executed because parallel calculation cannot be performed during ray detection.

The following provides an example of a GPU implementing single path ray detection in parallel:

1) calculating a starting point (x) using a ray detection method1,y1,z1) And end point (x)2,y2,z2) N points (a) to be passed in the voxel scene1,b1,c1)、(a2,b2,c2)、...、(an,bn,cn) (ii) a In the ray detection method, a ray is emitted from a starting point to an end point, a line segment exists between the starting point and the end point, and points on the line segment are n points which need to pass through.

2) Putting n points into an array A (the number of array elements is n, and each array element contains voxel scene coordinate information, namely three-dimensional coordinate (x, y and z) information);

3) in the GPU, the calculation is performed simultaneously for each point in the array a, i.e. n threads are concurrent, and the following process is performed for each thread:

points in the voxel data are indexed according to coordinates in the voxel scene and detected as being solid points. Specifically, each coordinate point in the voxel scene has an attribute value, and if the attribute value is 1, it indicates that an object or a part of the object exists on the coordinate point, and objects such as game characters and buildings occupy a large number of coordinate positions, and the attributes of the coordinate points in the occupied positions are all 1; correspondingly, if the attribute value is 0, it indicates that there is no object on the coordinate point, i.e. an open scene. If the solid point is detected, writing 1 in the result, namely a first detection result, which indicates that the thread is blocked; and if the solid point is not detected, writing 0 into the result, namely a second detection result, which indicates that the path corresponding to the thread can pass through without the barrier.

The following provides an example of a GPU implementing multiple ray detections in parallel:

1) for m ray detection tasks, m pairs of starting points and end points are provided, and the m pairs of starting points and end points are put into an array B (the number of array elements is m, and each array element comprises a starting point and an end point);

2) in the GPU, each pair of start and end points in the set B is computed simultaneously, i.e. m parent threads are concurrent, and the following process is performed on each thread:

a. for the starting point (x)1,y1,z1) And end point (x)2,y2,z2) The ray detection is carried out, and the ray detection is carried out,

b. calculating n points (a) to be passed by the voxel scene by using a ray detection method1,b1,c1)、(a2,b2,c2)、...、(an,bn,cn);

c. Putting n points into an array A' (the number of array elements is n, and each array element contains voxel scene coordinate information, namely three-dimensional coordinate (x, y and z) information);

d. in the GPU, the calculation is performed simultaneously for each point in the group a, i.e. n child threads are concurrent, and the following procedure is performed for each child thread (in this case, n child threads are concurrent for each parent thread, i.e. n × m threads in total): indexing points in the voxel data according to coordinates in the voxel scene, and detecting whether the points are solid points or not; if the solid point is detected, writing 1 into the result, which indicates that the path corresponding to the sub-thread is blocked; if no solid point is detected, writing 0 into the result, which indicates that the path corresponding to the sub-thread can pass through without a barrier;

3) and collecting the detection results of the m rays.

The invention is measured on processors RTX3090 and AMD thread 3990X: when 100 ten thousand or more rays are detected at the same time, the detection speed of the GPU is about 550 times that of a single CPU core, and the operation speed is obviously improved.

Dynamic planning is usually required in a voxel scene for calculating a navigation task, and the output result is a path. In a dynamic planning task, a plurality of nodes to be explored are included, and it should be noted that the nodes are nodes in the meaning of the task process and do not represent specific references in data. In some embodiments, a node may be a particular voxel scene coordinate point. For dynamic planning, nodes are explored in sequence, and whether ray detection is needed when the nodes are explored and which targets are subjected to ray detection are unknown, so that a time sequence task is formed. The invention can perform parallelization time dispersion task by using GPU:

1) estimating a detection area to be used by dynamic planning;

2) performing ray detection on all nodes in the detection area and all detection targets of each node, which need to detect rays, wherein if x detection targets and y nodes exist, x paths and y paths exist, namely, x paths and y parallel detection tasks are shared; the detection target may be a voxel scene coordinate point, such as a coordinate point on the appearance of a target object or a scene building in the game world.

3) Storing the detection result;

4) when the dynamic programming algorithm is executed, only the detection result which is already calculated needs to be inquired.

Because the ray detection result for storing the appointed detection area occupies a small storage space, one result occupies one byte at most, and 100 ten thousand detection results can be stored in 1MB, the dynamic programming algorithm task has high execution efficiency and only needs to read time.

Preferably, a plurality of detection main bodies need to be dynamically planned at the same time, the detection main bodies comprise a plurality of detection targets, namely, x × y paths of detection areas corresponding to different detection targets are subjected to ray detection at the same time, and detection results are stored to form a detection result table divided by the detection areas; when a detection area is dynamically planned, the detection result of the detection area is called from a detection result table.

For example, if it is necessary to dynamically plan the area a, the area B, the area C, and the area D, x × y paths of each area are detected simultaneously, and the detection time is only a single ray detection time t.

And storing the detection result, wherein the detection result of the area A is a, the detection result of the area B is B, the detection result of the area C is C, and the detection result of the area D is D, forming a detection result table of A-a, B-B, C-C and D-D, and calling the result a when the area A is dynamically planned.

The radiation detection time is only a single radiation detection time t regardless of whether there are a plurality of detection targets or a plurality of detection subjects. And the subsequent reading is carried out in time in the actual process of dynamic programming, and the operation speed is very high.

The invention also discloses a system for ray detection by using the voxel data, which is used for detecting the starting point (x)1,y1,z1) And end point (x)2,y2,z2) The formed path is subjected to ray detection and comprises a point capturing module, a comparison indexing module and a judging module.

The point capture module calculates n points (a) that the acquisition path passes through in the voxel scene1,b1,c1)、(a2,b2,c2)、...、(an,bn,cn)。

In the GPU, n points are calculated simultaneously: indexing a corresponding point of each point in the voxel scene by a contrast indexing module according to the coordinates in the voxel scene, and detecting whether the point is a solid point by a judging module; if solid points are detected in the n points, outputting a first detection result; otherwise, outputting a second detection result; and acquiring whether the path is blocked or not according to the first detection result and the second detection result.

The system comprises a hardware structure and a computer readable storage medium, and the functional modules may be integrated on the hardware structure or the computer readable storage medium, which is not limited herein. The connection relationship of the functional modules may be a tangible connection or an intangible connection across regions, and is not limited herein.

The invention also discloses a server for ray detection by using the voxel data, which is used for detecting the starting point (x)1,y1,z1) And end point (x)2,y2,z2) The formed path is subjected to ray detection and comprises a point capturing module, a comparison indexing module and a judging module.

The point capture module calculates n points (a) that the acquisition path passes through in the voxel scene1,b1,c1)、(a2,b2,c2)、...、(an,bn,cn)。

In the GPU, n points are calculated simultaneously: indexing a corresponding point of each point in the voxel scene by a contrast indexing module according to the coordinates in the voxel scene, and detecting whether the point is a solid point by a judging module; if solid points are detected in the n points, outputting a first detection result; otherwise, outputting a second detection result; and acquiring whether the path is blocked or not according to the first detection result and the second detection result.

The invention also discloses a computer readable storage medium for ray detection by using the voxel data, which is used for detecting the starting point (x)1,y1,z1) And end point (x)2,y2,z2) The formed path is subjected to ray detection and comprises a point capturing module, a comparison indexing module and a judging module.

The point capture module calculates n points (a) that the acquisition path passes through in the voxel scene1,b1,c1)、(a2,b2,c2)、...、(an,bn,cn)。

In the GPU, n points are calculated simultaneously: indexing a corresponding point of each point in the voxel scene by a contrast indexing module according to the coordinates in the voxel scene, and detecting whether the point is a solid point by a judging module; if solid points are detected in the n points, outputting a first detection result; otherwise, outputting a second detection result; and acquiring whether the path is blocked or not according to the first detection result and the second detection result.

The computer-readable storage medium may be integrated on hardware, and when the hardware operates, the computer-readable storage medium may be supported to operate.

It should be noted that the embodiments of the present invention have been described in terms of preferred embodiments, and not by way of limitation, and that those skilled in the art can make modifications and variations of the embodiments described above without departing from the spirit of the invention.

14页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:虚拟对象的控制方法、装置、设备及介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类