Navigation grid linking method and device
By traversing the boundary line of the navigation grid in a virtual scene and emitting ray detection, automatically judge and establishing navigation links, the problem of cumbersome and inefficient navigation grid links in the existing technology is solved, and efficient and accurate navigation links are achieved.
Patent Information
- Application Number
- CN202211138621.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-19
- Publication Date
- 2024-12-20
- Estimated Expiration
- 2042-09-19
AI Technical Summary
In the prior art, links between navigation grids require manual judgment and creation, resulting in cumbersome and inefficient and error-prone.
By traversing the boundary lines of the navigation grid in a virtual scene, the ray detection results are emitted to automatically judge and establish navigation links, eliminating the tedious operation of manually creating links.
Automatic links between navigation grids are realized, efficiency is improved, error rate is reduced, and one-way or two-way navigation links can be established according to different situations to meet the needs of different scenarios.
Smart Images

Figure CN115414670B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of electronic information, and in particular to a navigation grid linking method and device. Background Art
[0002] At present, in virtual reality scenes, in order to meet the pathfinding needs of virtual characters inside dynamic virtual building models, navigation mesh is usually used to achieve pathfinding. Navigation mesh (Navigation Mesh), also called walking surface, is a polygonal mesh data structure used for navigation and pathfinding in complex spaces and marking which places are walkable. A navigation mesh is usually composed of multiple convex polygons (Convex Polygon, Poly Mesh). In addition, in order to indicate whether two navigation meshes or mesh boundaries are reachable, it is necessary to set a link between two mutually reachable navigation meshes or mesh boundaries, so as to guide the virtual character from one navigation mesh to another based on the link.
[0003] In the related art, links between navigation grids are manually generated. Game configuration personnel manually determine whether two navigation grids are reachable, and manually create links between the two navigation grids based on the manual determination result. However, the inventors found in the process of implementing the present invention that the above method has at least the following defects: the manual method of creating links is cumbersome, inefficient, and prone to errors. Summary of the invention
[0004] In view of the above problems, the present invention is proposed to provide a navigation grid linking method and device that overcomes the above problems or at least partially solves the above problems.
[0005] According to one aspect of the present invention, a navigation grid linking method is provided, the method comprising:
[0006] Get the navigation mesh contained in the virtual scene;
[0007] Traversing each grid boundary line of the navigation grid;
[0008] Emit rays based on each grid boundary line;
[0009] Obtaining the ray detection results corresponding to each grid boundary line, and judging whether there are at least two grid boundary lines that meet the linking condition according to the ray detection results;
[0010] If so, a navigation link is established between the at least two grid boundary lines that meet the link condition.
[0011] According to another aspect of the present invention, a navigation grid linking device is provided, the device comprising:
[0012] An acquisition module, adapted to acquire a navigation mesh contained in a virtual scene;
[0013] A traversal module, adapted to traverse each grid boundary line of the navigation grid;
[0014] A transmitting module, adapted to transmit rays based on each grid boundary line as a reference;
[0015] A judgment module, adapted to obtain the ray detection results corresponding to each grid boundary line, and judge whether there are at least two grid boundary lines that meet the linking condition according to the ray detection results;
[0016] The establishing module is adapted to establish a navigation link between the at least two grid boundary lines that meet the linking condition.
[0017] According to another aspect of the present invention, there is provided an electronic device, comprising: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus;
[0018] The memory is used to store at least one executable instruction, and the executable instruction enables the processor to execute the above method.
[0019] According to another aspect of the embodiments of the present invention, a computer storage medium is provided, wherein the storage medium stores at least one executable instruction, and the executable instruction enables a processor to execute the above method.
[0020] In the navigation grid linking method and device provided by the present invention, after obtaining the navigation grid contained in the virtual scene, each grid boundary line of the navigation grid is traversed; rays are respectively emitted based on each grid boundary line; the ray detection results corresponding to each grid boundary line are obtained, and it is determined whether there are at least two grid boundary lines that meet the linking conditions according to the ray detection results; if so, a navigation link is established between at least two grid boundary lines that meet the linking conditions. It can be seen that this method can automatically establish a navigation link between two adjacent grid boundary lines by ray detection, thereby eliminating the tedious operation of manually creating a link, and is efficient and not prone to errors.
[0021] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0023] Figure 1 A flowchart of a navigation grid linking method provided by an embodiment of the present invention is shown;
[0024] Figure 2 A flowchart of a navigation grid linking method provided by yet another embodiment of the present invention is shown;
[0025] Figure 3 A schematic structural diagram of a navigation grid linking device provided by yet another embodiment of the present invention is shown;
[0026] Figure 4 A schematic structural diagram of an electronic device provided by yet another embodiment of the present invention is shown. DETAILED DESCRIPTION
[0027] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0028] Figure 1 FIG. 1 is a flowchart of a method for linking navigation grids provided by an embodiment of the present invention. Figure 1 As shown, the method includes:
[0029] S110: Acquire the navigation mesh included in the virtual scene.
[0030] Among them, the virtual scene can be various scenes such as game scenes and virtual reality scenes. When obtaining multiple navigation meshes contained in the virtual scene, the pre-generated navigation mesh can be directly obtained. The specific generation time and generation method of the pre-generated navigation mesh can be flexibly set by a person skilled in the art, and the present invention does not limit this. Alternatively, the navigation mesh can also be directly generated in this step. For example, it can be generated in the following way: first, determine the scene model that can carry human objects contained in the virtual scene, and perform voxel processing, also called rasterization processing, on the scene model that can carry human objects. Then, filter out the walkable surface. Finally, generate a navigation mesh based on the walkable surface. A navigation mesh is usually composed of multiple convex polygons (Convex Polygon, Poly Mesh).
[0031] S120: Traverse each grid boundary line of the navigation grid.
[0032] The number of navigation grids may be one or more, and each navigation grid has at least three grid boundary lines. Accordingly, in this step, it is necessary to traverse each grid boundary line in each navigation grid.
[0033] S130: emitting rays based on each grid boundary line.
[0034] Specifically, rays can be emitted in parallel based on each grid boundary line at the same time, so as to achieve the purpose of parallel ray detection between each grid boundary line, thereby achieving efficient detection.
[0035] In addition, when emitting rays, the direction and length of the rays can be flexibly configured. For example, the direction of the rays can include horizontal and vertical directions, and can even include a specified direction corresponding to a preset angle. The length of the rays can be set according to the mobility of the virtual character.
[0036] S140: Obtain the ray detection results corresponding to each grid boundary line, and determine whether there are at least two grid boundary lines that meet the linking condition according to the ray detection results.
[0037] The link condition includes: the distance between two grid boundary lines is less than a preset spacing threshold. It can be seen that ray detection is mainly used to find adjacent grid boundary lines. By reasonably setting the value of the preset spacing threshold, a link can be automatically established between two grid boundary lines that the virtual character can reach.
[0038] The at least two grid boundary lines that meet the linking condition include: the grid boundary line where the emission source is located and another grid boundary line that meets the linking condition with the grid boundary line where the emission source is located. The linking condition includes various types such as distance conditions and grid attribute conditions, which can be flexibly set by those skilled in the art. For example, in one implementation, it is determined based on the ray detection results whether there is another grid boundary that can be connected to the grid boundary where the emission source is located.
[0039] S150: If yes, establish a navigation link between at least two grid boundary lines that meet the link condition.
[0040] In the navigation grid linking method provided by the present invention, a navigation link can be automatically established between two adjacent grid boundary lines by means of ray detection, thereby eliminating the tedious operation of manually creating a link, being efficient and not prone to errors.
[0041] Figure 2FIG. 4 is a flowchart of a method for linking navigation grids provided by another embodiment of the present invention. Figure 2 As shown, the method includes:
[0042] S200: Determine a scene area in a virtual scene that requires automatic path finding.
[0043] This step is an optional step. For a smaller virtual scene, the entire virtual scene can be directly used as the scene area that requires automatic path finding, thereby omitting this step.
[0044] For some virtual scenes with larger scales, in order to avoid affecting other areas of the scene, this step can be used to pre-set the scene areas contained in the virtual scene that require automatic pathfinding to limit the execution scope of subsequent steps.
[0045] Specifically, a virtual scene can be created through a scene editor. For example, a new editor scene (EditorScene) can be created. Alternatively, a portion of the created virtual scene can be selected as a local scene area that requires automatic pathfinding.
[0046] S210: Acquire the navigation mesh included in the virtual scene.
[0047] Among them, when obtaining the navigation mesh contained in the virtual scene, it can be achieved in the following way: first, determine the scene model that can carry the human object contained in the virtual scene, and perform voxel processing, also called rasterization processing, on the scene model that can carry the human object. Then, filter out the walkable surface. Finally, generate a navigation mesh based on the walkable surface. A navigation mesh is usually composed of multiple convex polygons (Convex Polygon, Poly Mesh). Alternatively, the navigation mesh can also be generated in advance, and accordingly, the pre-generated navigation mesh can be directly obtained in this step.
[0048] When determining the scene model that can carry a character object contained in the virtual scene, it is determined whether each scene model in the virtual scene is provided with physical collision information, that is, it is determined whether each scene model in the virtual scene is added with a collision body and can respond to the collision operation. Accordingly, the scene model provided with physical collision information is determined as the scene model that can carry a character object, so as to generate a navigation mesh according to the scene model that can carry a character object.
[0049] The number of navigation grids may be one or more.
[0050] S220: Traverse each grid boundary line of the navigation grid.
[0051] The number of navigation grids may be one or more, and each navigation grid has at least three grid boundary lines. Accordingly, in this step, it is necessary to traverse each grid boundary line in each navigation grid.
[0052] S230: emitting rays based on each grid boundary line.
[0053] Specifically, rays can be emitted in parallel based on each grid boundary line at the same time to achieve the purpose of parallel ray detection between each grid boundary line, thereby achieving efficient detection. In addition, when emitting rays, the direction and length of the rays can be flexibly configured. For example, the ray direction can include the horizontal direction and the vertical direction, and can even include a specified direction corresponding to a preset angle. The ray length can be set according to the action ability of the virtual character.
[0054] In one implementation, for any grid boundary line, with the grid boundary line as a reference, according to the first detection step, multiple rays are sequentially emitted along the first direction to detect whether there is a grid boundary line that meets the linking condition in the first direction; with the grid boundary line as a reference, according to the second detection step, multiple rays are sequentially emitted along the second direction to detect whether there is a grid boundary line that meets the linking condition in the second direction; wherein the first direction is perpendicular to the second direction; wherein the linking condition includes: the distance between the two grid boundary lines is less than a preset spacing threshold. wherein the first direction is usually a horizontal direction, and the second direction is usually a vertical direction. correspondingly, the first detection step is a horizontal detection step, and the second detection step is a vertical detection step. by detecting in two directions separately, it can ensure that the detected grid boundary line is more comprehensive and avoids omission. and by setting the horizontal detection step and the vertical detection step, the method of sequentially emitting multiple rays according to the detection step helps to improve the detection accuracy. For example, assuming that the horizontal detection step length is 1 meter and the vertical detection step length is 0.5 meter, a one-meter-long ray is first emitted in the horizontal direction to determine whether obstacles such as walls are detected; if not, a two-meter-long ray is emitted in the horizontal direction to determine whether obstacles such as walls are detected; if still not, a three-meter-long ray is emitted in the horizontal direction to determine whether obstacles such as walls are detected. The detection method in the vertical direction is similar to that in the horizontal direction and will not be repeated here. In addition, the process of performing multiple ray detections in the horizontal direction according to the horizontal detection step length and the process of performing multiple ray detections in the vertical direction according to the vertical detection step length can be performed sequentially or crosswise, and the present invention does not limit the specific details.
[0055] In other optional implementations, any grid boundary line can be determined as a target grid boundary line, and rays are emitted based on the target grid boundary line. Since the virtual scene contains multiple grid boundary lines, any grid boundary line can be determined as a target grid boundary line, and based on the target grid boundary line, adjacent grid boundary lines that are adjacent to and reachable from the target grid boundary line are found. Specifically, rays are emitted based on the target grid boundary line, and adjacent grid boundary lines are found by ray detection. In this embodiment, multiple grid boundary lines are determined as target grid boundary lines at the same time, and rays are emitted based on each target grid boundary line. In this method, multiple target grid boundary lines can be processed simultaneously by multi-threading, thereby realizing parallel processing between multiple target grid boundary lines. This method is more efficient, can greatly shorten the link establishment time, and reduce the user waiting time. In actual situations, any one of the above two implementations can be flexibly selected. In addition, rays can be emitted based on each grid boundary line as a reference in turn, or rays can be emitted based on each grid boundary line as a reference at the same time.
[0056] S240: Obtain the ray detection results corresponding to each grid boundary line, and determine whether there are at least two grid boundary lines that meet the linking condition according to the ray detection results.
[0057] The linking condition includes: the distance between two grid boundary lines is less than a preset spacing threshold, wherein the two grid boundary lines include: the grid boundary line where the emission source is located and another grid boundary line whose distance from the grid boundary line where the emission source is located is less than the preset spacing threshold. It can be seen that ray detection is mainly used to find adjacent grid boundary lines. By reasonably setting the numerical value of the preset spacing threshold, a link can be automatically established between two grid boundary lines that the virtual character can reach.
[0058] Preferably, the preset spacing threshold can be dynamically set according to the character's role level information; or, it can also be fixed. In short, the preset spacing threshold is related to the character's ability to act. For example, the horizontal spacing threshold is set according to the character's maximum horizontal movement displacement, and the vertical spacing threshold is set according to the character's maximum vertical movement displacement. Correspondingly, at least two grid boundary lines that meet the linking condition include: two grid boundary lines whose horizontal spacing is not greater than the horizontal spacing threshold, and / or, two grid boundary lines whose vertical spacing is not greater than the vertical spacing threshold. Considering that different characters have different abilities to act, and even if the same character changes in level, the ability to act will usually change accordingly. Therefore, in this embodiment, the character level information of the character can also be dynamically obtained, so that the numerical value of the preset spacing threshold can be dynamically adjusted according to the dynamically obtained character level information of the character.
[0059] In one implementation, when performing ray detection, a ray detection level may be configured for the ray detection operation, and accordingly, when performing the ray detection operation, the ray detection operation is performed only within the configured ray detection level. In this method, at least two grid boundary lines that meet the linking condition refer to at least two navigation grids that are located within the same ray detection level and whose spacing is not greater than a preset spacing threshold.
[0060] In one implementation, when the distance between the first grid boundary line and the second grid boundary line is less than a preset distance threshold, a first grid attribute of the first grid boundary line and a second grid attribute of the second grid boundary line are further obtained; and according to the first grid attribute and the second grid attribute, it is determined whether the first grid boundary line and the second grid boundary line meet the linking condition. In other words, the linking condition includes not only the condition set according to the preset spacing threshold, but also the condition set according to the grid attribute.
[0061] Considering that the navigation grid and its grid boundary line have various attributes, it is further determined whether to establish a navigation link according to the grid attributes of the first grid boundary line and the second grid boundary line. The grid attributes of the navigation grid or the grid boundary line are used to describe the function or type of the scene model corresponding to the navigation grid or the grid boundary line. For example, the grid attributes include: support attributes, surface attributes, etc. The navigation grid or grid boundary line of the surface attribute corresponds to the ground class object; the navigation grid or grid boundary line of the support attribute corresponds to the support object such as the table and the chair. Accordingly, when judging whether the first grid boundary line and the second grid boundary line meet the linking condition according to the first grid attribute and the second grid attribute, it can be determined that the first grid boundary line and the second grid boundary line meet the linking condition when the first grid attribute and the second grid attribute are the same. For example, two grid boundary lines with the same surface attribute are mutually a group of linkable boundary lines; for another example, two grid boundary lines with the same support attribute (and the same support type) are mutually a group of linkable boundary lines.
[0062] In addition, a link type identifier can be further configured for the established navigation link, and the link type identifier is used to indicate what type of character object the navigation link can provide a pathfinding function for. The link type identifier can be set according to the first grid attribute and the second grid attribute: for example, when the first grid attribute and the second grid attribute are both support attributes (and the support type is a table), the link type identifier configured for the navigation link between the group of linkable boundary lines is used to provide a pathfinding function for character objects whose size is smaller than a preset volume. For example, the load-bearing capacity of a table is weak, so a character object with a larger volume cannot jump on two adjacent tables; however, for a character object with a small volume (such as a cat or dog, etc.), it can jump on two adjacent tables. Therefore, configuring the link type identifier according to the grid attribute and indicating the type of character object to which the navigation link can be applied based on the link type identifier can make the navigation pathfinding function more flexible and applicable to various types of character objects.
[0063] S250: If yes, establish a navigation link between at least two grid boundary lines that meet the link condition.
[0064] In one implementation, based on the relative positional relationship between the first grid boundary line and the second grid boundary line, it is determined whether the first grid boundary line and the second grid boundary line are a set of bidirectionally linkable boundary lines; if so, a bidirectional navigation link is established between the first grid boundary line and the second grid boundary line; if not, a unidirectional navigation link is established between the first grid boundary line and the second grid boundary line.
[0065] Among them, the relative position relationship includes: interval distance, relative orientation, etc. In specific implementation, a two-way interval threshold can be pre-set, and the two-way interval threshold is less than the preset interval threshold mentioned above. Accordingly, when it is determined that the interval between the first grid boundary line and the second grid boundary line is not greater than the preset interval threshold, it is further determined whether the interval between the first grid boundary line and the second grid boundary line is not greater than the two-way interval threshold. If so, it is determined that the group of linkable boundary lines is a group of two-way linkable boundary lines, and then a two-way navigation link is established between the first grid boundary line and the second grid boundary line. Otherwise, a unidirectional navigation link is established between the first grid boundary line and the second grid boundary line.
[0066] The bidirectional navigation link refers to a link that can be reached from the first grid boundary line to the second grid boundary line, or from the second grid boundary line to the first grid boundary line. In addition, in addition to judging based on the bidirectional interval threshold, in other implementations, the judgment can also be made based on the relative orientation between the first grid boundary line and the second grid boundary line. For example, if the relative orientation between the first grid boundary line and the second grid boundary line is horizontal, that is, the second grid boundary line is located at the horizontal orientation of the first grid boundary line, then the group of linkable boundary lines is determined to be a group of bidirectional linkable boundary lines, and a bidirectional navigation link is established between the first grid boundary line and the second grid boundary line; if the relative orientation between the second grid boundary line and the first grid boundary line is vertical, that is, the second grid boundary line is located above or below the first grid boundary line, then the group of linkable boundary lines is determined not to belong to a group of bidirectional linkable boundary lines, and a unidirectional navigation link is established between the first grid boundary line and the second grid boundary line.
[0067] In addition, the above two implementation methods can also be used in combination, so as to determine whether the group of linkable boundary lines belongs to a group of bidirectional linkable boundary lines according to the spacing distance and relative orientation between the first grid boundary line and the second grid boundary line. For example, if the relative orientation between the first grid boundary line and the second grid boundary line is a vertical orientation, that is, the second grid boundary line is located above or below the first grid boundary line, then it is further determined whether the spacing (also called height difference) between the first grid boundary line and the second grid boundary line is greater than the bidirectional spacing threshold; if it is greater than the bidirectional spacing threshold, it is determined that the group of linkable boundary lines does not belong to a group of bidirectional linkable boundary lines; if it is not greater than the bidirectional spacing threshold, it is determined that the group of linkable boundary lines belongs to a group of bidirectional linkable boundary lines. The specific reason is that it is relatively easy for a character to jump from a high place to a low place, while it is relatively difficult for a character to jump from a low place to a high place. Therefore, the bidirectional spacing threshold can be set according to the jumping ability of the character object when jumping upward.
[0068] In addition, the relative position relationship may include not only the interval distance and the relative orientation, but also features such as the slope angle between the first grid boundary line and the second grid boundary line. For example, if the first grid boundary line and the second grid boundary line are located at the top and bottom of a slope, respectively, it is possible to further determine whether the group of linkable boundary lines belongs to a group of bidirectional linkable boundary lines based on the slope's inclination angle. For example, considering that a slope with a steeper slope is usually difficult to climb after falling, therefore, when the slope's inclination angle is greater than a preset angle threshold, it is determined that the group of linkable boundary lines does not belong to a group of bidirectional linkable boundary lines.
[0069] In addition, the inventors found in the process of implementing the present invention that when processing each grid boundary line in parallel through multi-threading, there may be a situation where navigation links are repeatedly established. For example, when grid boundary line A is used as the target grid boundary line, grid boundary line B is used as the linkable boundary line of grid boundary line A, so that grid boundary line A and grid boundary line B are determined as a group of linkable boundary lines. However, when grid boundary line B is used as the target grid boundary line, grid boundary line A may be repeatedly used as the adjacent grid boundary line of grid boundary line B, so that grid boundary line A and grid boundary line B are repeatedly determined as a group of linkable boundary lines. In the above manner, redundant navigation links will be established between grid boundary line A and grid boundary line B. In order to avoid the above problem, in an optional implementation, when establishing a navigation link, it is implemented in the following manner: obtaining the first coordinate information corresponding to the first grid boundary line and the second coordinate information corresponding to the second grid boundary line; judging whether the first grid boundary line is located at the preset position of the second grid boundary line according to the first coordinate information and the second coordinate information; if so, establishing a navigation link between the first grid boundary line and the second grid boundary line. Among them, the preset orientation is used to reflect the relative position between the first grid boundary line and the second grid boundary line, so that the process of establishing the navigation link follows a certain orientation order, thereby preventing duplication problems. For example, the preset orientation can be: the lower orientation. For example, it is determined whether the second grid boundary line is located below the first grid boundary line. If so, a navigation link is established between the first grid boundary line and the second grid boundary line; if not, a navigation link is not established between the first grid boundary line and the second grid boundary line. Specifically, it can be determined whether the height (i.e., the ordinate value) of the first grid boundary line is greater than the height (i.e., the ordinate value) of the second grid boundary line. If so, it is determined that the second grid boundary line is located below the first grid boundary line. That is, the navigation link will only be established if the starting point of the navigation link to be established is higher than the end point. For example, still taking the above example, since there must be a slight difference in the height of the grid boundary line A and the grid boundary line B, a navigation link will only be established between the two when the grid boundary line with a higher height is used as the target grid boundary line; and when the grid boundary line with a lower height is used as the target grid boundary line, a navigation link will not be repeatedly established between the two, thereby avoiding the above problem. Of course, the preset direction may be not only the bottom, but also the left, right or top, etc. The present invention does not limit the specific details.
[0070] In addition, the inventors also found in the process of implementing the present invention that due to the existence of algorithm errors, the established navigation link may have a slight deviation, which may result in the inability to smoothly connect the two navigation grids. In order to solve the above problem, after the navigation link is established, the following verification operation is further performed: obtaining the first link endpoint and the second link endpoint of the navigation link; determining whether the first link endpoint matches the position of the first grid boundary line, and / or whether the second link endpoint matches the position of the second grid boundary line; if not, adjusting the position of the unmatched first link endpoint and / or second link endpoint so that the adjusted first link endpoint matches the position of the first grid boundary line, and the second link endpoint matches the position of the second grid boundary line. Among them, the first link endpoint of the first grid boundary line refers to: the endpoint used to connect the first grid boundary line; the second link endpoint of the second grid boundary line refers to: the endpoint used to connect the first grid boundary line. When the position of any link endpoint does not match the grid boundary line, it means that there is a gap between the navigation link and the grid boundary line due to the existence of algorithm errors. The existence of this gap will affect the effect of the character object navigating through the navigation link. Therefore, by adjusting the position of the mismatched first link endpoint and / or second link endpoint, so that the adjusted first link endpoint matches the position of the first grid boundary line, and the second link endpoint matches the position of the second grid boundary line, the accuracy of the navigation link can be ensured, thereby improving the navigation effect. For example, the algorithm can automatically check whether the start / end point of the navigation link (Link) is on the grid boundary line, so as to make adjustments when the start / end point of the navigation link is not on the grid boundary line.
[0071] It can be seen that in this embodiment, a navigation link (NavMesh Link) can be automatically generated according to the configuration parameters to mark the position where the character can jump up and down, thereby saving a lot of time for manual arrangement. In a specific example, the following configuration parameters can be pre-set:
[0072] (1) Tile Width: This parameter is used to control the spacing between generated links, and to control the density between multiple navigation links to prevent multiple adjacent navigation links from being too dense.
[0073] (2)OneMinLinkWidth: used to control the minimum edge width for placing at least one Link. As long as the length of the boundary line of the navigation grid is not less than the minimum edge width, a Link can be generated.
[0074] (3) Max Drop Height: used to control the maximum height at which a link can be generated. That is, when the first grid boundary line and the second grid boundary line are adjacent in the vertical direction, a navigation link can be established only if the height difference between the two grid boundary lines is not greater than the value of this parameter.
[0075] (4) Max Jump Height: The maximum height that can generate a bidirectional link. The value of this parameter must be less than or equal to the value of Max Drop Height. For example, a bidirectional navigation link can only be established if the height difference between the grid boundary lines is not greater than the value of this parameter.
[0076] (5)Raycast Layer Mask: The Layer Mask used by the algorithm ray detection, usually filled with StageCollider, is used to control the level of ray detection so that the ray detection process is limited to the specified ray level range.
[0077] (6) Max Horizontal Distance: This parameter is used to control the maximum horizontal distance at which a link can be generated. That is, when grid boundaries are adjacent in the horizontal direction, a navigation link can be established only if the horizontal distance between the two grid boundaries is not greater than the value of this parameter.
[0078] (7)Horizontal Step: It is used to control the step length of horizontal detection. The lower the value, the more accurate the result is, but the calculation takes longer. For example, if the parameter value is 0.6 meters, a 0.6-meter ray will be shot horizontally for the first time. If no obstacle is detected, a 1.2-meter ray will be shot horizontally, and so on.
[0079] (8) Wall Check Tolerance: It is used to control the distance to which the starting point is raised during horizontal detection, and can be used to bypass railings, etc. This parameter can also be called the horizontal elevation parameter. This parameter is mainly used to elevate the horizontal detection ray when performing horizontal ray detection, so that the elevated horizontal detection ray can bypass obstacles such as railings. For example, assuming that the virtual scene contains a large number of railings with a height of 0.4 meters, in order to avoid misdetecting the railings when performing horizontal obstacle detection through horizontal detection rays, it is necessary to raise the vertical coordinate of the starting point of the horizontal detection ray by 0.4 meters (that is, the parameter value of the horizontal elevation parameter) before performing horizontal ray detection operations.
[0080] In summary, this method can automatically establish a navigation link between two adjacent grid boundary lines by ray detection, thereby eliminating the tedious operation of manually creating links, which is efficient and error-prone. In addition, this method can also establish one-way navigation links or two-way navigation links according to different situations, thereby meeting the needs of different scenarios. Moreover, the preset spacing threshold used to determine whether to establish a navigation link can also be dynamically set according to the role level information of the character, thereby meeting the personalized needs of different roles.
[0081] Figure 3 A navigation grid linking device provided by another embodiment of the present invention is shown, comprising:
[0082] An acquisition module 31, adapted to acquire a navigation grid contained in a virtual scene;
[0083] A traversal module 32, adapted to traverse each grid boundary line of the navigation grid;
[0084] The transmitting module 33 is adapted to transmit rays based on each grid boundary line as a reference;
[0085] A judgment module 34 is adapted to obtain the ray detection results corresponding to each grid boundary line, and judge whether there are at least two grid boundary lines that meet the linking condition according to the ray detection results;
[0086] The establishing module 35 is adapted to establish a navigation link between the at least two grid boundary lines that meet the linking condition.
[0087] In an optional implementation, the transmitting module is specifically adapted to:
[0088] For any grid boundary line, taking the grid boundary line as a reference, and emitting a plurality of rays in sequence along a first direction according to a first detection step length, so as to detect whether there is a grid boundary line meeting the linking condition in the first direction;
[0089] Taking the grid boundary line as a reference, and emitting a plurality of rays in sequence along a second direction according to a second detection step length, so as to detect whether there is a grid boundary line meeting the linking condition in the second direction; wherein the first direction is perpendicular to the second direction;
[0090] The linking condition includes: the distance between two grid boundary lines is less than a preset spacing threshold.
[0091] In an optional implementation, the judgment module is specifically adapted to:
[0092] When the distance between the first grid boundary line and the second grid boundary line is less than a preset distance threshold, further acquiring a first grid attribute of the first grid boundary line and a second grid attribute of the second grid boundary line;
[0093] According to the first grid attribute and the second grid attribute, it is determined whether the first grid boundary line and the second grid boundary line meet a linking condition.
[0094] In an optional implementation, the establishing module is specifically adapted to:
[0095] determining, according to a relative positional relationship between the first grid boundary line and the second grid boundary line, whether the first grid boundary line and the second grid boundary line are a set of bidirectionally linkable boundary lines;
[0096] If so, establishing a bidirectional navigation link between the first grid boundary line and the second grid boundary line;
[0097] If not, a one-way navigation link is established between the first grid boundary line and the second grid boundary line.
[0098] In an optional implementation, the establishing module is specifically adapted to:
[0099] Acquire first coordinate information corresponding to the first grid boundary line and second coordinate information corresponding to the second grid boundary line;
[0100] Determining whether the first grid boundary line is located at a preset position of the second grid boundary line according to the first coordinate information and the second coordinate information;
[0101] If so, a navigation link is established between the first grid boundary line and the second grid boundary line.
[0102] In an optional implementation, the establishing module is further adapted to:
[0103] Obtaining a first link endpoint and a second link endpoint of the navigation link;
[0104] Determining whether the first link endpoint matches the position of the first grid boundary line, and / or whether the second link endpoint matches the position of the second grid boundary line;
[0105] If not, the positions of the unmatched first link endpoint and / or second link endpoint are adjusted so that the adjusted first link endpoint matches the position of the first grid boundary line, and the second link endpoint matches the position of the second grid boundary line.
[0106] In an optional implementation, the preset distance threshold is dynamically set according to role level information of the human character.
[0107] The specific structure and working principle of each of the above modules can be referred to the description of the corresponding part of the method embodiment, which will not be repeated here.
[0108] Another embodiment of the present application provides a non-volatile computer storage medium, which stores at least one executable instruction, which can execute the navigation grid linking method in any of the above method embodiments. The executable instruction can be specifically used to enable the processor to execute the corresponding operations in the above method embodiments.
[0109] Figure 4 A schematic structural diagram of an electronic device according to another embodiment of the present invention is shown. The specific embodiment of the present invention does not limit the specific implementation of the electronic device.
[0110] like Figure 4 As shown, the electronic device may include: a processor (processor) 502 , a communication interface (Communications Interface) 506 , a memory (memory) 504 , and a communication bus 508 .
[0111] in:
[0112] The processor 502 , the communication interface 506 , and the memory 504 communicate with each other via a communication bus 508 .
[0113] The communication interface 506 is used to communicate with other devices such as clients or other servers.
[0114] The processor 502 is used to execute the program 510, and specifically can execute the relevant steps in the above-mentioned embodiment of the method for linking the navigation grid.
[0115] Specifically, the program 510 may include program codes, which include computer operation instructions.
[0116] The processor 502 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiment of the present invention. The one or more processors included in the electronic device may be processors of the same type, such as one or more CPUs. They may also be processors of different types, such as one or more CPUs and one or more ASICs.
[0117] The memory 504 is used to store the program 510. The memory 504 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0118] The program 510 may be specifically used to enable the processor 502 to execute the corresponding operations in the above-mentioned navigation grid linking method embodiment.
[0119] The algorithm and display provided herein are not inherently related to any particular computer, virtual device or other equipment. Various general-purpose devices can also be used together with the teachings based on this. According to the above description, it is obvious to construct the structure required for this type of device. In addition, the present invention is not directed to any specific programming language either. It should be understood that various programming languages can be utilized to realize the content of the present invention described herein, and the description of the above specific language is for the purpose of disclosing the best mode of the present invention.
[0120] In the description provided herein, a large number of specific details are described. However, it is understood that embodiments of the present invention can be practiced without these specific details. In some instances, well-known methods, structures and techniques are not shown in detail so as not to obscure the understanding of this description.
[0121] Similarly, it should be understood that in order to streamline the present disclosure and aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of the present invention, various features of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. However, this method of disclosure should not be interpreted as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim.
[0122] Those skilled in the art will appreciate that the modules in the devices in the embodiments may be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments may be combined into one module or unit or component, and in addition they may be divided into a plurality of submodules or subunits or subcomponents. Except that at least some of such features and / or processes or units are mutually exclusive, all features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed in this manner may be combined in any combination. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature providing the same, equivalent or similar purpose.
[0123] In addition, those skilled in the art will appreciate that, although some embodiments herein include certain features included in other embodiments but not other features, the combination of features of different embodiments is meant to be within the scope of the present invention and form different embodiments. For example, any one of the claimed embodiments may be used in any combination.
[0124] The various component embodiments of the present invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. It should be understood by those skilled in the art that a microprocessor or digital signal processor (DSP) may be used in practice to implement some or all of the functions of some or all of the components in the apparatus according to an embodiment of the present invention. The present invention may also be implemented as a device or device program (e.g., a computer program and a computer program product) for executing part or all of the methods described herein. Such a program implementing the present invention may be stored on a computer-readable medium, or may have the form of one or more signals. Such a signal may be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.
[0125] It should be noted that the above embodiments illustrate the present invention rather than limit it, and that those skilled in the art may devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference symbol between brackets shall not be construed as a limitation on the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "one" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present invention may be implemented by means of hardware comprising a number of different elements and by means of a suitably programmed computer. In a unit claim enumerating a number of devices, several of these devices may be embodied by the same hardware item. The use of the words first, second, and third, etc., does not indicate any order. These words may be interpreted as names.
Claims
1. A method for linking a navigation grid, the method comprising: Get the navigation mesh contained in the virtual scene; Traversing each grid boundary line of the navigation grid; Emit rays based on each grid boundary line; Obtaining the ray detection results corresponding to each grid boundary line, and judging whether there are at least two grid boundary lines that meet the linking condition according to the ray detection results; If so, establishing a navigation link between the at least two grid boundary lines that meet the linking condition; wherein, judging whether there are at least two grid boundary lines that meet the linking condition according to the ray detection result includes: when the distance between the first grid boundary line and the second grid boundary line is less than a preset distance threshold, further acquiring a first grid attribute of the first grid boundary line and a second grid attribute of the second grid boundary line; judging whether the first grid boundary line and the second grid boundary line meet the linking condition according to the first grid attribute and the second grid attribute; wherein, establishing a navigation link between the at least two grid boundary lines that meet the linking condition includes: judging whether the first grid boundary line and the second grid boundary line are a group of bidirectionally linkable boundary lines according to the relative position relationship between the first grid boundary line and the second grid boundary line; if so, establishing a bidirectional navigation link between the first grid boundary line and the second grid boundary line; if not, establishing a unidirectional navigation link between the first grid boundary line and the second grid boundary line.
2. The method according to claim 1, wherein: The emitting rays based on each grid boundary line as a reference comprises: For any grid boundary line, taking the grid boundary line as a reference, and emitting a plurality of rays in sequence along a first direction according to a first detection step length, so as to detect whether there is a grid boundary line meeting the linking condition in the first direction; Taking the grid boundary line as a reference, and emitting a plurality of rays in sequence along a second direction according to a second detection step length, so as to detect whether there is a grid boundary line meeting the linking condition in the second direction; wherein the first direction is perpendicular to the second direction; The linking condition includes: the distance between two grid boundary lines is less than a preset spacing threshold.
3. The method according to claim 1, wherein: The step of establishing a navigation link between at least two grid boundary lines meeting the link condition comprises: Acquire first coordinate information corresponding to the first grid boundary line and second coordinate information corresponding to the second grid boundary line; Determining whether the first grid boundary line is located at a preset position of the second grid boundary line according to the first coordinate information and the second coordinate information; If so, a navigation link is established between the first grid boundary line and the second grid boundary line.
4. The method according to any one of claims 1 to 3, wherein: After the navigation link is established between the at least two grid boundary lines that meet the link condition, the method further includes: Obtaining a first link endpoint and a second link endpoint of the navigation link; Determining whether the first link endpoint matches the position of the first grid boundary line, and / or whether the second link endpoint matches the position of the second grid boundary line; If not, the positions of the unmatched first link endpoint and / or second link endpoint are adjusted so that the adjusted first link endpoint matches the position of the first grid boundary line, and the second link endpoint matches the position of the second grid boundary line.
5. The method according to claim 2, wherein: The preset distance threshold is dynamically set according to the role level information of the human character.
6. A navigation grid linking device, the device comprising: An acquisition module, adapted to acquire a navigation mesh contained in a virtual scene; A traversal module, adapted to traverse each grid boundary line of the navigation grid; A transmitting module, adapted to transmit rays based on each grid boundary line as a reference; A judgment module, adapted to obtain the ray detection results corresponding to each grid boundary line, and judge whether there are at least two grid boundary lines that meet the linking condition according to the ray detection results; An establishing module, adapted to establish a navigation link between at least two grid boundary lines that meet the linking condition; The judgment module is specifically adapted to: when the distance between the first grid boundary line and the second grid boundary line is less than a preset distance threshold, further obtain a first grid attribute of the first grid boundary line and a second grid attribute of the second grid boundary line; and judge whether the first grid boundary line and the second grid boundary line meet a link condition according to the first grid attribute and the second grid attribute; wherein establishing a navigation link between the at least two grid boundary lines that meet the link condition comprises: judging whether the first grid boundary line and the second grid boundary line are a group of bidirectionally linkable boundary lines according to a relative position relationship between the first grid boundary line and the second grid boundary line; if so, establishing a bidirectional navigation link between the first grid boundary line and the second grid boundary line; if not, establishing a unidirectional navigation link between the first grid boundary line and the second grid boundary line.
7. An electronic device comprising: A processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to execute the method according to any one of claims 1 to 5.
8. A computer storage medium, wherein at least one executable instruction is stored in the storage medium, and the executable instruction enables a processor to execute the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Map data, map data production method, storage medium and navigation apparatus
CN102142023A
Route generation method and device for three-dimensional game scene, and storage medium
CN110772791A
Systems and methods for identifying grid of geographic regions in map
CN111831772A
Navigation grid generation method and device, nonvolatile storage medium and electronic device
CN112386911A
Method and device for automatically generating map area link, equipment and storage medium
CN113521741A
