Grid model collision detection method and device and electronic equipment

By constructing a pre-computed volume for collision detection of the mesh model during the offline phase of the game, the problem of high complexity in mesh model collision detection is solved, achieving low performance consumption and high efficiency in collision detection, which is suitable for game scenarios.

CN121544829APending Publication Date: 2026-02-17NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511374240.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-24
Publication Date
2026-02-17

AI Technical Summary

Technical Problem

In existing technologies, collision detection using mesh models is highly complex, resulting in significant performance and memory consumption. This is especially problematic in games where extensive collision detection is required, impacting game smoothness.

Method used

By constructing a pre-computed volume during the offline phase of the game—a polygonal model that surrounds the target mesh model with fewer faces than the target mesh model—collision detection is performed using the pre-computed volume, reducing performance consumption during the game runtime.

Benefits of technology

It reduces the performance consumption of collision detection during game operation, improves collision detection efficiency, and quickly locates collision points, making it suitable for mobile devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121544829A_ABST
    Figure CN121544829A_ABST
Patent Text Reader

Abstract

The invention provides a collision detection method and device for a grid model and electronic equipment, and the method comprises the steps: determining a target grid model which can be collided by an incident model from a game scene based on the emission position and the emission direction of the incident model when the incident model is emitted in the game scene; determining an entry target surface from a pre-calculation body of the target grid model based on the emission direction; the pre-calculation body is a polygon model which is determined in the game offline stage and surrounds all vertexes contained in the target mesh model, and the number of faces of the pre-calculation body is smaller than that of faces of the target mesh model; determining the collision position of the incident model on the surface of the target grid model based on the corresponding relation between the target surface and the collision point on the surface of the target grid model; the corresponding relation of the collision points of the target surface and the surface of the target grid model is determined in the game offline stage. According to the mode, through the pre-calculation data of the model in the game offline stage, the performance consumption of model collision detection in the game running stage is reduced, and the collision detection efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the fields of computer graphics and game development, and in particular to a collision detection method, apparatus, and electronic device for a mesh model. Background Technology

[0002] The game includes a large number of collision models, which need to be collision detected. Since collision models are usually composed of triangular facets, and the collision detection complexity between triangular facets is O(n²), that is, two collision models each with 1K triangular facets need to be collision detected millions of times, resulting in a large performance consumption and memory overhead for collision detection. Summary of the Invention

[0003] In view of this, the purpose of this disclosure is to provide a collision detection method, apparatus and electronic device for mesh models to reduce the performance consumption of model collision detection.

[0004] In a first aspect, embodiments of this disclosure provide a collision detection method for a mesh model. The method includes: in response to launching an incident model in a game scene, determining the launch position and launch direction corresponding to the incident model; based on the launch position and launch direction, determining a target mesh model that the incident model can collide with from the game scene; based on the launch direction, determining a target face from a pre-computed volume of the target mesh model; wherein the pre-computed volume is a polygonal model enclosing each vertex of the target mesh model, determined during the offline phase of the game, and the number of faces of the pre-computed volume is less than the number of faces of the target mesh model; and determining the collision position of the incident model on the surface of the target mesh model based on the correspondence between the target face and the collision points on the surface of the target mesh model; wherein the correspondence between the target face and the collision points on the surface of the target mesh model is determined during the offline phase of the game.

[0005] Secondly, embodiments of this disclosure also provide a collision detection device for a mesh model. The device includes: a launch information determination module, configured to determine the launch position and launch direction of the incident model in response to launching an incident model in a game scene; a model determination module, configured to determine a target mesh model that the incident model can collide with from the game scene based on the launch position and launch direction; a collision surface determination module, configured to determine a target surface from a pre-calculated volume of the target mesh model based on the launch direction; wherein the pre-calculated volume is a polygonal model enclosing each vertex of the target mesh model, determined during the offline phase of the game, and the number of faces in the pre-calculated volume is less than the number of faces in the target mesh model; and a collision position determination module, configured to determine the collision position of the incident model on the surface of the target mesh model based on the correspondence between the target surface and the collision points on the surface of the target mesh model; wherein the correspondence between the target surface and the collision points on the surface of the target mesh model is determined during the offline phase of the game.

[0006] Thirdly, this disclosure provides an electronic device including a processor and a memory, the memory storing machine-executable instructions that can be executed by the processor, the processor executing the machine-executable instructions to implement the collision detection method of the mesh model described above.

[0007] Fourthly, this disclosure provides a computer-readable storage medium storing computer-executable instructions that, when invoked and executed by a processor, cause the processor to implement the collision detection method of the aforementioned mesh model.

[0008] The embodiments disclosed herein bring the following beneficial effects: This disclosure provides a collision detection method, apparatus, and electronic device for mesh models. First, in response to launching an incident model into a game scene, the launch position and direction of the incident model are determined. Then, based on the launch position and direction, a target mesh model that the incident model can collide with is determined from the game scene. Next, based on the launch direction, a target face is determined from a pre-computed volume of the target mesh model. The pre-computed volume is a polygonal model enclosing the vertices of the target mesh model, determined during the offline game phase, and the number of faces in the pre-computed volume is less than the number of faces in the target mesh model. Then, based on the correspondence between the target face and the collision points on the target mesh model surface, the collision position of the incident model on the target mesh model surface is determined. The correspondence between the target face and the collision points on the target mesh model surface is determined during the offline game phase. This method, by pre-compiling model data during the offline game phase, can reduce the performance overhead of collision detection during game execution, improve collision detection efficiency, and quickly locate collision positions.

[0009] Other features and advantages of this disclosure will be set forth in the following description and will be apparent in part from the description or may be learned by practicing the disclosure. The objects and other advantages of this disclosure are realized and obtained through the structures particularly pointed out in the description, claims and drawings.

[0010] To make the above-mentioned objects, features and advantages of this disclosure more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0011] To more clearly illustrate the technical solutions in the specific embodiments of this disclosure or the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0012] Figure 1 A flowchart illustrating a collision detection method for a mesh model provided in this embodiment of the disclosure; Figure 2 This is a schematic diagram of a pre-computed volume generation method provided in an embodiment of the present disclosure; Figure 3 This is a schematic diagram illustrating close sampling of a target mesh model according to an embodiment of the present disclosure; Figure 4 A schematic diagram of the structure of a collision detection device for a mesh model provided in an embodiment of this disclosure; Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation

[0013] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this disclosure, and not all embodiments. The components of the embodiments of this disclosure described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.

[0014] Therefore, the following detailed description of the embodiments of this disclosure provided in the accompanying drawings is not intended to limit the scope of the claimed disclosure, but merely to illustrate selected embodiments of the disclosure. All other embodiments obtained by those skilled in the art based on the embodiments of this disclosure without inventive effort are within the scope of protection of this disclosure.

[0015] In game development, fast collision calculation of mesh models is a core requirement for physics engines and collision detection systems. Among related technologies, mesh model collision calculation can be performed based on bounding volume hierarchy (BVH), distance field (SDF), or continuous collision detection (CCD). However, dynamic mesh models require BVH updates every frame, and the hierarchical structure consumes a lot of storage. At the same time, coarse-grained bounding boxes may lead to false collisions. High-precision SDF requires a lot of storage, which is not suitable for the memory space of mobile devices. CCD requires multiple iterations to detect motion paths, resulting in high performance overhead.

[0016] To address the aforementioned issues, this disclosure provides a collision detection method, apparatus, and electronic device for mesh models. This technology is applied to scenarios where collision detection is performed on game models, such as a scenario where bullets are fired at a spaceship in a game.

[0017] From an art production perspective, collision mesh optimization is key to balancing visual effects and performance. When creating scene props, simplified collision meshes are typically created for complex models. For example, an intricately carved stone pillar might contain tens of thousands of faces for rendering, but collision detection only uses a simplified cylinder with 8-12 faces. This approach allows players to appreciate the exquisite architectural details while ensuring a smooth climbing experience when climbing in architectural game scenes—the character won't get stuck on decorative details but will move along reasonable geometric surfaces.

[0018] In interactive scene design, collision detection is crucial to the player experience. Take treasure chests in RPG games as an example: precise collision boundaries are set for the chest model to ensure that the player can only trigger the opening animation when standing in a reasonable position. Simultaneously, the opening and closing process of the chest lid requires real-time collision detection to prevent collisions with the surrounding environment. Furthermore, in the environmental destruction system of action games, each destructible object (barrel, stone wall, glass window) requires a multi-layered collision mesh: the outer layer for weapon attack detection, and the inner layer for fragment physics simulation. This is essential to achieve believable environmental destruction effects, making every explosion feel realistic and credible.

[0019] The collision detection method for a mesh model in one embodiment of this disclosure can run on a local terminal device or a server. When the collision detection method for a mesh model runs on a server, the method can be implemented and executed based on a cloud interaction system, wherein the cloud interaction system includes a server and client devices.

[0020] In an optional implementation, various cloud applications, such as cloud gaming, can run under the cloud interaction system. Taking cloud gaming as an example, cloud gaming refers to a gaming method based on cloud computing. In the cloud gaming operating mode, the game program and the game screen presentation are separated. The storage and execution of the collision detection method for the mesh model are completed on the cloud gaming server. The client device is used for data reception, transmission, and game screen presentation. For example, the client device can be a display device with data transmission capabilities located close to the user, such as a mobile terminal, television, computer, or PDA; however, the information processing is performed by the cloud gaming server in the cloud. When playing the game, the player operates the client device to send operation commands to the cloud gaming server. The cloud gaming server runs the game according to the operation commands, encodes and compresses the game screen and other data, returns it to the client device via the network, and finally, the client device decodes and outputs the game screen.

[0021] In an optional implementation, taking a game as an example, the local terminal device stores the game program and is used to display the game screen. The local terminal device is used to interact with the player through a graphical user interface (GUI), i.e., conventionally by downloading, installing, and running the game program via an electronic device. The local terminal device can provide the GUI to the player in various ways, such as rendering it on the terminal's display screen or providing it to the player via holographic projection. For example, the local terminal device can include a display screen for displaying the GUI, which includes game screens, and a processor for running the game, generating the GUI, and controlling the display of the GUI on the display screen.

[0022] In one possible implementation, embodiments of this disclosure provide a collision detection method for a mesh model, such as... Figure 1 As shown, the method includes the following specific steps: Step S102: In response to launching the incident model in the game scene, determine the launch position and launch direction corresponding to the incident model.

[0023] In practice, the aforementioned incident model can be a cannonball, missile, or bullet in the game scene. Users can launch the incident model in a certain direction in the game scene through their terminal devices. When launching the incident model in the game scene, it is necessary to record the launch position and launch direction of the incident model.

[0024] Step S104: Based on the launch position and launch direction, determine the target mesh model that the incident model can collide with from the game scene.

[0025] After launching an incident model into the game scene, a target mesh model that the incident model can collide with can be determined from multiple mesh models contained in the game scene based on the incident model's attributes, launch position, and launch direction. The attributes of the incident model may include, but are not limited to, its range and power. The target mesh model is a mesh model in the game scene located along the launch direction of the incident model and within its range.

[0026] Step S106: Based on the launch direction, determine the target face from the pre-computed volume of the target mesh model; wherein, the pre-computed volume is a polygonal model that surrounds each vertex of the target mesh model, determined during the offline phase of the game, and the number of faces in the pre-computed volume is less than the number of faces in the target mesh model.

[0027] In practice, the pre-computed volume of the target mesh model is calculated during the offline phase of the game. This pre-computed volume is a polygonal model that can enclose the target mesh model. The number of model faces contained in this polygonal model is less than the number of model faces contained in the target mesh model.

[0028] Since the number of faces in the pre-computed volume is less than the number of faces in the target mesh model, the performance cost of collision detection based on the pre-computed volume will be much lower than that based on the target mesh model. Specifically, the angle between the emission direction of the incident model and the normal direction of each face in the pre-computed volume can be calculated, and the face with the smallest angle can be determined as the target face; alternatively, the angle between the emission direction of the incident model and each face in the pre-computed volume can be calculated, and the face with the angle within a preset range can be determined as the target face.

[0029] Step S108: Based on the correspondence between the collision points of the target surface and the target mesh model surface, determine the collision position of the incident model on the target mesh model surface; wherein, the correspondence between the collision points of the target surface and the target mesh model surface is determined during the offline phase of the game.

[0030] During the offline phase of the game, after calculating the pre-computed volume of the target mesh model, the correspondence between each face in the pre-computed volume and the collision points on the surface of the target mesh model can be calculated. This correspondence indicates which collision points on the target mesh model surface each face in the pre-computed volume corresponds to. The number and location of the collision points on the target mesh model surface can be randomly determined or determined according to preset rules. It should be noted that a face in the pre-computed volume can correspond to one or more collision points on the target mesh model surface.

[0031] During the game's execution phase, after the user launches an incident model in the game scene, the system needs to determine the target mesh model that the incident model can collide with based on the launch position and direction of the incident model. Then, it needs to determine the target surface from the pre-calculated volume of the target mesh model. Finally, it needs to determine a target collision point from the collision points that correspond to the target surface of the target mesh model. The position of this target collision point on the surface of the target mesh model is also the collision position of the incident model on the surface of the target mesh model.

[0032] In practical implementation, the collision point closest to the launch position among the collision points that correspond to the target mesh model surface and the target surface can be determined as the target collision point, or the point with the highest or lowest preset score corresponding to the target surface can be determined as the target collision point, etc.

[0033] This disclosure provides a collision detection method for a mesh model. By pre-compiling data for the model during the offline phase of the game, the performance consumption of collision detection during the game runtime can be reduced, and the collision detection efficiency can be improved and the collision location can be quickly located.

[0034] The following examples describe a method for determining pre-computed volumes during the offline phase of a game.

[0035] Specifically, the pre-computed volume of the target mesh model is determined in the following way: during the offline phase of the game, the target mesh model is obtained; wherein, the target mesh model consists of multiple model faces, and each model face includes multiple vertices; based on the vertex positions and vertex normal directions corresponding to the vertices contained in the target mesh model, the model faces of the target mesh model are merged to obtain multiple merged faces; the multiple merged faces are offset to generate a pre-computed volume surrounding each vertex contained in the target mesh model.

[0036] In practical implementation, the target mesh model can be any collideable mesh model set in the game scene. For example, the target mesh model can be a spaceship model, yacht model, or tank model in the game scene. The target mesh model is composed of multiple model faces, and each model face includes at least three vertices.

[0037] After obtaining the target mesh model, convex hull calculation is performed on it. However, traditional convex hull calculation uses the tangent surfaces of the target mesh model to form the minimum bounding surface. This results in an excessive number of model faces in the calculated convex hull model when there are too many model faces in the target mesh model. In other words, the convex hull model completely overlaps with the target mesh model on the curved surface, thus affecting branching efficiency and consuming excessive memory. Therefore, this disclosure improves the traditional convex hull calculation method.

[0038] To avoid having too many model faces on the curved surface, the improved convex hull calculation merges the faces by taking the normal directions of the vertices contained in the target mesh model, and offsets them according to the positions of the merged vertices to obtain a pre-computed volume that can surround the vertices contained in the target mesh model.

[0039] In an optional embodiment, the specific process of merging the model faces of the target mesh model based on the vertex positions and vertex normal directions of the vertices contained in the target mesh model to obtain multiple merged faces may include: for each vertex in the target mesh model, determining the connecting face containing the current vertex from the target mesh model, and identifying whether the connecting face of the current vertex meets a preset condition; if it does, determining the current vertex as a degenerate point; determining a first model face from the model faces of the target mesh model where all vertices are degenerate points; and merging the model faces of the target mesh model based on the vertex positions and vertex normal directions of the degenerate points contained in the first model face to obtain multiple merged faces.

[0040] In practical implementation, each vertex in the target mesh model needs to be treated as a current vertex. Connecting surfaces containing the current vertex are determined from the target mesh model. Typically, one vertex corresponds to at least two connecting surfaces. Then, it is calculated whether the connecting surfaces of the current vertex satisfy a preset condition. If the preset condition is not satisfied, the current vertex is skipped and the calculation continues to the next vertex. If the preset condition is satisfied, the current vertex is designated as a degenerate point. The preset condition can be that the positional relationship of the connecting surfaces of the current vertex is a preset positional relationship, or that the included angle between the connecting surfaces of the current vertex is less than a preset angle threshold, such as 20 degrees or 25 degrees.

[0041] After determining whether all points in the target mesh model are degenerate points, a first model face is identified from the model faces of the target mesh model, where all vertices are degenerate points. Degeneracy calculations are then performed on each degenerate point contained in the first model face. This involves merging the model faces of the target mesh model based on the vertex positions and vertex normal directions of the degenerate points contained in the first model face, resulting in multiple merged faces.

[0042] In an optional embodiment, the specific process of merging the model faces of the target mesh model based on the vertex positions and vertex normal directions of the degenerate points contained in the first model face to obtain multiple merged faces may include: for each first model face, performing the following operations: for each degenerate point contained in the first model face, determining the first vertex in the target mesh model connected to the current degenerate point, and identifying the midpoint of the line connecting the current degenerate point and the first vertex; connecting the midpoints corresponding to each degenerate point contained in the first model face to obtain the merged face corresponding to the first model face.

[0043] In practical implementation, the target mesh model contains multiple first vertices connected to the current degenerate point. It's necessary to calculate the lines connecting the current degenerate point to each first vertex, as well as the midpoints on each line. Additionally, the average normal direction corresponding to the current degenerate point needs to be calculated and saved, along with its midpoint and average normal direction. After obtaining the midpoints corresponding to each degenerate point within the first model surface, connecting these midpoints yields the merged surface corresponding to the first model surface. Integrating all the merged surfaces corresponding to the first model surfaces results in multiple merged surfaces. In an optional embodiment, for each of the multiple merged surfaces, the mass point and the average normal direction of the mass point of the current merged surface are determined, and each edge of the current merged surface is translated along the average normal direction of the mass point until each edge is tangent to a vertex in the target mesh model, thereby obtaining the translated merged surface corresponding to the current merged surface; the translated merged surfaces corresponding to each of the multiple merged surfaces are integrated to obtain a pre-computed volume surrounding each vertex contained in the target mesh model.

[0044] In practice, the average normal direction of the particles is obtained by weighting the average normal direction of the degenerate points corresponding to the current merged surface. The weight of each average normal direction can be determined based on the distance between the particles and the degenerate points, or it can be determined in other ways. No specific limitation is made here.

[0045] In practical applications, the specific process of translating each edge of the current merged surface along the average normal direction of the mass point until each edge is tangent to a vertex in the target mesh model to obtain the translated merged surface can include: for each edge of the current merged surface, translating the current edge along the average normal direction of the mass point until the current edge is tangent to a vertex in the target mesh model to obtain the translated edge corresponding to the current edge; connecting the translated edges corresponding to each edge of the current merged surface to obtain the translated merged surface corresponding to the current merged surface. The translated merged surface is located outside the target mesh model.

[0046] In the specific implementation, each edge in the current merged surface is treated as a current edge. Then, the current edge is translated along the direction of the average normal to the corresponding mass point of the current merged surface. During the translation, it is determined whether the current edge is tangent to a vertex in the target mesh model. If so, the translation stops, and the current edge at this point is defined as the translated current edge. The position coordinates of the two endpoints of the translated current edge are recorded. After obtaining the position coordinates of the endpoints corresponding to all edges in the current merged surface, the surface enclosed by the position coordinates of all endpoints is defined as the translated merged surface corresponding to the current merged surface.

[0047] In an optional embodiment, the current edge can be gradually extended during the translation process so that the current edge is always connected to other edges in the current merged surface. Thus, after all edges in the current merged surface have been translated, the resulting merged surface is the translated merged surface corresponding to the current merged surface.

[0048] like Figure 2 The diagram shown is a schematic representation of a method for generating a pre-computed volume according to an embodiment of this disclosure. Figure 2 The black lines without arrows represent edges on the target mesh model, and vertices A, B, and C represent vertices on the target mesh model. Taking vertex B as an example, the connecting faces of vertex B are faces AB and BC. The angle between faces AB and BC is calculated to see if it is less than a preset angle threshold. If it is, vertex B is marked as a degenerate point. When all vertices of any face in the target mesh model are marked as degenerate points, that face is determined as the first model face, and degeneracy calculations are performed on all degenerate points on the first model face.

[0049] Figure 2Vertex B in the model is a degenerate point in the first model face. The degeneracy calculation for vertex B is described below, including: determining the first vertices connected to vertex B as vertices A and C; then calculating the midpoints of line segments AB and DC, and the average normal directions for vertices A, B, and C respectively. The average normal direction here is also... Figure 2 The arrow direction in the middle; then, after collecting all the calculated midpoints in the first model surface, a merged surface corresponding to the first model surface is generated, and the particle and the average normal direction of the particle are calculated for the merged surface. For each merged surface, each edge in the current merged surface is translated along the corresponding average normal direction of the particle until the vertex of the surface tangent corresponds to the edge of the target mesh model, thus obtaining the moved edge (i.e., the... Figure 2 The line segment DE is processed, and the position coordinates of the endpoints of the moved edge are recorded, which are the positions of vertices D and E. This process continues until all edges in the current merged face are processed, and the face enclosed by the endpoints corresponding to all recorded position coordinates is taken as the merged face after the move.

[0050] By stitching together all the moved and merged faces, the pre-computed volume corresponding to the target mesh model can be obtained. After obtaining the pre-computed volume, it is also necessary to calculate and save the midpoint and midpoint normal direction of each face contained in the pre-computed volume.

[0051] Furthermore, after generating the pre-computed volume surrounding each vertex of the target mesh model, it is necessary to perform tiling sampling on the outer surface of the target mesh model to obtain multiple collision points located on the surface of the target mesh model. For each collision point on the surface of the target mesh model, the positional relationship between the current collision point and each face in the pre-computed volume is determined, and the faces in the pre-computed volume that correspond to the current collision point are determined based on the positional relationship. The collision points that correspond to each face in the pre-computed volume are integrated respectively to obtain the collision points corresponding to each face in the pre-computed volume.

[0052] In practical implementation, tiling sampling is performed on the outer surface of the target mesh model to obtain points located on the surface of the target mesh model. These points are also the preset collision points of the target mesh model. This tiling sampling can be achieved by using identical shapes and sizes to tile the outer surface of the target mesh model, without gaps or overlaps, then sampling each shape to obtain multiple shapes, and determining the midpoint of each shape as the collision point on the target mesh model surface. For example... Figure 3 The diagram shown is a schematic representation of a method for tiling a target mesh model according to an embodiment of this disclosure. Figure 3 The 3D model in the image is the target mesh model, and the midpoint of the square facet on the target mesh model is the collision point.

[0053] In an optional embodiment, each collision point on the surface of the target mesh model can be connected to the midpoint of each face in the pre-computed volume. If the connection is occluded by the target mesh model, it is determined that there is no correspondence between the collision point and the face corresponding to the connection.

[0054] In another optional embodiment, the following operations are performed for each face in the pre-computed volume: determine the angle between the normal direction of the current collision point and the normal direction of the previous face; if the angle is less than a preset angle threshold, determine the distance between the current collision point and the current face, divide the distance by the boundary size parameter to obtain a distance score; determine whether the distance score is the minimum distance score corresponding to the current collision point; if so, perform ray occlusion detection on the current face to obtain a detection result; if the detection result meets the preset occlusion condition, update the minimum distance score corresponding to the current collision point, and determine the current face as a face that has a corresponding relationship with the current collision point.

[0055] In the specific implementation, for each face in the pre-computation volume, the angular compatibility between the current collision point and the current face is first calculated. This involves calculating the angle between the normal direction of the current collision point and the normal direction of the face before it (which could be the normal direction of the midpoint of the face before it). If this angle is greater than or equal to a preset angle threshold, the current face is excluded, and the next face before it is checked. If this angle is less than the preset angle threshold, the distance from the current collision point to the face before it is calculated. This distance is the shortest distance from the current collision point along the normal direction of the face before it to the face before it. This distance is then divided by the corresponding boundary size parameter to obtain a standardized distance score. This step ensures the comparability of mesh models of different sizes. The distance scores are then compared, meaning it is determined whether the distance score corresponding to the current face is the smallest among the distance scores corresponding to the current collision point. If not, the current face is skipped, and the angular compatibility of the next face before it is checked. If it is the smallest, perform ray occlusion detection. If the detection result meets the preset occlusion conditions, update the minimum distance score corresponding to the current collision point and determine the current face as the face that has a corresponding relationship with the current collision point. If the detection result does not meet the preset occlusion conditions, skip the current face and continue to detect the next face in front of it.

[0056] In an optional embodiment, the specific process of performing ray occlusion detection on the current face and obtaining the detection result may include: offsetting the current collision point along the normal direction of the current collision point by a first length, and offsetting it along the normal direction of the current face by a second length to obtain the offset current collision point; using the offset current collision point as the starting point, emitting a target ray along the normal direction of the current face, detecting whether the target ray is occluded by the target mesh model, and obtaining the detection result; wherein, when the detection result indicates that the target ray is not occluded by the target mesh model, it is determined that the detection result meets the preset occlusion condition.

[0057] In practical implementation, the specific lengths corresponding to the first and second lengths mentioned above can be determined according to R&D requirements. The first and second lengths can be the same or different. For example, the first and second lengths can be 0.1 meters or 0.2 meters, etc. Specifically, to avoid geometric accuracy issues, the current collision point is offset by the first length along the normal direction of the current collision point, and then offset by the second length along the current normal direction. From this offset position, a target ray is emitted along the current normal direction. If the target ray is occluded by the target mesh model, it means that the current face is unusable, and the next face is checked; if it is not occluded by the target mesh model, it means that there is a correspondence between the current face and the current collision point.

[0058] Optionally, if the current face passes all detections, the minimum distance score and optimal face index corresponding to the current collision point are updated. Here, the optimal face index is the model face corresponding to the minimum distance score. The minimum distance score and optimal face index corresponding to each collision point are saved so that the final collision position can be determined during the game run.

[0059] Furthermore, for the current collision point, after all faces in the pre-computed volume have been detected, it is checked whether a face with a corresponding relationship has been found. If the optimal face index is still -1, i.e., an empty set, it means that no face with a corresponding relationship has been found. At this time, the current collision point is marked as an invalid point and can be deleted.

[0060] After the above calculations, the collision points corresponding to each face in the pre-calculated volume can be obtained and saved.

[0061] Simultaneously, to ensure the visual appeal, it's desirable for the target mesh model to move along a line. Therefore, neighboring points between collision points are recorded to enable path tracking of the target mesh model. Based on this, the nearest neighboring points are calculated for each collision point, as follows: First, the code iterates through each point in the point cloud. For the current point, it records its spatial position and normal direction. Then, it initializes an empty list to store the indices of possible connection points that might be connected to the current point. The point cloud here includes all collision points on the surface of the target mesh model.

[0062] Next, for the current point, the code iterates through all other points in the point cloud again to perform pairing checks. Cases comparing with itself are skipped to avoid self-connections. This pairing check involves the algorithm performing the following two geometric condition checks on each pair of points: The first condition is the compatibility check of the normal directions, which involves calculating the dot product of the normal directions of two points. This value reflects the similarity between the two normal directions. If the dot product value is less than 0.5, it means that the angle between the two normal directions is greater than 60 degrees (because 60 degrees cosine equals 0.5). In this case, the orientation difference between the two points is considered too great, and they are not suitable for connection. Therefore, this pair of points is skipped.

[0063] The second condition is spatial proximity detection, which is to calculate the Euclidean distance between two points. If this distance is less than the preset proximity detection distance threshold, it means that the two points are close enough in space.

[0064] The collision point's index is added to the list of connectable points only when both conditions are met: the normal directions of the two points are similar and their spatial distance is sufficiently close. Essentially, this algorithm builds a proximity graph in the point cloud based on geometric features, connecting each point only to points that are both spatially proximate and compatible in their normal directions. This filtering mechanism ensures that connected point pairs are geometrically consistent, providing high-quality proximity data for subsequent applications such as mesh generation, surface reconstruction, or path planning.

[0065] The 0.5 threshold and the nearest neighbor detection distance are two key parameters in the algorithm, which control the strictness of normal similarity and the range of spatial proximity, respectively. These parameters can be adjusted according to specific application scenarios to obtain different connection effects.

[0066] Based on the above, two tables can be recorded. One table records the midpoint, normal direction, and corresponding collision points of each face of the pre-calculated volume; the other table records the position, normal, and adjacent points of each collision point on the surface of the target mesh model.

[0067] The following examples describe how to determine the target surface and collision location during the game's runtime phase.

[0068] Specifically, the process of determining the target surface from the pre-calculated volume of the target mesh model based on the launch direction can include: determining the angle between the launch direction and the normal direction of each surface in the pre-calculated volume of the target mesh model; and determining the surface in the pre-calculated volume whose angle meets the preset angle requirement as the target surface.

[0069] In practical implementation, it is necessary to calculate the angle between the launch direction and the normal direction of each face in the pre-calculated volume of the target mesh model, and determine the face whose angle meets the preset angle requirement. This face is then designated as the target face. The preset angle requirement can be the face with the angle closest to 180 degrees, or the face with the largest angle, etc. Specifically, if the angle is close to 180 degrees, it means that the incident model has a high probability of hitting the target; if the angle is less than or equal to 90 degrees, the target model is unreachable.

[0070] In an optional embodiment, the specific process of determining the collision position of the incident model on the surface of the target mesh model based on the correspondence between the collision points of the target surface and the surface of the target mesh model may include: determining at least one collision point on the surface of the target mesh model corresponding to the target surface based on the correspondence between the collision points of the target surface and the surface of the target mesh model; obtaining the distance score of each of the at least one collision point relative to the target surface, and determining the target collision point from the at least one collision point based on the distance score; and determining the position corresponding to the target collision point as the collision position of the incident model on the surface of the target mesh model.

[0071] In practical implementation, the collision point with the smallest or largest distance score among the collision points that correspond to the target surface can be determined as the target collision point, and the position of the target collision point can be determined as the collision position of the incident model on the surface of the target mesh model.

[0072] The above method can calculate calculable collision positions based on pre-calculated content, and it has low performance consumption, making it suitable for mobile devices.

[0073] Corresponding to the above method embodiments, this disclosure also provides a collision detection device for a mesh model, such as... Figure 4 As shown, the device includes: The launch information determination module 40 is used to determine the launch position and launch direction corresponding to the launch incident model in response to the launch incident model in the game scene.

[0074] Model determination module 41 is used to determine the target mesh model that the incident model can collide with from the game scene based on the launch position and launch direction.

[0075] The collision surface determination module 42 is used to determine the target surface from the pre-computed volume of the target mesh model based on the launch direction; wherein, the pre-computed volume is a polygonal model that surrounds each vertex of the target mesh model and is determined during the offline stage of the game, and the number of faces of the pre-computed volume is less than the number of faces of the target mesh model.

[0076] The collision location determination module 43 is used to determine the collision location of the incident model on the surface of the target mesh model based on the correspondence between the collision points of the target surface and the surface of the target mesh model; wherein, the correspondence between the collision points of the target surface and the surface of the target mesh model is determined during the offline phase of the game.

[0077] The collision detection device for the aforementioned mesh model can reduce the performance consumption of collision detection during game operation by pre-compiling data of the model during the offline stage of the game, and can also improve collision detection efficiency and quickly locate collision positions.

[0078] Furthermore, the aforementioned device also includes a pre-computation volume determination module, which comprises: a model acquisition unit, used to acquire a target mesh model during the offline phase of the game; wherein the target mesh model consists of multiple model faces, and each model face includes multiple vertices; a face merging unit, used to perform face merging processing on the model faces of the target mesh model based on the vertex positions and vertex normal directions corresponding to the vertices contained in the target mesh model, to obtain multiple merged faces; and a model generation unit, used to perform offset processing on the multiple merged faces to generate a pre-computation volume surrounding each vertex contained in the target mesh model.

[0079] Furthermore, the aforementioned face merging unit is used to: for each vertex in the target mesh model, determine the connecting face containing the current vertex from the target mesh model, and identify whether the connecting face of the current vertex meets the preset conditions. If it does, the current vertex is determined as a degenerate point; determine the first model face from the model faces of the target mesh model, where all vertices are degenerate points; and perform face merging processing on the model faces of the target mesh model based on the vertex positions and vertex normal directions of the degenerate points contained in the first model face, to obtain multiple merged faces.

[0080] Furthermore, the aforementioned preset conditions include: the included angle between the connecting surfaces of the current vertex is less than a preset angle threshold.

[0081] Furthermore, the aforementioned face merging module is also used to: for each first model face, perform the following operations: for each degenerate point contained in the first model face, determine the first vertex in the target mesh model connected to the current degenerate point, and identify the midpoint of the line connecting the current degenerate point and the first vertex; connect the midpoints corresponding to each degenerate point contained in the first model face to obtain the merged face corresponding to the first model face.

[0082] Furthermore, the aforementioned model generation module is used to: for each of the multiple merged surfaces, determine the mass point and the average normal direction of the mass point of the current merged surface, translate each edge of the current merged surface along the average normal direction of the mass point until each edge is tangent to a vertex in the target mesh model, thereby obtaining the translated merged surface corresponding to the current merged surface; integrate the translated merged surfaces corresponding to each of the multiple merged surfaces to obtain a pre-computational volume surrounding each vertex contained in the target mesh model.

[0083] Furthermore, the aforementioned model generation module is used to: translate each edge in the current merged surface along the direction of the average normal of the mass point until the current edge is tangent to a vertex in the target mesh model, thereby obtaining the translated edge corresponding to the current edge; and connect the translated edges corresponding to each edge in the current merged surface to obtain the translated merged surface corresponding to the current merged surface.

[0084] Furthermore, the aforementioned device also includes a relationship determination module, used for: after offsetting multiple merged surfaces to generate a pre-computation volume surrounding each vertex contained in the target mesh model, performing tiling sampling on the outer surface of the target mesh model to obtain multiple collision points located on the surface of the target mesh model; for each collision point on the surface of the target mesh model, determining the positional relationship between the current collision point and each face in the pre-computation volume, and determining the face in the pre-computation volume that has a corresponding relationship with the current collision point based on the positional relationship; and integrating the collision points that have a corresponding relationship with each face in the pre-computation volume to obtain the collision point corresponding to each face in the pre-computation volume.

[0085] Furthermore, the aforementioned relationship determination module is also used to perform the following operations for each face in the pre-calculated volume: determine the angle between the normal direction of the current collision point and the normal direction of the previous face; if the angle is less than a preset angle threshold, determine the distance between the current collision point and the current face, divide the distance by the boundary size parameter to obtain a distance score; determine whether the distance score is the minimum distance score corresponding to the current collision point; if so, perform ray occlusion detection on the current face to obtain a detection result; if the detection result meets the preset occlusion conditions, update the minimum distance score corresponding to the current collision point, and determine the current face as a face that has a corresponding relationship with the current collision point.

[0086] Furthermore, the aforementioned relationship determination module is also used to: offset the current collision point along the normal direction of the current collision point by a first length, and offset it along the current normal direction by a second length to obtain the offset current collision point; using the offset current collision point as the starting point, emit a target ray along the current normal direction, detect whether the target ray is occluded by the target mesh model, and obtain a detection result; wherein, when the detection result indicates that the target ray is not occluded by the target mesh model, it is determined that the detection result meets the preset occlusion condition.

[0087] Furthermore, the aforementioned collision surface determination module 42 is used to: determine the angle between the launch direction and the normal direction of each face in the pre-calculated volume of the target mesh model; and determine the face in the pre-calculated volume whose angle meets the preset angle requirement as the target face.

[0088] Furthermore, the collision location determination module 43 is used to: determine at least one collision point on the target mesh model surface corresponding to the target surface based on the correspondence between the collision points of the target surface and the target mesh model surface; obtain the distance score of each collision point relative to the target surface, and determine the target collision point from the at least one collision point based on the distance score; and determine the position corresponding to the target collision point as the collision position of the incident model on the target mesh model surface.

[0089] The collision detection device for the mesh model provided in this embodiment has the same implementation principle and technical effect as the aforementioned method embodiment. For the sake of brevity, any parts not mentioned in the device embodiment can be referred to the corresponding content in the aforementioned method embodiment.

[0090] This embodiment also provides an electronic device, such as... Figure 5 As shown, the electronic device includes a processor and a memory. The memory stores computer-executable instructions that can be executed by the processor. The processor executes the computer-executable instructions to implement the collision detection method for the aforementioned mesh model. This electronic device can be a server or a terminal device.

[0091] Specifically, the collision detection method for the aforementioned mesh model includes: in response to emitting an incident model in the game scene, determining the emission position and emission direction corresponding to the incident model; based on the emission position and emission direction, determining a target mesh model that the incident model can collide with from the game scene; based on the emission direction, determining a target face from a pre-computed volume of the target mesh model; wherein, the pre-computed volume is a polygonal model that surrounds each vertex of the target mesh model, determined during the offline phase of the game, and the number of faces of the pre-computed volume is less than the number of faces of the target mesh model; and based on the correspondence between the target face and the collision points on the surface of the target mesh model, determining the collision position of the incident model on the surface of the target mesh model; wherein, the correspondence between the target face and the collision points on the surface of the target mesh model is determined during the offline phase of the game.

[0092] The collision detection method for the above-mentioned mesh model can reduce the performance consumption of collision detection during game operation by pre-compiling data of the model during the offline stage of the game, and can also improve the collision detection efficiency and quickly locate the collision position.

[0093] In an optional embodiment, the pre-computed volume of the target mesh model is determined in the following manner: during the offline phase of the game, the target mesh model is obtained; wherein, the target mesh model consists of multiple model faces, and each model face includes multiple vertices; based on the vertex positions and vertex normal directions corresponding to the vertices contained in the target mesh model, the model faces of the target mesh model are merged to obtain multiple merged faces; the multiple merged faces are offset to generate a pre-computed volume surrounding each vertex contained in the target mesh model.

[0094] In an optional embodiment, the step of merging the model faces of the target mesh model based on the vertex positions and vertex normal directions of the vertices contained in the target mesh model to obtain multiple merged faces includes: for each vertex in the target mesh model, determining the connecting face containing the current vertex from the target mesh model, and identifying whether the connecting face of the current vertex meets a preset condition; if it does, determining the current vertex as a degenerate point; determining a first model face from the model faces of the target mesh model where all vertices are degenerate points; and merging the model faces of the target mesh model based on the vertex positions and vertex normal directions of the degenerate points contained in the first model face to obtain multiple merged faces.

[0095] In an optional embodiment, the above-mentioned preset condition includes: the included angle between the connecting surfaces of the current vertex is less than a preset angle threshold.

[0096] In an optional embodiment, the step of merging the model faces of the target mesh model based on the vertex positions and vertex normal directions of the degenerate points contained in the first model face to obtain multiple merged faces includes: for each first model face, performing the following operations: for each degenerate point contained in the first model face, determining the first vertex in the target mesh model connected to the current degenerate point, and identifying the midpoint of the line connecting the current degenerate point and the first vertex; connecting the midpoints corresponding to each degenerate point contained in the first model face to obtain the merged face corresponding to the first model face.

[0097] In an optional embodiment, the step of offsetting multiple merged surfaces to generate a pre-computed volume surrounding each vertex of the target mesh model includes: for each of the multiple merged surfaces, determining the mass point and the mass point average normal direction of the current merged surface, translating each edge of the current merged surface along the mass point average normal direction until each edge is tangent to a vertex in the target mesh model, thereby obtaining the translated merged surface corresponding to the current merged surface; and integrating the translated merged surfaces corresponding to each of the multiple merged surfaces to obtain the pre-computed volume surrounding each vertex of the target mesh model.

[0098] In an optional embodiment, the step of translating each edge in the current merged surface along the average normal direction of the mass point until each edge is tangent to a vertex in the target mesh model to obtain the translated merged surface corresponding to the current merged surface includes: for each edge in the current merged surface, translating the current edge along the average normal direction of the mass point until the current edge is tangent to a vertex in the target mesh model to obtain the translated edge corresponding to the current edge; connecting the translated edges corresponding to each edge in the current merged surface to obtain the translated merged surface corresponding to the current merged surface.

[0099] In an optional embodiment, after offsetting multiple merged faces to generate a pre-computation volume surrounding each vertex of the target mesh model, the method further includes: performing tiling sampling on the outer surface of the target mesh model to obtain multiple collision points located on the surface of the target mesh model; for each collision point on the surface of the target mesh model, determining the positional relationship between the current collision point and each face in the pre-computation volume, and determining the face in the pre-computation volume that corresponds to the current collision point based on the positional relationship; and integrating the collision points that correspond to each face in the pre-computation volume to obtain the collision point corresponding to each face in the pre-computation volume.

[0100] In an optional embodiment, the steps of determining the positional relationship between the current collision point and each face in the pre-computation volume, and determining the face in the pre-computation volume that corresponds to the current collision point based on the positional relationship, include: performing the following operations for each face in the pre-computation volume: determining the angle between the normal direction of the current collision point and the normal direction of the current face; if the angle is less than a preset angle threshold, determining the distance between the current collision point and the current face, dividing the distance by the boundary size parameter to obtain a distance score; determining whether the distance score is the minimum distance score corresponding to the current collision point; if so, performing ray occlusion detection on the current face to obtain a detection result; if the detection result meets the preset occlusion condition, updating the minimum distance score corresponding to the current collision point, and determining the current face as the face that corresponds to the current collision point.

[0101] In an optional embodiment, the step of performing ray occlusion detection on the current face and obtaining the detection result includes: offsetting the current collision point along the normal direction of the current collision point by a first length, and offsetting it along the normal direction of the current face by a second length to obtain the offset current collision point; emitting a target ray along the normal direction of the current face from the offset current collision point, detecting whether the target ray is occluded by the target mesh model, and obtaining the detection result; wherein, when the detection result indicates that the target ray is not occluded by the target mesh model, it is determined that the detection result meets the preset occlusion condition.

[0102] In an optional embodiment, the step of determining the target surface from the pre-calculated volume of the target mesh model based on the launch direction includes: determining the angle between the launch direction and the normal direction of each surface in the pre-calculated volume of the target mesh model; and determining the surface in the pre-calculated volume whose angle meets the preset angle requirement as the target surface.

[0103] In an optional embodiment, the step of determining the collision position of the incident model on the surface of the target mesh model based on the correspondence between the collision points of the target surface and the surface of the target mesh model includes: determining at least one collision point on the surface of the target mesh model corresponding to the target surface based on the correspondence between the collision points of the target surface and the surface of the target mesh model; obtaining the distance score of each of the at least one collision point relative to the target surface, and determining the target collision point from the at least one collision point based on the distance score; and determining the position corresponding to the target collision point as the collision position of the incident model on the surface of the target mesh model.

[0104] Furthermore, Figure 5 The electronic device shown also includes a bus 102 and a communication interface 103, with the processor 101, the communication interface 103 and the memory 100 connected via the bus 102.

[0105] The memory 100 may include high-speed random access memory (RAM) and may also include non-volatile memory, such as at least one disk storage device. Communication between this system network element and at least one other network element is achieved through at least one communication interface 103 (which can be wired or wireless), such as the Internet, wide area network, local area network, metropolitan area network, etc. The bus 102 may be an ISA bus, PCI bus, or EISA bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 5 The symbol is represented by a single double-headed arrow, but this does not mean that there is only one bus or one type of bus.

[0106] Processor 101 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of processor 101 or by instructions in software form. The processor 101 can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this disclosure. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this disclosure can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software module can reside in a readily available storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory 100, and processor 101 reads information from memory 100 and, in conjunction with its hardware, completes the steps of the method described in the foregoing embodiments.

[0107] This disclosure also provides a computer-readable storage medium storing computer-executable instructions. When these computer-executable instructions are called and executed by a processor, they cause the processor to implement the collision detection method for the mesh model described above. For specific implementation details, please refer to the method embodiments, which will not be repeated here.

[0108] Specifically, the collision detection method for the aforementioned mesh model includes: in response to emitting an incident model in the game scene, determining the emission position and emission direction corresponding to the incident model; based on the emission position and emission direction, determining a target mesh model that the incident model can collide with from the game scene; based on the emission direction, determining a target face from a pre-computed volume of the target mesh model; wherein, the pre-computed volume is a polygonal model that surrounds each vertex of the target mesh model, determined during the offline phase of the game, and the number of faces of the pre-computed volume is less than the number of faces of the target mesh model; and based on the correspondence between the target face and the collision points on the surface of the target mesh model, determining the collision position of the incident model on the surface of the target mesh model; wherein, the correspondence between the target face and the collision points on the surface of the target mesh model is determined during the offline phase of the game.

[0109] The collision detection method for the above-mentioned mesh model can reduce the performance consumption of collision detection during game operation by pre-compiling data of the model during the offline stage of the game, and can also improve the collision detection efficiency and quickly locate the collision position.

[0110] In an optional embodiment, the pre-computed volume of the target mesh model is determined in the following manner: during the offline phase of the game, the target mesh model is obtained; wherein, the target mesh model consists of multiple model faces, and each model face includes multiple vertices; based on the vertex positions and vertex normal directions corresponding to the vertices contained in the target mesh model, the model faces of the target mesh model are merged to obtain multiple merged faces; the multiple merged faces are offset to generate a pre-computed volume surrounding each vertex contained in the target mesh model.

[0111] In an optional embodiment, the step of merging the model faces of the target mesh model based on the vertex positions and vertex normal directions of the vertices contained in the target mesh model to obtain multiple merged faces includes: for each vertex in the target mesh model, determining the connecting face containing the current vertex from the target mesh model, and identifying whether the connecting face of the current vertex meets a preset condition; if it does, determining the current vertex as a degenerate point; determining a first model face from the model faces of the target mesh model where all vertices are degenerate points; and merging the model faces of the target mesh model based on the vertex positions and vertex normal directions of the degenerate points contained in the first model face to obtain multiple merged faces.

[0112] In an optional embodiment, the above-mentioned preset condition includes: the included angle between the connecting surfaces of the current vertex is less than a preset angle threshold.

[0113] In an optional embodiment, the step of merging the model faces of the target mesh model based on the vertex positions and vertex normal directions of the degenerate points contained in the first model face to obtain multiple merged faces includes: for each first model face, performing the following operations: for each degenerate point contained in the first model face, determining the first vertex in the target mesh model connected to the current degenerate point, and identifying the midpoint of the line connecting the current degenerate point and the first vertex; connecting the midpoints corresponding to each degenerate point contained in the first model face to obtain the merged face corresponding to the first model face.

[0114] In an optional embodiment, the step of offsetting multiple merged surfaces to generate a pre-computed volume surrounding each vertex of the target mesh model includes: for each of the multiple merged surfaces, determining the mass point and the mass point average normal direction of the current merged surface, translating each edge of the current merged surface along the mass point average normal direction until each edge is tangent to a vertex in the target mesh model, thereby obtaining the translated merged surface corresponding to the current merged surface; and integrating the translated merged surfaces corresponding to each of the multiple merged surfaces to obtain the pre-computed volume surrounding each vertex of the target mesh model.

[0115] In an optional embodiment, the step of translating each edge in the current merged surface along the average normal direction of the mass point until each edge is tangent to a vertex in the target mesh model to obtain the translated merged surface corresponding to the current merged surface includes: for each edge in the current merged surface, translating the current edge along the average normal direction of the mass point until the current edge is tangent to a vertex in the target mesh model to obtain the translated edge corresponding to the current edge; connecting the translated edges corresponding to each edge in the current merged surface to obtain the translated merged surface corresponding to the current merged surface.

[0116] In an optional embodiment, after offsetting multiple merged faces to generate a pre-computation volume surrounding each vertex of the target mesh model, the method further includes: performing tiling sampling on the outer surface of the target mesh model to obtain multiple collision points located on the surface of the target mesh model; for each collision point on the surface of the target mesh model, determining the positional relationship between the current collision point and each face in the pre-computation volume, and determining the face in the pre-computation volume that corresponds to the current collision point based on the positional relationship; and integrating the collision points that correspond to each face in the pre-computation volume to obtain the collision point corresponding to each face in the pre-computation volume.

[0117] In an optional embodiment, the steps of determining the positional relationship between the current collision point and each face in the pre-computation volume, and determining the face in the pre-computation volume that corresponds to the current collision point based on the positional relationship, include: performing the following operations for each face in the pre-computation volume: determining the angle between the normal direction of the current collision point and the normal direction of the current face; if the angle is less than a preset angle threshold, determining the distance between the current collision point and the current face, dividing the distance by the boundary size parameter to obtain a distance score; determining whether the distance score is the minimum distance score corresponding to the current collision point; if so, performing ray occlusion detection on the current face to obtain a detection result; if the detection result meets the preset occlusion condition, updating the minimum distance score corresponding to the current collision point, and determining the current face as the face that corresponds to the current collision point.

[0118] In an optional embodiment, the step of performing ray occlusion detection on the current face and obtaining the detection result includes: offsetting the current collision point along the normal direction of the current collision point by a first length, and offsetting it along the normal direction of the current face by a second length to obtain the offset current collision point; emitting a target ray along the normal direction of the current face from the offset current collision point, detecting whether the target ray is occluded by the target mesh model, and obtaining the detection result; wherein, when the detection result indicates that the target ray is not occluded by the target mesh model, it is determined that the detection result meets the preset occlusion condition.

[0119] In an optional embodiment, the step of determining the target surface from the pre-calculated volume of the target mesh model based on the launch direction includes: determining the angle between the launch direction and the normal direction of each surface in the pre-calculated volume of the target mesh model; and determining the surface in the pre-calculated volume whose angle meets the preset angle requirement as the target surface.

[0120] In an optional embodiment, the step of determining the collision position of the incident model on the surface of the target mesh model based on the correspondence between the collision points of the target surface and the surface of the target mesh model includes: determining at least one collision point on the surface of the target mesh model corresponding to the target surface based on the correspondence between the collision points of the target surface and the surface of the target mesh model; obtaining the distance score of each of the at least one collision point relative to the target surface, and determining the target collision point from the at least one collision point based on the distance score; and determining the position corresponding to the target collision point as the collision position of the incident model on the surface of the target mesh model.

[0121] The aforementioned function, when implemented as a software functional unit and sold or used as an independent product, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this disclosure, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a terminal device, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this disclosure. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0122] In the description of this disclosure, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings, and are only for the convenience of describing this disclosure and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of this disclosure. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.

[0123] Finally, it should be noted that the above-described embodiments are merely specific implementations of this disclosure, used to illustrate the technical solutions of this disclosure, and not to limit it. The protection scope of this disclosure is not limited thereto. Although this disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this disclosure. Such modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this disclosure, and should all be covered within the protection scope of this disclosure. Therefore, the protection scope of this disclosure should be determined by the protection scope of the claims.

Claims

1. A method of collision detection for a mesh model, the method comprising: The method comprises: in response to emitting an incident model in a game scene, determining a launch position and a launch direction corresponding to the incident model; based on the launch position and the launch direction, determining a target mesh model that can be collided with the incident model from the game scene; based on the launch direction, determining a target face from a pre-computed volume of the target mesh model; wherein the pre-computed volume is a polygonal model determined in an offline stage of the game that encloses each vertex contained in the target mesh model, and the number of faces of the pre-computed volume is less than the number of faces of the target mesh model; based on the correspondence between the target face and the collision points of the surface of the target mesh model, determining the collision position of the incident model on the surface of the target mesh model; wherein the correspondence between the target face and the collision points of the surface of the target mesh model is determined in the offline stage of the game.

2. The method of claim 1, wherein, The pre-computed volume of the target mesh model is determined by the following method: in the offline stage of the game, obtaining the target mesh model; wherein the target mesh model is composed of a plurality of model faces, and the model faces include a plurality of vertices; based on the vertex positions and vertex normal directions corresponding to the vertices contained in the target mesh model, performing face merging processing on the model faces of the target mesh model to obtain a plurality of merged faces; performing offset processing on the plurality of merged faces to generate a pre-computed volume enclosing each vertex contained in the target mesh model.

3. The method of claim 2, wherein, The step of performing face merging processing on the model faces of the target mesh model based on the vertex positions and vertex normal directions corresponding to the vertices contained in the target mesh model to obtain a plurality of merged faces comprises: for each vertex in the target mesh model, determining the connection faces containing the current vertex from the target mesh model, and identifying whether the connection faces of the current vertex satisfy a preset condition, if so, determining the current vertex as a degenerate point; determining a first model face in which all vertices are degenerate points from the model faces of the target mesh model; based on the vertex positions and vertex normal directions of the degenerate points contained in the first model face, performing face merging processing on the model faces of the target mesh model to obtain a plurality of merged faces.

4. The method of claim 3, wherein, The preset condition includes that the included angle between the connection faces of the current vertex is less than a preset angle threshold.

5. The method of claim 3, wherein, The step of performing face merging processing on the model faces of the target mesh model based on the vertex positions and vertex normal directions of the degenerate points contained in the first model face to obtain a plurality of merged faces comprises: for each of the first model faces, the following operations are performed: for each degenerate point contained in the first model face, determining a first vertex connected to the current degenerate point in the target mesh model, and identifying the midpoint of the line connecting the current degenerate point and the first vertex; connecting the midpoints corresponding to each degenerate point contained in the first model face to obtain a merged face corresponding to the first model face.

6. The method of claim 2, wherein, The step of performing offset processing on the plurality of merged faces to generate a pre-computed volume enclosing each vertex contained in the target mesh model comprises: For each of the plurality of merged faces, a vertex and a vertex average normal direction of a current merged face are determined, and each edge in the current merged face is translated along the vertex average normal direction until each edge is tangent to a vertex in the target mesh model, to obtain a translated merged face corresponding to the current merged face; The translated merged face corresponding to each of the plurality of merged faces is integrated to obtain a pre-computed volume enclosing each vertex contained in the target mesh model.

7. The method of claim 6, wherein, The step of translating each edge in the current merged face along the vertex average normal direction until each edge is tangent to a vertex in the target mesh model, to obtain a translated merged face corresponding to the current merged face, includes: For each edge in the current merged face, the current edge is translated along the vertex average normal direction until the current edge is tangent to a vertex in the target mesh model, to obtain a translated edge corresponding to the current edge; The translated edges corresponding to each edge in the current merged face are connected to obtain a translated merged face corresponding to the current merged face.

8. The method of claim 2, wherein, After the step of offsetting the plurality of merged faces to generate a pre-computed volume enclosing each vertex contained in the target mesh model, the method further includes: The outer surface of the target mesh model is densely sampled to obtain a plurality of collision points located on the surface of the target mesh model; For each collision point on the surface of the target mesh model, a positional relationship between the current collision point and each face in the pre-computed volume is determined, and a face in the pre-computed volume having a corresponding relationship with the current collision point is determined based on the positional relationship; Collision points having a corresponding relationship with each face in the pre-computed volume are integrated respectively to obtain a collision point corresponding to each face in the pre-computed volume.

9. The method of claim 8, wherein, The step of determining a positional relationship between the current collision point and each face in the pre-computed volume, and determining a face in the pre-computed volume having a corresponding relationship with the current collision point based on the positional relationship, includes: For each face in the pre-computed volume, the following operations are performed: An included angle between a normal direction of the current collision point and a normal direction of the current face is determined, and if the included angle is less than a preset angle threshold, a distance between the current collision point and the current face is determined, the distance is divided by a boundary size parameter to obtain a distance score; It is determined whether the distance score is a minimum distance score corresponding to the current collision point, and if so, a ray occlusion detection is performed on the current face to obtain a detection result; If the detection result satisfies a preset occlusion condition, the minimum distance score corresponding to the current collision point is updated, and the current face is determined as a face having a corresponding relationship with the current collision point.

10. The method of claim 9, wherein, The step of performing a ray occlusion detection on the current face to obtain a detection result includes: The current collision point is offset by a first length along a normal direction of the current collision point and by a second length along a normal direction of the current face to obtain an offset current collision point; The target ray is emitted along the normal direction of the current face with the offset current collision point as a starting point, and whether the target ray is blocked by the target mesh model is detected to obtain a detection result; when the detection result indicates that the target ray is not blocked by the target mesh model, it is determined that the detection result meets the preset blocking condition.

11. The method of claim 1, wherein, The step of determining the target face from the precomputed volume of the target mesh model based on the emission direction comprises: determining the included angle between the emission direction and the normal direction of each face in the precomputed volume of the target mesh model; determining the face in the precomputed volume that meets the preset included angle requirement as the target face.

12. The method of claim 1, wherein, The step of determining the collision position of the incident model on the surface of the target mesh model based on the correspondence between the target face and the collision point of the surface of the target mesh model comprises: determining at least one collision point of the surface of the target mesh model corresponding to the target face based on the correspondence between the target face and the collision point of the surface of the target mesh model; obtaining a distance score of each collision point in the at least one collision point relative to the target face, and determining a target collision point from the at least one collision point based on the distance score; determining the position corresponding to the target collision point as the collision position of the incident model on the surface of the target mesh model.

13. An apparatus for collision detection of a mesh model, the apparatus comprising: The device comprises: a launch information determination module configured to determine a launch position and a launch direction corresponding to an incident model in response to launching the incident model in a game scene; a model determination module configured to determine a target mesh model that can be collided with the incident model from the game scene based on the launch position and the launch direction; a collision face determination module configured to determine a target face from a precomputed volume of the target mesh model based on the launch direction; wherein the precomputed volume is a polygonal model determined in an offline stage of a game and enclosing each vertex contained in the target mesh model, and the number of faces of the precomputed volume is less than the number of faces of the target mesh model; a collision position determination module configured to determine a collision position of the incident model on the surface of the target mesh model based on the correspondence between the target face and the collision point of the surface of the target mesh model; wherein the correspondence between the target face and the collision point of the surface of the target mesh model is determined in the offline stage of the game.

14. An electronic device, comprising: The device comprises a processor and a memory, the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the mesh model collision detection method of any one of claims 1-12.

15. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer executable instructions, and when the computer executable instructions are called and executed by a processor, the computer executable instructions cause the processor to implement the mesh model collision detection method of any one of claims 1-12.