Method and device for detecting collision of characters in flight in network game, electronic equipment and storage medium

CN122912476APending Publication Date: 2026-10-16BEIJING PIXEL SOFTWARE TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610886428.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-18
Publication Date
2026-10-16

AI Technical Summary

Technical Problem

[0004]存在漏检风险:若为提高效率而增大固定步长,则可能直接越过厚度较薄的能量屏障或云层边缘,造成角色“穿越”障碍物的漏检,破坏游戏规则和体验

Benefits of technology

[0016] This invention provides a method, device, electronic device, and storage medium for detecting character flight collisions in online games. It replaces the traditional fixed-step sampling with dynamic step-size ray stepping. The detection step size is adjusted in real time according to the density, gradient, and line-of-sight of the current sampling points. The step size is automatically increased in sparse areas to reduce invalid sampling and improve computational efficiency, while the step size is automatically reduced in density boundaries and high-density areas to accurately approximate the obstacle surface and avoid missing thin-layer obstacles due to excessive step size.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122912476A_ABST
    Figure CN122912476A_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a role flight collision detection method and device in a network game, electronic equipment and storage medium, and relate to the technical field of network games. The current position and flight direction of a target role are obtained, the density value of the current position in a preset three-dimensional density field is calculated, if the density value exceeds a preset density threshold, it is determined that the target role collides with an obstacle in the three-dimensional density field, if the density value does not exceed the density threshold, the next detection step is calculated according to the density value of the current position, the density gradient of the current position and the distance from the current position to a game camera, the current position is updated to a new position after advancing the next detection step along the flight direction, and the step of calculating the density value of the current position is executed. Thus, under the premise of ensuring that thin layer obstacles are not missed, redundant sampling of empty areas can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of online game technology, and more specifically, to a method, device, electronic device, and storage medium for detecting collisions during character flight in online games. Background Technology

[0002] In 3D online game scenes, flying characters often need to traverse volumetric obstacles such as clouds, energy barriers, and storm areas. These obstacles are typically modeled using a 3D density field, and density values ​​are sampled progressively along the character's flight direction using a ray stepping method. A collision is determined when the density at a sampled point exceeds a threshold.

[0003] In related technologies, ray stepping generally adopts a fixed step size strategy, that is, starting from the starting point, it advances a constant distance along the direction each time, samples the density at that point, and compares it with a threshold. However, this method has the following drawbacks: Computationally inefficient: The same small step size is used regardless of whether the scene is sparse or dense. In open, low-density areas, a large number of sampling points are in a vacuum, resulting in invalid computations.

[0004] There is a risk of missed detections: If the fixed step size is increased to improve efficiency, it may directly bypass thinner energy barriers or cloud edges, causing the character to "pass through" obstacles without being detected, thus disrupting the game rules and experience. Summary of the Invention

[0005] In view of this, the purpose of this invention is to provide a method, apparatus, electronic device, and storage medium for detecting character flight collisions in online games to at least partially improve the above-mentioned problems.

[0006] To achieve the above objectives, the technical solutions adopted in the embodiments of the present invention are as follows: In a first aspect, embodiments of the present invention provide a method for detecting collisions during character flight in online games, comprising: Obtain the target character's current location and flight direction; Calculate the density value of the current position in a preset three-dimensional density field; wherein the three-dimensional density field is used to represent the spatial distribution of airborne volumetric obstacles; If the density value exceeds a preset density threshold, it is determined that the target character has collided with an obstacle in the three-dimensional density field. If the density value does not exceed the density threshold, then the next detection step size is calculated based on the density value at the current position, the density gradient at the current position, and the distance from the current position to the game camera. Update the current position to the new position after advancing the next detection step along the flight direction, and return to the step of calculating the density value of the current position.

[0007] Optionally, calculating the next detection step size based on the density value at the current position, the density gradient at the current position, and the distance from the current position to the game camera includes: Obtain the distance from the current location to the game camera, and calculate the distance attenuation factor based on the ratio of the distance to a preset distance threshold; Obtain the density value at the current location, and calculate the density factor based on the density value; Obtain the density gradient value at the current position, and calculate the gradient factor based on the density gradient value and a preset gradient threshold; The adaptive step size is calculated based on the preset baseline step size, the distance decay factor, the density factor, and the gradient factor. The adaptive step size is compared with the preset minimum step size, and the larger of the two values ​​is taken as the next detection step size.

[0008] Optionally, calculating the adaptive step size based on the preset reference step size, the distance decay factor, the density factor, and the gradient factor includes: Based on the distance attenuation factor, the preset minimum step size scaling factor, and the preset maximum step size scaling factor, linear interpolation is performed to calculate the distance scaling factor; The adaptive step size is obtained by multiplying the preset baseline step size by the distance scaling factor, the density factor, and the gradient factor.

[0009] Optionally, the method further includes: Obtain the dynamic axis alignment bounding box of the target character and at least one other flying character; wherein each dynamic axis alignment bounding box is calculated and generated based on the current action posture and movement direction of the corresponding character; Intersection tests are performed between the dynamic axis alignment bounding box of the target character and the dynamic axis alignment bounding boxes of the other flight characters; If the intersection test result is an intersection, it is determined that the target character has collided with the other flying characters.

[0010] Optionally, the generation of the dynamic axis-aligned bounding box includes: Obtain the character's original dimensions, current action state, and current velocity vector; Normalize the velocity vector to obtain the unit vector of the motion direction; Based on the current action state, the original size is scaled to obtain the scaled size; The offset vector is obtained by multiplying the product of the length of the scaled size in the direction of motion and the preset offset coefficient by the unit vector in the direction of motion. Add the offset vector to the character's current position to obtain the center point of the dynamic axis-aligned bounding box; Subtracting and adding half of the scaled size from the center point respectively yields the minimum and maximum point coordinates of the dynamic axis-aligned bounding box.

[0011] Optionally, the intersection test is to determine whether the projection intervals of the two dynamically aligned bounding boxes on the three coordinate axes overlap.

[0012] Optionally, before the step of performing an intersection test between the dynamic axis alignment bounding box of the target character and the dynamic axis alignment bounding boxes of the other flight characters, the method further includes: The game space is divided into a three-dimensional grid with preset side lengths, and the grid cell to which each character belongs is determined based on the current position of each character. Select other roles that are in the same or adjacent grid cells as the target role as candidate roles; The intersection test between the dynamic axis alignment bounding box of the target character and the dynamic axis alignment bounding boxes of the other flight characters includes: An intersection test is performed between the dynamic axis-aligned bounding box of the target character and the dynamic axis-aligned bounding box of the candidate character.

[0013] Secondly, embodiments of the present invention provide a collision detection device for character flight in online games, comprising: The character status acquisition unit is used to obtain the target character's current position and flight direction; A density calculation unit is used to calculate the density value of the current position in a preset three-dimensional density field; wherein the three-dimensional density field is used to represent the spatial distribution of airborne volumetric obstacles; The collision detection unit is used to determine that the target character has collided with an obstacle in the three-dimensional density field if the density value exceeds a preset density threshold; if the density value does not exceed the density threshold, it calculates the next detection step size based on the density value at the current position, the density gradient at the current position, and the distance from the current position to the game camera. The character state update unit is used to update the current position to the new position after moving forward the next detection step along the flight direction, and return to the step of calculating the density value of the current position.

[0014] Thirdly, embodiments of the present invention provide an electronic device, including a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor executes the computer program to implement the method described in any of the above-mentioned embodiments.

[0015] Fourthly, embodiments of the present invention provide a storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the method described in any of the preceding claims.

[0016] This invention provides a method, device, electronic device, and storage medium for detecting character flight collisions in online games. It replaces the traditional fixed-step sampling with dynamic step-size ray stepping. The detection step size is adjusted in real time according to the density, gradient, and line-of-sight of the current sampling points. The step size is automatically increased in sparse areas to reduce invalid sampling and improve computational efficiency, while the step size is automatically reduced in density boundaries and high-density areas to accurately approximate the obstacle surface and avoid missing thin-layer obstacles due to excessive step size.

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

[0018] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1 A schematic structural block diagram of an electronic device provided in an embodiment of the present invention; Figure 2 A flowchart illustrating a collision detection method for character flight in an online game, provided by an embodiment of the present invention; Figure 3 A flowchart illustrating step S24 provided in an embodiment of the present invention; Figure 4 This is another flowchart illustrating a collision detection method for character flight in an online game, provided by an embodiment of the present invention. Figure 5 This is a schematic structural block diagram of a collision detection device for character flight in an online game, provided as an embodiment of the present invention.

[0020] Icons: 100 - Electronic device; 101 - Memory; 102 - Communication interface; 103 - Processor; 104 - Communication bus; 40 - Character flight collision detection device in online games; 41 - Character status acquisition unit; 42 - Density calculation unit; 43 - Collision detection unit; 44 - Character status update unit. Detailed Implementation

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

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

[0023] It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, in the description of this invention, terms such as "first," "second," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0024] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0025] As described in the background section, in related technologies, ray stepping generally adopts a fixed step size strategy, that is, starting from the starting point, it moves forward a constant distance along the direction each time, samples the density of the point and compares it with a threshold. A code implementation example of this method is shown in Table 1.

[0026] Table 1

[0027] This approach still advances with small step sizes (such as 2.0) in sparse regions, resulting in wasted computing resources; if the step size is too large (such as 5.0), it may skip the energy barrier that is only 5 units thick, causing missed detections.

[0028] Based on the above, embodiments of the present invention provide a method, device, electronic device, and storage medium for detecting collisions during character flight in online games. By using light stepping that automatically adjusts the stepping distance based on local density characteristics, invalid sampling can be significantly reduced while ensuring that thin-layer obstacles are not missed.

[0029] To implement the process steps and functions of this invention, please refer to [link / reference]. Figure 1 , Figure 1 This is a schematic structural block diagram of an electronic device 100 provided in an embodiment of the present invention. The electronic device 100 includes a memory 101 and a processor 103, which are electrically connected directly or indirectly to each other to realize data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses 104 or signal lines. The memory 101 can be used to store software programs and modules, and the processor 103 executes the software programs and modules stored in the memory 101, thereby performing various functional applications and data processing.

[0030] Electronic device 100 can be, but is not limited to, a personal computer (PC), a server, a distributed computer, etc. It is understood that electronic device 100 is not limited to a physical server, but can also be a virtual machine on a physical server, a virtual machine built on a cloud platform, or any other computer that can provide the same functionality as the server or virtual machine. The operating system of electronic device 100 can be, but is not limited to, Windows, Linux, etc.

[0031] The memory 101 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.

[0032] The communication connection between the electronic device 100 and external devices is achieved through at least one communication interface 102 (which can be wired or wireless).

[0033] Processor 103 may be an integrated circuit chip with signal processing capabilities. In implementation, the steps of this embodiment can be completed by integrated logic circuits in the hardware of processor 103 or by instructions in software form. Processor 103 may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may 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.

[0034] Understandable. Figure 1 The structure shown is for illustrative purposes only; the electronic device 100 may also include components that are more advanced than those shown. Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown. Figure 1 The components shown can be implemented using hardware, software, or a combination thereof.

[0035] The following is an exemplary description of the collision detection method for character flight in online games provided by an embodiment of the present invention. See also... Figure 2 The subject executing this method can be one of the above. Figure 1 The electronic device 100 shown, the method includes as follows Figure 2 The following steps are described: S21: Obtain the target character's current position and flight direction.

[0036] The target character is the game entity that needs to perform collision detection. Its state is updated by the game engine every frame: the current position is the three-dimensional coordinates in the world coordinate system; the flight direction is the unit vector normalized to the character's current velocity vector.

[0037] S22: Calculate the density value of the current position in the preset three-dimensional density field.

[0038] The three-dimensional density field represents the spatial distribution of aerial volumetric obstacles. It is a pre-baked or real-time generated three-dimensional texture, where each voxel stores a scalar density value ρ ∈ [0.0, 1.0], representing the physical concentration of clouds, energy barriers, or storm regions at the corresponding spatial location. The density value for the current position can be obtained from the three-dimensional density field based on the character's current location.

[0039] S23: If the density value exceeds the preset density threshold, it is determined that the target character has collided with an obstacle in the three-dimensional density field.

[0040] S24: If the density value does not exceed the density threshold, calculate the next detection step size based on the density value at the current position, the density gradient at the current position, and the distance from the current position to the game camera.

[0041] S25: Update the current position to the new position after moving forward one more detection step along the flight direction, and return to execute step S22.

[0042] First, obtain the target character's current position in the world coordinate system and the normalized direction vector representing its flight direction. Then, based on the current position, sample the corresponding density value in the preset three-dimensional density field.

[0043] The density value is compared with a preset density threshold; if the density value is greater than the density threshold, it is determined that the target character has entered the obstacle's influence range, a collision occurs, and the current position is output as the collision point.

[0044] If the density value is less than or equal to the density threshold, the step size for the next detection step is calculated based on the density value at the current location, the spatial rate of change of the density field at that location (i.e., the density gradient), and the distance from that location to the game camera.

[0045] The new sampling position is obtained by moving forward the calculated step length from the current position along the flight direction; then return to execute S22 to continue sampling density values ​​and performing collision determination at the new position.

[0046] The process is repeated until any of the following termination conditions are met: (1) a collision occurs; (2) the cumulative number of samples reaches the preset upper limit; (3) the cumulative travel distance along the flight direction exceeds the preset maximum detection distance.

[0047] This method constructs an adaptive scale space by coupling distance perception, density perception, and gradient perception to adjust the step size. This space enables the algorithm to automatically increase the sampling interval in open areas and automatically decrease the sampling interval inside obstacles and at the edges. This reduces redundant sampling in open areas while ensuring that thin-layer obstacles are not missed.

[0048] In one alternative implementation, see [link to implementation details]. Figure 3 Step S24 may include the following sub-steps: S241: Obtain the distance from the current location to the game camera, and calculate the distance attenuation factor based on the ratio of the distance to a preset distance threshold.

[0049] Obtain the Euclidean distance from the current position to the game camera position. Based on the ratio of this distance to a preset distance threshold, calculate the distance attenuation factor. The calculation can be as follows: viewDistance = distance(worldPos, WorldSpaceCameraPos) distanceFactor = saturate(viewDistance / distanceThreshold) Where `worldPos` represents the current position, `WorldSpaceCameraPos` represents the position of the game camera, `distance()` retrieves the Euclidean distance between the two points, `saturate(x)` truncates `x` to the interval [0.0, 1.0], and `distanceThreshold` represents the preset distance threshold, which can be 300. This distance decay factor is used to characterize the perceived distance of the sampling points in the rendering pipeline: when `viewDistance`... When distanceThreshold is constant, distanceFactor ≈ 0, indicating that the view is in the foreground and requires fine sampling. When viewDistance ≥ distanceThreshold, distanceFactor = 1.0, indicating that the view is in the background and allows for a larger step size to improve efficiency. The technical purpose is to alleviate the oversampling waste caused by a fixed step size in the background.

[0050] S242: Obtain the density value at the current location and calculate the density factor based on the density value.

[0051] Obtain the density value of the current location sampled in S22, and calculate the density factor based on this density value: densityFactor = saturate(1.0 - density) The density factor monotonically decreases as local density increases: when density = 0.0, densityFactor = 1.0, allowing for a larger step size; when density = 1.0 (dense barrier core), densityFactor = 0.0, forcing a smaller step size. The technical purpose is to prevent skipping high-density areas due to excessively large step sizes, ensuring reliable coverage of thick clouds or energy sources.

[0052] S243: Obtain the density gradient value at the current location, and calculate the gradient factor based on the density gradient value and the preset gradient threshold.

[0053] Obtain the spatial density gradient value gradient of the three-dimensional density field at the current location. This value characterizes the degree of drastic local change in density in space. The gradient factor is calculated by comparing the gradient with a preset gradient threshold, gradientThreshold. gradientFactor = gradient>gradientThreshold ? 0.3 : 1.0 Here, `gradient = fwidth(density)`, where `fwidth` is a built-in function in the GPU shader, and `gradientThreshold` can be set to 0.1, corresponding to the typical gradient magnitude in spatially discontinuous regions such as cloud edges and energy field boundaries. This gradient factor is used to identify regions of abrupt density changes: when the gradient exceeds the threshold, it is determined that the current location is in an obstacle transition zone, and a fine step size needs to be enabled to avoid missing thin-layer structures; otherwise, it is processed with normal accuracy. Its technical purpose is specifically to address the geometric uncertainty of volumetric obstacles and solve the crossing problem that traditional methods are prone to encounter in edge regions.

[0054] S244: Calculate the adaptive step size based on the preset baseline step size, distance decay factor, density factor, and gradient factor.

[0055] Optionally, step S244 may include: S2441: Calculate the distance scaling factor by performing linear interpolation based on the distance attenuation factor, the preset minimum step size scaling factor, and the preset maximum step size scaling factor.

[0056] You can set the minimum step size scaling factor minScale = 0.5 and the preset maximum step size scaling factor maxScale = 2.0. Using the linear interpolation function lerp(), the distance scaling factor distScale is calculated using the distance decay factor distanceFactor as the interpolation weight. distScale = lerp(minScale, maxScale, distanceFactor) This design allows the distance scaling factor to continuously vary with distanceFactor within the range of [0.5, 2.0]: when distanceFactor ≈ 0 (near view), distScale ≈ 0.5, the step size is forced to shrink, ensuring high accuracy at close range; when distanceFactor = 1.0 (far view), distScale = 2.0, the step size is allowed to increase, significantly reducing redundant sampling in the far view.

[0057] S2442: Multiply the preset baseline step size by the distance scaling factor, density factor, and gradient factor to obtain the adaptive step size.

[0058] The preset baseline step size (e.g., 2.0 units) is multiplied and coupled with the distance scaling factor (distScale), density factor (densityFactor), and gradient factor (gradientFactor) to obtain the initial adaptive step size `adaptiveStep_temp`: adaptiveStep_temp = baseStep × distScale × densityFactor × gradientFactor This multiplicative structure embodies the orthogonal superposition of three physical constraints: distScale dominates macro-scale regulation (i.e., near-fit); densityFactor implements concentration-sensitive regulation (i.e., finer and coarser); gradientFactor performs edge-specific reinforcement.

[0059] Multiplying these three factors ensures that when any dimension requests "refinement," the step size can be effectively compressed, and there is no risk of offsetting between dimensions. This approach is more effective than linear combination methods such as weighted summation in ensuring stable detection of thin-layer obstacles at any spatial location.

[0060] S245: Compare the adaptive step size with the preset minimum step size, and take the larger of the two as the next detection step size.

[0061] The larger of the adaptive step size and the preset minimum step size is taken as the next detection step size. max(adaptiveStep, 0.5) The minStep parameter can be set to 0.5 to ensure the lower limit accuracy of the algorithm and avoid step size collapse failure due to extreme parameter combinations.

[0062] Meanwhile, in the game, characters also collide with other characters. For collision detection between dynamic characters, the traditional approach uses static axis-aligned bounding boxes (AABBs), binding a bounding box of a fixed size to each character and detecting collisions by judging whether the projections of each axis overlap. However, this approach does not consider that the character's flight posture (such as diving or gliding) will change the actual outline, and static AABBs cannot adapt to this, resulting in a large deviation between the bounding box and the actual shape, generating a large number of false alarms and triggering unnecessary avoidance or deceleration logic.

[0063] To address this, embodiments of the present invention provide a dynamic axis alignment bounding box detection mechanism for interactions between entity roles, see [link to relevant documentation]. Figure 4 The method may also include: S31: Obtain the dynamic axis alignment bounding box of the target character and at least one other flying character; wherein each dynamic axis alignment bounding box is calculated and generated based on the current action posture and motion direction of the corresponding character.

[0064] For any flight character to be detected (including the target character itself and other nearby flight characters), a dynamic axis-aligned bounding box is calculated and generated based on the current action posture and direction of motion of the corresponding character.

[0065] Optionally, the step of generating the dynamic axis-aligned bounding box may include: S311: Get the character's original dimensions, current action state, and current velocity vector.

[0066] Read the following three inputs from the game runtime data bus: The original size of the character model is base_size = (base_x, base_y, base_z). This triple is a static preset value in world coordinate system units. It is defined during the character modeling stage and represents the minimum circumscribed cuboid size in the standard pose.

[0067] The character's current action state, which can take values ​​such as dive and glide, and is used to drive the posture deformation strategy; where dive means diving and glide means gliding.

[0068] The character's current velocity vector, velocity = (v_x, v_y, v_z), reflects the character's instantaneous movement trend.

[0069] S312: Normalize the velocity vector to obtain the unit vector of the motion direction.

[0070] Normalize velocity to obtain a dimensionless unit vector of motion direction, which can be directly processed using the normalize function.

[0071] S313: Based on the current action state, scale the original size to obtain the scaled size.

[0072] The base_size is scaled axis-by-axis based on the preset scaling factor matrix by looking up the action table to obtain the pose adaptation size.

[0073] For example, during a dive, the length increases (stretches along the velocity direction), while the width and height decrease. The scaled size is: size = (base_size.x × 1.3, base_size.y × 0.7, base_size.z × 0.6).

[0074] When gliding, the width increases (wings spread), and the scaled size is size = (base_size.x × 1.1, base_size.y × 1.4, base_size.z × 1.0).

[0075] In other cases, size remains unchanged as base_size.

[0076] S314: The offset vector is obtained by multiplying the product of the length of the scaled size in the direction of motion and the preset offset coefficient by the unit vector in the direction of motion.

[0077] Based on the projected length size_x of the scaled size in the direction of motion, and combined with the preset offset coefficient k_offset, the offset vector is calculated: offset = direction × (size.x × k_offset) Where k_offset can be 0.3.

[0078] The offset is proportional to the actual length occupied by the character in the direction of movement, rather than a fixed distance, thus adapting the collision warning scale to different character sizes (such as dragon vs. hummingbird).

[0079] S315: Add the offset vector to the character's current position to obtain the center point of the dynamically aligned bounding box.

[0080] Add the character's current position worldPos to offset to get the center coordinates of the dynamic AABB: center = position + offset.

[0081] S316: Subtract and add half of the scaled size to the center point to obtain the minimum and maximum coordinates of the dynamically aligned bounding box.

[0082] Construct an axis-aligned cuboid with center as the origin and size as the side length along the XYZ axes of the world coordinate system: Minimum point coordinates (bottom left corner of AABB): aabb_min = center - size / 2.

[0083] The coordinates of the maximum point (top right front corner of AABB): aabb_max = center + size / 2.

[0084] At this point, a complete, parameter-controllable, physically interpretable, and engine-integrable dynamic AABB structure has been constructed.

[0085] S32: Perform an intersection test on the dynamic axis alignment bounding box of the target character and the dynamic axis alignment bounding box of other flight characters.

[0086] After calculating each dynamic AABB, an intersection test can be performed. Optionally, the intersection test can be used to determine whether the projection intervals of the two dynamic axis-aligned bounding boxes on the three coordinate axes overlap.

[0087] For the target character's dynamic AABB (denoted as aabb1) and the dynamic AABBs of all other candidate flight characters (denoted as aabb2), a standard AABB intersection determination is performed. Based on the simplified form of the separation axis theorem in the axis-aligned coordinate system, two AABBs intersect if and only if their projection intervals on the X, Y, and Z coordinate axes all overlap. The specific determination logic is as follows: (aabb1.min.x<= aabb2.max.x and aabb1.max.x>= aabb2.min.x) and (aabb1.min.y<= aabb2.max.y and aabb1.max.y>= aabb2.min.y) and (aabb1.min.z<= aabb2.max.z and aabb1.max.z>= aabb2.min.z) The decision-making process consists of only 6 floating-point comparisons and 3 logical AND operations, with no multiplication, division, or branch jumps, and can be executed quickly on both CPU and GPU.

[0088] S33: If the intersection test result is an intersection, it is determined that the target character has collided with other flying characters.

[0089] If the above judgment logic returns True, it is determined that the target character has collided with the other flying character in space, and the upper-level game logic is triggered, such as playing collision sound effects and particle effects, activating physical bounce or forced separation algorithms, etc.

[0090] Conversely, if the intersection test results for all candidate characters are False, then it is determined that there is no collision between actual characters in the current frame.

[0091] Performing full pairwise intersection detection on all nearby flying units would be computationally expensive and difficult to support large-scale, multi-user online scenarios.

[0092] Therefore, prior to step S32, the method may further include: S321: Divide the game space into a three-dimensional grid with preset side lengths, and determine the grid cell to which each character belongs based on its current position.

[0093] The entire game world space (or the currently active loading area) is divided into cubic grid cells with a side length of grid_cell_size along the X, Y, and Z axes. This size is a preset constant, and grid_cell_size must be larger than the maximum outer sphere diameter of a single character's dynamic AABB (ensuring that each character falls within a unique grid).

[0094] For each flight character, its grid cell index is quickly located using integer truncation operations based on its current position.

[0095] S322: Filter other roles that are in the same grid cell or adjacent grid cells as the target role as candidate roles.

[0096] Define the grid containing the target character as the central grid C, and define the set of 26 neighboring grids N(C) of C, that is, all neighboring grids satisfying `|Δx| ≤ 1, |Δy| ≤ 1, |Δz| ≤ 1`, including itself, for a total of 3. 3 =27 grids, 26 after removing itself.

[0097] Include all other flight roles located within C ∪ N(C) into the candidate role set Candidates.

[0098] S32': Perform an intersection test between the dynamic axis-aligned bounding box of the target character and the dynamic axis-aligned bounding box of the candidate character.

[0099] Then, perform a three-axis projection overlap determination only on the dynamic AABB of the target character and the dynamic AABB of each character in Candidates.

[0100] Furthermore, embodiments of the present invention also provide a collision detection device for character flight in online games, see [link to related document]. Figure 5 The collision detection device 40 for character flight in the online game includes: The character status acquisition unit 41 is used to acquire the target character's current position and flight direction.

[0101] The density calculation unit 42 is used to calculate the density value of the current position in the preset three-dimensional density field; wherein, the three-dimensional density field is used to represent the spatial distribution of airborne volumetric obstacles.

[0102] The collision detection unit 43 is used to determine that the target character has collided with an obstacle in the three-dimensional density field if the density value exceeds a preset density threshold; if the density value does not exceed the density threshold, it calculates the next detection step size based on the density value at the current position, the density gradient at the current position, and the distance from the current position to the game camera.

[0103] The character state update unit 44 is used to update the current position to the new position after moving forward one more detection step along the flight direction, and return to the step of calculating the density value of the current position.

[0104] In summary, the collision detection method, apparatus, electronic device, and storage medium for character flight in online games provided by this invention combine adaptive step size ray stepping with dynamic axis-aligned bounding boxes, significantly reducing computational overhead while maintaining high detection accuracy. The adaptive step size mechanism dynamically adjusts the sampling interval based on local density, edge gradient, and line-of-sight distance, moving forward in large steps in open areas to improve efficiency, and automatically sampling finely at density edges and in high-density areas to avoid missing thin-layer obstacles; the dynamic bounding box adjusts its size and center offset in real time according to the character's flight posture, accurately conforming to the actual contour and greatly reducing false positives.

[0105] In the embodiments provided by this invention, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative; for example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code, which contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

[0106] In addition, the functional modules in the various embodiments of the present invention can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.

[0107] If the functionality is implemented as a software module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a computer-readable storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this invention. 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.

[0108] The above are merely preferred embodiments of the present invention and are not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

[0109] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the invention can be implemented in other specific forms without departing from its spirit or essential characteristics. Therefore, the embodiments should be considered in all respects as exemplary and non-limiting, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be included within the present invention. No reference numerals in the claims should be construed as limiting the scope of the claims.

Claims

1. A collision detection method for characters flying in an online game, characterized in that, include: Obtain the target character's current location and flight direction; Calculate the density value of the current position in a preset three-dimensional density field; wherein the three-dimensional density field is used to represent the spatial distribution of airborne volumetric obstacles; If the density value exceeds a preset density threshold, it is determined that the target character has collided with an obstacle in the three-dimensional density field. If the density value does not exceed the density threshold, then the next detection step size is calculated based on the density value at the current position, the density gradient at the current position, and the distance from the current position to the game camera. Update the current position to the new position after advancing the next detection step along the flight direction, and return to the step of calculating the density value of the current position.

2. The method according to claim 1, characterized in that, The step of calculating the next detection step size based on the density value at the current position, the density gradient at the current position, and the distance from the current position to the game camera includes: Obtain the distance from the current location to the game camera, and calculate the distance attenuation factor based on the ratio of the distance to a preset distance threshold; Obtain the density value at the current location, and calculate the density factor based on the density value; Obtain the density gradient value at the current location, and calculate the gradient factor based on the density gradient value and a preset gradient threshold; The adaptive step size is calculated based on the preset baseline step size, the distance decay factor, the density factor, and the gradient factor. The adaptive step size is compared with the preset minimum step size, and the larger of the two values ​​is taken as the next detection step size.

3. The method according to claim 2, characterized in that, The step of calculating the adaptive step size based on the preset baseline step size, the distance decay factor, the density factor, and the gradient factor includes: Based on the distance attenuation factor, the preset minimum step size scaling factor, and the preset maximum step size scaling factor, linear interpolation is performed to calculate the distance scaling factor; The adaptive step size is obtained by multiplying the preset baseline step size by the distance scaling factor, the density factor, and the gradient factor.

4. The method according to claim 1, characterized in that, The method further includes: Obtain the dynamic axis alignment bounding box of the target character and at least one other flying character; wherein each dynamic axis alignment bounding box is calculated and generated based on the current action posture and movement direction of the corresponding character; Intersection tests are performed between the dynamic axis alignment bounding box of the target character and the dynamic axis alignment bounding boxes of the other flight characters; If the intersection test result is an intersection, it is determined that the target character has collided with the other flying characters.

5. The method according to claim 4, characterized in that, The generation of the dynamic axis-aligned bounding box includes: Obtain the character's original dimensions, current action state, and current velocity vector; Normalize the velocity vector to obtain the unit vector of the motion direction; Based on the current action state, the original size is scaled to obtain the scaled size; The offset vector is obtained by multiplying the product of the length of the scaled size in the direction of motion and the preset offset coefficient by the unit vector in the direction of motion. Add the offset vector to the character's current position to obtain the center point of the dynamic axis-aligned bounding box; Subtracting and adding half of the scaled size from the center point respectively yields the minimum and maximum coordinates of the dynamically aligned bounding box.

6. The method according to claim 4, characterized in that, The intersection test is used to determine whether the projection intervals of the two dynamically aligned bounding boxes on the three coordinate axes overlap.

7. The method according to claim 4, characterized in that, Prior to the step of performing an intersection test between the dynamic axis alignment bounding box of the target character and the dynamic axis alignment bounding boxes of the other flight characters, the method further includes: The game space is divided into a three-dimensional grid with preset side lengths, and the grid cell to which each character belongs is determined based on the current position of each character. Select other roles that are in the same or adjacent grid cells as the target role as candidate roles; The intersection test between the dynamic axis alignment bounding box of the target character and the dynamic axis alignment bounding boxes of the other flight characters includes: An intersection test is performed between the dynamic axis-aligned bounding box of the target character and the dynamic axis-aligned bounding box of the candidate character.

8. A collision detection device for character flight in an online game, characterized in that, include: The character status acquisition unit is used to obtain the target character's current position and flight direction; A density calculation unit is used to calculate the density value of the current position in a preset three-dimensional density field; wherein the three-dimensional density field is used to represent the spatial distribution of airborne volumetric obstacles; The collision detection unit is used to determine that the target character has collided with an obstacle in the three-dimensional density field if the density value exceeds a preset density threshold; if the density value does not exceed the density threshold, it calculates the next detection step size based on the density value at the current position, the density gradient at the current position, and the distance from the current position to the game camera. The character state update unit is used to update the current position to the new position after moving forward the next detection step along the flight direction, and return to the step of calculating the density value of the current position.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the method according to any one of claims 1 to 7.

10. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method described in any one of claims 1 to 7.