Method and apparatus for determining collision event, and storage medium, electronic device and program product
By estimating the trajectory and judging the candidate collision space, the problem of inaccurate collision detection in the existing technology is solved, higher accuracy and efficiency are achieved, and the real simulation of collision events in the virtual scene is ensured.
Patent Information
- Application Number
- PCT/CN2024/083691
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-03-30
- Filing Date
- 2024-03-26
- Publication Date
- 2024-10-03
AI Technical Summary
Existing collision detection methods lead to inaccurate collision detection and penetration phenomena when virtual objects move quickly or the frame update time in a virtual scene is long, making it impossible to realistically simulate collision events.
By obtaining the estimated trajectories of the target object and the collision object, judging their spatial position relationship in the next movement cycle, determining the candidate collision space, and determining whether a collision event occurs with the target object within this space, avoiding the need for accurate detection every time , reducing the complexity.
It improves the recognition accuracy of collision events, avoids penetration phenomena, and enhances the authenticity of collision detection in virtual scenes.
Smart Images

Figure CN2024083691_03102024_PF_FP_ABST
Abstract
Description
Method, device, storage medium, electronic device and program product for determining collision event
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on March 30, 2023, with application number 202310377758.6 and application name “Method and device for determining collision events, storage medium and electronic device”. Technical Field
[0002] The present application relates to the field of computers, and in particular to a method, device, storage medium, electronic device, and program product for determining a collision event.
[0003] Background of the Invention
[0004] In the process of real-time rendering of game animations, to enhance the realism of the images, animation effects similar to those in the real world are often configured for relevant events in the virtual scene. For example, when a virtual game object collides with an object in the virtual game scene, a corresponding collision image or collision effect is rendered.
[0005] Existing technologies usually use the DCD (Discrete Collision Detection) detection method to implement collision detection during the rendering process. This method usually selects the object positions at different times for collision detection, and has high performance. However, precisely because of the "discrete" nature of the discrete detection method, when the virtual objects in the virtual scene move too fast, or the current frame update time is too long, the collision detection object will penetrate the collision object, resulting in an unrealistic simulation phenomenon. In other words, the existing collision determination method has the technical problem of inaccurate detection results of collision events.
[0006] To address the above-mentioned problems, no effective solutions have been proposed so far.
[0007] Summary of the Invention
[0008] The embodiments of the present application provide a method, apparatus, storage medium, electronic device, and program product for determining a collision event, so as to at least solve the technical problem of inaccurate detection of collision events by collision detection methods.
[0009] According to one aspect of an embodiment of the present application, a method for determining a collision event is provided, comprising:
[0010] Obtaining a first estimated trajectory associated with the target object and a second estimated trajectory associated with the collision object, wherein the first estimated trajectory is a movement trajectory that the target object will pass through in a next movement cycle, and the second estimated trajectory is a movement trajectory that the collision object will pass through in the next movement cycle;
[0011] When the spatial position relationship between the first estimated trajectory and the second estimated trajectory satisfies a reference collision condition, determining a candidate collision space associated with the collision object, wherein the candidate collision space is used to indicate a space through which the target object is not allowed to move; and
[0012] When the plurality of candidate object positions on the first estimated trajectory include a target object position located in the candidate collision space, it is determined that a collision event occurs between the target object and the collision object.
[0013] According to another aspect of an embodiment of the present application, a device for determining a collision event is provided, including:
[0014] an acquisition unit, configured to acquire a first estimated trajectory associated with the target object and a second estimated trajectory associated with the collision object, wherein the first estimated trajectory is a movement trajectory that the target object will pass through in a next movement cycle, and the second estimated trajectory is a movement trajectory that the collision object will pass through in the next movement cycle;
[0015] a first determining unit configured to determine, when a spatial positional relationship between the first estimated trajectory and the second estimated trajectory satisfies a reference collision condition, a candidate collision space associated with the collision object, wherein the candidate collision space indicates a space through which the target object is not allowed to move; and
[0016] The second determining unit is configured to determine that a collision event occurs between the target object and the collision object when the plurality of candidate object positions on the first estimated trajectory include a target object position located in the candidate collision space.
[0017] According to another aspect of the embodiments of the present application, a computer-readable storage medium is provided, in which a computer program is stored. The computer program is configured to execute the above-mentioned method for determining a collision event when running.
[0018] According to another aspect of an embodiment of the present application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the above-described method for determining a collision event.
[0019] According to another aspect of an embodiment of the present application, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the method for determining a collision event through the computer program.
[0020] BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0022] FIG1 is a schematic diagram of a hardware environment of an optional method for determining a collision event according to an embodiment of the present application;
[0023] FIG2 is a flow chart of an optional method for determining a collision event according to an embodiment of the present application;
[0024] FIG3 is a schematic diagram of an optional method for determining a collision event according to an embodiment of the present application;
[0025] FIG4 is a schematic diagram of another optional method for determining a collision event according to an embodiment of the present application;
[0026] FIG5 is a schematic diagram of another optional method for determining a collision event according to an embodiment of the present application;
[0027] FIG6 is a schematic diagram of another optional method for determining a collision event according to an embodiment of the present application;
[0028] FIG7 is a schematic diagram of another optional method for determining a collision event according to an embodiment of the present application;
[0029] FIG8 is a schematic diagram of another optional method for determining a collision event according to an embodiment of the present application;
[0030] FIG9 is a schematic diagram of another optional method for determining a collision event according to an embodiment of the present application;
[0031] FIG10 is a schematic diagram of another optional method for determining a collision event according to an embodiment of the present application;
[0032] FIG11 is a schematic diagram of an optional device for determining a collision event according to an embodiment of the present application;
[0033] FIG12 is a schematic structural diagram of another optional electronic device according to an embodiment of the present application.
[0034] Implementation Method
[0035] In order to enable those skilled in the art to better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.
[0036] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in a sequence other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0037] According to one aspect of an embodiment of the present application, a method for determining a collision event is provided. As an optional implementation, the above-mentioned method for determining a collision event can be, but is not limited to, applied to a collision event determination system composed of a terminal device 102, a server 104, and a network 110 as shown in FIG1 . As shown in FIG1 , the terminal device 102 is connected to and communicates with the server 104 via the network 110. The above-mentioned network can include, but is not limited to: a wired network, a wireless network, wherein the wired network includes: a local area network, a metropolitan area network, and a wide area network, and the wireless network includes: Bluetooth, WIFI, and other networks that implement wireless communication. The above-mentioned terminal device can include, but is not limited to, at least one of the following: a mobile phone (such as an Android phone, an iOS phone, etc.), a laptop computer, a tablet computer, a PDA, an MID (Mobile Internet Devices), a PAD, a desktop computer, a smart TV, an in-vehicle device, etc. A client can be installed on the above-mentioned terminal device, wherein the terminal device 102 can be installed with a client having a real-time virtual scene rendering function, such as a game client, a video playback client, etc.
[0038] The terminal device 102 is also provided with a display, a processor, and a memory. The display can be used to display the program interface of the game program, and the processor can be used to render the virtual scene based on the acquired processing information; the memory is used to store various rendering data required for rendering the game scene. It is understood that when the server 104 receives the operation information sent by the terminal device 102, it can process the operation information and send a corresponding operation control response. When the terminal device 102 receives the operation control response sent by the server 104 via the network 110, it can update the relevant scene data based on the operation control response sent by the server and implement the rendering of the virtual scene locally.
[0039] The server 104 can be a single server, a server cluster consisting of multiple servers, or a cloud server. The server includes a database and a processing engine. The processing engine is used to process operational information sent by terminal devices; the database can be used to store information related to virtual scenes used in the game client.
[0040] According to one aspect of an embodiment of the present application, the collision event determination system may further perform the following steps:
[0041] First, step S102 is executed, and the client in the terminal device 102 can send operation information to the server 104 through the network 110, for example, control information for controlling the movement of the virtual character;
[0042] Next, the server 104 determines the virtual object element to be displayed in the client according to the operation information, and executes step S104 to send an operation control response to the terminal device 102 via the network 110, wherein the operation control response may carry the virtual scene object information updated according to the operation information sent by the client;
[0043] Next, upon receiving the operation control response sent by the server 104, the terminal device 102 may further perform steps S106 to S110:
[0044] Step S106: Acquire a first estimated trajectory associated with the target object and a second estimated trajectory associated with the collision object, wherein the first estimated trajectory is a trajectory that the target object is estimated to move through in the next movement cycle, and the second estimated trajectory is a trajectory that the collision object is estimated to move through in the next movement cycle;
[0045] Step S108: When the spatial position relationship between the first estimated trajectory and the second estimated trajectory satisfies the reference collision condition, determining a candidate collision space associated with the collision object, wherein the candidate collision space is used to indicate a space through which the target object is not allowed to move;
[0046] Step S110 : When the plurality of candidate object positions on the first estimated trajectory include a target object position located in the candidate collision space, it is determined that a collision event occurs between the target object and the collision object.
[0047] Optionally, in this embodiment, the collision event determination method can be applied, but is not limited to, to a gaming application scenario. The gaming application can be a gaming terminal application (Application, APP) that completes a predetermined competitive gaming task in a virtual scene, such as a virtual competitive gaming application in a Multiplayer Online Battle Arena (MOBA) game application. The competitive gaming task can be, but is not limited to, a gaming task completed by a current player through human-computer interaction, where a virtual object in a virtual scene interacts with another player's virtual object through competitive interaction. The virtual item generation method can also be applied to a massively multiplayer online role-playing game (MMORPG) terminal application, in which the current player can complete social gaming tasks in the game through role-playing, from the first-person perspective of a virtual object, for example, by working together with other virtual objects to complete the gaming task. The social gaming task here can be, but is not limited to, running in an application (such as a non-standalone gaming app) in the form of a plug-in or applet, or running in an application (such as a standalone gaming app) within a game engine. The types of the aforementioned game applications may include, but are not limited to, at least one of the following: two-dimensional (2D) game applications, three-dimensional (3D) game applications, virtual reality (VR) game applications, augmented reality (AR) game applications, and mixed reality (MR) game applications. The above are merely examples and are not intended to be limiting in this embodiment.
[0048] In the above-mentioned method for determining a collision event, the possibility of a collision between the target object and the collision object is first determined by the spatial position relationship between their respective estimated trajectories. When it is determined that a collision event may occur between the two based on the spatial position relationship, the collision space associated with the collision object is then determined, and based on the position relationship between the position of the target object and the collision space, it is accurately determined whether the target object collides with the collision object. In the above-mentioned method, the collision event is first pre-detected based on the spatial position relationship of the trajectories, thereby avoiding the need to accurately detect every possible collision, thereby reducing the complexity of the collision determination process; in addition, when it is determined that there is a possibility of a collision between the target object and the collision object, the collision event is accurately identified based on the position relationship between the collision space associated with the collision object and the target object, thereby solving the technical problem of inaccurate collision event identification results in the existing method and achieving the technical effect of improving the accuracy of collision event identification.
[0049] The above is only an example and is not limited in this embodiment.
[0050] As an optional implementation, as shown in FIG2 , the method for determining a collision event may include the following steps:
[0051] S202, obtaining a first estimated trajectory associated with the target object and a second estimated trajectory associated with the collision object, wherein the first estimated trajectory is a movement trajectory that the target object will pass through in the next movement cycle, and the second estimated trajectory is a movement trajectory that the collision object will pass through in the next movement cycle;
[0052] S204, when the spatial position relationship between the first estimated trajectory and the second estimated trajectory satisfies the reference collision condition, determining a candidate collision space associated with the collision object, wherein the candidate collision space is used to indicate a space through which the target object is not allowed to move;
[0053] S206 : When the plurality of candidate object positions on the first estimated trajectory include a target object position located in the candidate collision space, determining that a collision event occurs between the target object and the collision object.
[0054] That is, when a candidate object position on the first estimated trajectory is located within the candidate collision space, the candidate object position is the target object position, and it can be determined that a collision event occurs between the target object and the collision object.
[0055] It should be noted that the above-mentioned method for determining collision events can be applied to, but is not limited to, an application that can render a virtual scene. For example, the above-mentioned application can include, but is not limited to, a game application, a video playback application, a map navigation application, etc. It can be understood that in the above-mentioned different types of applications, in order to achieve real-time rendering of the virtual scene, it is necessary to accurately identify the collision events occurring in the virtual scene. For example, in a game application, in the process of controlling the movement of a virtual character in a virtual scene, it is necessary to render the collision effect in real time when the virtual character collides with a virtual object in the virtual scene; for another example, in a map navigation application, a virtual navigation interface corresponding to the real navigation scene can be rendered in the interface for the current navigation state, and in this interface, when a collision is detected between different virtual objects in the virtual scene, a corresponding collision effect can be rendered. In this embodiment, the application type corresponding to the above-mentioned method for determining collision events is not limited.
[0056] It should be further explained that the specific execution entities of the above-mentioned collision event determination method may vary for different applications. For example, in a terminal gaming application, the above-mentioned collision event determination method may be applied to the terminal, where the terminal renders the game scene in real time. In a cloud gaming application, the above-mentioned collision event determination method may be applied to the server, where the server renders the game scene in real time and sends the rendered image to the terminal in the form of a video for display. In this embodiment, the specific execution entity of the above-mentioned collision event determination method is not limited.
[0057] It is understood that the specific types of the target object and collision object in step S202 can be determined based on the specific application scenario. For example, in a game scenario, the target object can be a game object element that requires collision detection, and the collision object can be another game object element that requires collision detection. Specifically, the target object can be a first virtual object controlled by the player in the game application, and the collision object can be a second virtual object in the game application that is not controlled and is located in the virtual scene.
[0058] Optionally, the target object may also be a part of the elements included in the first virtual object in the virtual scene, and the collision object may also be a part of the elements included in the second virtual object in the virtual scene. For example, in a case where the virtual scene includes a virtual object controlled by the player and a non-controlled virtual item, the target object may be a model object indicating the head of the virtual object, and the collision object may be a model object indicating a plane of the virtual item. Specifically, in a case where the virtual object is a virtual character, the target object may be a spherical model indicating the head of the virtual character, and in a case where the virtual item is a table, the collision object may be a model object indicating the tabletop of the table, that is, a rectangular model.
[0059] The target objects and virtual objects described above are described in detail below with reference to Figure 3. As shown in Figure 3, multiple target objects are shown for indicating the "virtual sleeve" of the first virtual object, including a first target object 301 for indicating the tip of the "virtual sleeve," a second target object 302 for indicating the cuff of the "virtual sleeve," and a third target object 303 for indicating the hem of the "virtual sleeve." As shown in Figure 3, the multiple target objects used to indicate the "virtual sleeve" can be indicated by spherical models. Simply obtaining the center coordinates and radius of each spherical model is sufficient for collision event detection, significantly improving collision event detection efficiency.
[0060] As a specific implementation method, collision detection can be performed based on PBD (Position base dynamics, position-based dynamic model) simulation technology. PBD is a dynamic simulation technology that is widely used in the real-time field. Unlike physics-based dynamics, PBD does not calculate energy when calculating elastic potential energy constraints. Without energy, there is no calculation process for obtaining the gradient of energy to obtain conservative forces. Therefore, the calculation overhead is small and the operation efficiency is high. PBD is a position-based method. When solving deformation constraints, it is similar to shape matching. The position after time integration is directly projected onto the constrained flow type. This process is generally completed through Gauss-Seidel or Jacobi iteration. It can be seen that the characteristic of PBD to directly solve the position is very suitable for fields that do not require high physical accuracy and real-time requirements.
[0061] In the present embodiment, the above-mentioned target object can be referred to as "bone" in the above-mentioned PBD simulation technology, which is used to simulate the various virtual parts of the virtual object. It is understandable that the bone-based PBD is more suitable for mobile phone platforms with lower computing power than the vertex-based approach. In the vertex-based approach, tens of thousands of particles are updated per frame (each particle is mapped to a vertex), while in the bone-based approach, the number of particles updated per frame is much less (each particle is mapped to a bone), generally not exceeding 100 bones. At the same time, the skeleton chain and skinning can be specified by the production staff, so controllability is higher. This bone-based PBD method has a wide range of application requirements in, for example, games and animations, particularly in application scenarios with strict frame rate requirements. For example, in Figure 3, multiple target objects, i.e., multiple virtual skeletons, for indicating the long sleeves of a virtual character are shown, which are represented as multiple spherical models in Figure 3.
[0062] It should be further explained that in the above step S202, when obtaining the first estimated trajectory associated with the target object and the second estimated trajectory associated with the collision object, the trajectories that the target object and the collision object will move through in the next movement cycle after the current moment are respectively estimated as the first estimated trajectory and the second estimated trajectory. The above movement cycle can be an estimated duration determined for the real-time rendering scene, such as 1s, 2s, etc. Optionally, when the probability of a collision event occurring in the current real-time rendering scene is low, the above movement cycle can select a longer first duration value, and when the probability of a collision event occurring in the current real-time rendering scene is high, the above movement cycle can select a shorter second duration value.
[0063] Corresponding to different movement cycles, the shapes of the estimated trajectories of the target object and the collision object may be different. For example, when the duration of the above-mentioned movement cycle is relatively long, the shapes of the above-mentioned estimated trajectories may be determined according to the movement states of the current target object and the collision object, respectively. For example, when the current movement mode of the target object is circular motion, the above-mentioned first estimated trajectory may be an arc that continues to extend along the current motion trajectory; when the current movement mode of the target object is oblique projection motion, the above-mentioned first estimated trajectory may be a parabola that continues to extend along the current motion trajectory. The method for determining the shape of the second estimated trajectory associated with the collision object may be similar to or the same as the method for determining the shape of the first estimated trajectory, and will not be repeated here.
[0064] In a specific manner, the above-mentioned movement period can be selected as a duration that matches the current rendering scene. For example, when the number of rendering frames of the current rendering scene is 20 frames, the above-mentioned movement period can be the duration of the above-mentioned one frame of virtual image, such as 0.05s. That is to say, in this embodiment, the above-mentioned movement period can be used to indicate the movement duration of the target object and the collision object respectively between the current image frame and the next image frame of the virtual scene. When the above-mentioned movement period is the duration of one frame of image, the above-mentioned first estimated trajectory and the above-mentioned second estimated trajectory can also be simplified to the form of line segments. For example, the estimated position of the target object or the collision object in the next image frame can be obtained respectively, and the line between the position of the current image frame and the estimated position of the next image frame is determined as the above-mentioned estimated trajectory. It can be understood that since the interval between image frames is short, the duration corresponding to the movement period in this embodiment is also short. Therefore, the estimated trajectory can be modeled by line segments, thereby improving the efficiency of trajectory estimation.
[0065] Furthermore, in step S204, the spatial positional relationship between the first estimated trajectory and the second estimated trajectory includes one of the following: the distance between the two trajectories, the intersection of the two trajectories (including perpendicularity), or the parallelism of the two trajectories. In this embodiment, the specific type of the aforementioned spatial positional relationship is not limited. The aforementioned reference collision condition may include, but is not limited to, a distance condition, an intersection condition, or a parallel or perpendicular relationship condition. In this embodiment, the specific type of the aforementioned reference collision condition is not limited.
[0066] The following describes several optional conditional determination methods. In one embodiment, the reference collision condition can be an intersection condition, meaning that the reference collision condition is determined to be satisfied when the first and second estimated trajectories intersect. In another embodiment, the reference collision condition can be a distance condition, meaning that the reference collision condition is determined to be satisfied when the shortest distance between the first and second estimated trajectories is less than a distance threshold. In this embodiment, the specific form of the conditional determination is not limited.
[0067] It should be noted that, if it is determined that the first and second estimated trajectories meet the reference collision conditions, a candidate collision space associated with the target object can be determined. It will be appreciated that the candidate collision space indicates a space where the target object is not permitted to pass. Furthermore, once the candidate collision space has been determined, it can be further determined whether a collision event has occurred based on the positional relationship between the candidate collision space and the target object.
[0068] Optionally, the spatial shape information or spatial form of the candidate collision space may be determined based on the shape of the collision object. For example, if the collision object is spherical, the candidate collision space may be a spherical form that includes the collision object. For another example, if the collision object is an elongated rectangle, the candidate collision space may be a cylindrical or cubic form that includes the collision object.
[0069] In another embodiment, the candidate collision space may be a half-space determined based on the second estimated trajectory. For example, it may be a curved surface determined based on the estimated trajectory, with one side of the curved surface representing a traversable spatial region, and the other side of the curved surface, which includes the collision object, representing a candidate collision space where the target object is not allowed to pass. The half space determined by the curved surface is referred to as the half-space. In this embodiment, the specific form of the candidate collision space is not limited.
[0070] In the above step S204, when the candidate collision space associated with the collision object is determined, in the above step S206, multiple candidate object positions on the first estimated trajectory are further obtained and compared with the target space position in the candidate collision space. When the multiple candidate object positions include the target object position located in the candidate collision space, it is determined that a collision event occurs between the target object and the collision object.
[0071] It should be noted that the above-mentioned candidate object positions can be selected according to actual needs. For example, multiple object positions can be selected at a certain time interval, or multiple candidate positions can be selected at a certain distance interval. This embodiment does not limit the selection method of the above-mentioned candidate object positions.
[0072] In the above-mentioned method for determining a collision event, the possibility of a collision between the target object and the collision object is first determined by the spatial position relationship between their respective estimated trajectories. When it is determined that a collision event may occur between the two based on the spatial position relationship, the collision space associated with the collision object is then determined, and based on the position relationship between the position of the target object and the collision space, it is accurately determined whether the target object collides with the collision object. In the above-mentioned method, the collision event is first pre-detected based on the spatial position relationship of the trajectories, thereby avoiding the need to accurately detect every possible collision, thereby reducing the complexity of the collision determination process; in addition, when it is determined that there is a possibility of a collision between the target object and the collision object, the collision event is then accurately identified based on the position relationship between the collision space associated with the collision object and the target object, thereby solving the technical problem of inaccurate collision event identification results in the existing method and achieving the technical effect of improving the accuracy of collision event identification.
[0073] As an optional implementation, when the spatial position relationship between the first estimated trajectory and the second estimated trajectory satisfies the reference collision condition, determining the candidate collision space associated with the collision object includes:
[0074] S1, obtaining a plurality of candidate collision positions of the collision object from the second estimated trajectory;
[0075] For each candidate collision position in the plurality of candidate collision positions,
[0076] S2, determining a candidate reference position of the candidate collision space based on the candidate collision position;
[0077] S3 : determining the candidate collision space under the candidate collision position according to the candidate reference position and the spatial shape information of the candidate collision space.
[0078] It should be noted that in this embodiment, the candidate collision space is a spatial region obtained by following the real-time, synchronous movement of the collision object. In other words, different candidate collision locations on the second estimated trajectory can correspond to different candidate collision spaces. The multiple candidate collision locations can be selected based on actual needs, for example, at a certain time interval or at a certain distance interval.
[0079] In a preferred embodiment, at the same time, a candidate collision position corresponds to a candidate object position. For example, if the candidate collision positions include points A, B, and C, and the candidate object positions include points D, E, and F, points A and D may be the two corresponding positions of the collision object and the target object at time T0, points B and E may be the two corresponding positions of the collision object and the target object at time T1, and points C and F may be the two corresponding positions of the collision object and the target object at time T2.
[0080] The above-mentioned spatial shape information is used to indicate the spatial form of the above-mentioned candidate collision space, and may include, for example, but is not limited to, a spherical form, a cylindrical form, a curved surface form, and a half-space form. It can be pre-set; alternatively, it can be determined based on the specific shape of the collision object. For example, when the collision object is a spherical shape, the spatial form of the candidate collision space is a spherical form that includes the collision object; for another example, when the collision object is an elongated shape, the spatial form of the candidate collision space can be a cylindrical form or a cubic form that includes the collision object. In this embodiment, the specific form of the above-mentioned candidate collision space is not limited.
[0081] It is understandable that in this embodiment, when candidate reference positions corresponding to respective candidate collision positions are determined, multiple candidate collision spaces can be determined at the multiple candidate reference positions based on spatial shape information, and then collision judgment is performed based on the multiple candidate collision spaces and the multiple candidate object positions on the first trajectory.
[0082] Optionally, during the collision detection process, candidate object positions and candidate collision spaces used for collision detection are matched. The specific matching method can be as follows: where the candidate collision positions include points A, B, and C, and the candidate object positions include points D, E, and F, candidate collision spaces a, b, and c are determined based on candidate collision positions A, B, and C, respectively. Then, collision detection can be performed based on candidate collision space a and the matching candidate object position D; based on candidate collision space b and the matching candidate object position E; and based on candidate collision space c and the matching candidate object position F.
[0083] Through the above-mentioned embodiment of the present application, multiple candidate collision positions of the collision object are obtained from the second estimated trajectory. For each candidate collision position of the multiple candidate collision positions, a candidate reference position of the candidate collision space is determined based on the candidate collision position; based on the candidate reference position and the spatial shape information of the candidate collision space, the candidate collision space under the candidate collision position is determined, so that collision detection is performed separately according to the multiple candidate collision spaces and their corresponding candidate object positions, thereby accurately identifying the spatial location where the collision event occurs.
[0084] As an optional implementation manner, determining a candidate reference position of the candidate collision space according to the candidate collision position includes:
[0085] S1, determining a position offset distance according to a first object shape of the target object and a second object shape of the collision object, wherein the first object shape indicates a spatial area occupied by the target object and the second object shape indicates a spatial area occupied by the collision object;
[0086] S2. Moving the candidate collision position by the position offset distance according to a position offset direction to obtain the candidate reference position, wherein the position offset direction is a direction from the candidate collision position to the candidate object position corresponding to the candidate collision position.
[0087] It should be noted that, in this embodiment, the shapes of the target object and the collision object need to be combined to accurately determine the spatial position of the collision space. The above method will be described in detail below with reference to FIG4 .
[0088] As shown in Figure 4 , assuming that the current virtual space includes a spherical target object 401 and a spherical collision object 403 in a collision state, the spatial position of target object 401 can be indicated by the spatial position of target point 402, and the spatial position of collision object 403 can be indicated by the spatial position of collision point 404. Target point 402 is the center of target object 401, and the radius of target object 401 is r1. Collision point 404 is the center of collision object 403, and the radius of collision object 403 is r2.
[0089] Assume that the collision space currently associated with the collision object is a half-space, that is, based on the normal plane, one side of the normal plane is the traversable space, and the other side of the normal plane is the impassable collision space. It can be understood that the position of the collision space can be described by the position of the normal plane.
[0090] In some implementations, it is assumed that the position of the collision space is directly matched with the position of the collision point 404 used to describe the collision object 403, thereby obtaining a first normal plane 405 used to describe the first collision space. When comparing the position of the target point 402 with the position of the first normal plane 405, it can be determined that the target point 402 is not located within the first collision space to the right of the first normal plane 405. However, in reality, the current target object 401 and the collision object 403 have collided. Therefore, directly determining the collision space using the position of the collision point of the collision object cannot accurately identify the collision event.
[0091] In other solutions, assume that the position of the collision space is offset according to the shape of the collision object, that is, shifted to the left by a distance r2 to form a second normal plane 406 describing the second collision space. When comparing the position of target point 402 with the position of second normal plane 406, it can be determined that target point 402 is not located in the second collision space to the right of second normal plane 406. However, in reality, the current target object 401 and collision object 403 have collided. In other words, the collision space obtained by offsetting only the volume of the collision object is also unable to accurately identify the collision event.
[0092] In an embodiment of the present application, the position of the collision space is offset according to the first object shape of the collision object 403 and the second object shape of the target object 401, and the position offset distance is a distance value indicating the sum of the spatial areas occupied by the first object shape and the second object shape. For example, when the first object shape and the second object shape are both spheres, the position offset distance is the sum of the radii of the two spheres, that is, in Figure 4, a distance of r2+r1 is moved to the left to form a third normal plane 407 that describes the third collision space. In the process of comparing the position of the target point 402 with the position of the third normal plane 407, it can be determined that the target point 402 is located in the third collision space to the right of the third normal plane 407. Therefore, the collision space obtained by offsetting the volume of the collision object and the volume of the target object can accurately identify the collision event.
[0093] Through the above-mentioned implementation of the present application, the position offset distance is determined according to the first object shape of the target object and the second object shape of the collision object, wherein the first object shape indicates the spatial area occupied by the target object and the second object shape indicates the spatial area occupied by the collision object; multiple candidate collision positions are moved according to the position offset distance and the position offset direction, respectively, to obtain multiple candidate reference positions corresponding to the multiple candidate collision positions, thereby accurately determining the spatial area where the collision space is located, and then achieving the technical effect of accurately identifying collision events.
[0094] As an optional implementation manner, the determining of the candidate collision space under the candidate collision position based on the candidate reference position and the spatial shape information of the candidate collision space includes:
[0095] S1, when the spatial shape information indicates that the candidate collision space is a half-space area, obtaining a reference object position of the target object and a reference collision position of the collision object, wherein the reference object position is the candidate object position corresponding to the target object at a reference time, and the reference collision position is the candidate collision position corresponding to the collision object at the reference time;
[0096] S2, determining a reference space normal vector based on the reference object position and the reference collision position, wherein the position offset direction is the same as the direction of the reference space normal vector, and the direction of the reference space normal vector is the direction from the reference collision position to the reference object position;
[0097] S3. Determine a normal plane indicating the candidate collision space based on a reference space normal vector and the candidate reference position corresponding to the reference collision position, wherein a first side bounded by the normal plane is a first half-space region that does not allow the target object to pass through, and a second side bounded by the normal plane is a second half-space region that allows the target object to pass through, and the second half-space region is the half-space region indicated by the reference space normal vector.
[0098] It should be noted that in this embodiment, the collision space can be described using a Sign Distance Function (SDF). The SDF is a function used to describe the collision region (i.e., the infeasible region) and is incorporated into the solution process as a constraint function. The SDF is a metric function whose absolute value is a function of distance; its sign indicates whether a point is inside or outside the boundary.
[0099] As shown in Figure 5, the SDF functions corresponding to the collision spaces of three different spatial forms are shown. Among them, x is the point to be judged. Specifically, in Figure 5(a), the boundary is represented by the normal plane, p is the center of the normal plane, n is the normal vector, and the direction pointing to n is outside the boundary; in Figure 5(b), the boundary is represented by a circle, r is the radius, c is the center of the circle, and the outside of the circle is outside the boundary; in Figure 5(c), the boundary is represented by the surface of a cylinder, including 2 bottom surfaces and 1 side surface, wherein p is the center of the bottom surface, r is the radius of the bottom surface, and n is the vector direction or axis direction of the cylinder. It can be understood that in Figure 5, the function values in three different scenarios can be taken. Constraints are performed to limit the position area corresponding to x, thereby realizing spatial constraints.
[0100] In this embodiment, the aforementioned collision space constraint can be a half-space SDF constraint, and the half-space collision space can be described by a normal plane. As shown in Figure 6, normal plane 601 divides the current virtual space into two parts. The part pointed by normal vector 602 (i.e., the right side of normal plane 601) is the spatial region where the target object is allowed to pass. The left side of normal plane 601 is the candidate collision space, which is the spatial region where the target object is not allowed to pass.
[0101] Through the above-mentioned implementation of the present application, when the spatial shape information indicates that the candidate collision space is a half-space area, the reference object position of the target object and the reference collision position of the collision object are obtained; the reference space normal vector is determined based on the reference object position and the reference collision position, wherein the position offset direction is the same as the direction of the reference space normal vector, and the direction of the reference space normal vector is the direction from the reference collision position to the reference object position; the normal plane for indicating the candidate collision space is determined based on the reference space normal vector and the candidate reference position corresponding to the reference collision position, and then the specific collision space is determined by a half-space constraint method based on the real-time position of the collision object. Since the half-space constraint method only needs to be determined by the position of a point and a vector, it avoids describing the collision space through complex spatial shapes, improves the description efficiency of the collision space, and thus improves the recognition efficiency of collision event detection.
[0102] As an optional embodiment, when the spatial position relationship between the first estimated trajectory and the second estimated trajectory satisfies the reference collision condition, before determining the candidate collision space associated with the collision object, the method further includes:
[0103] S1, obtaining a first object shape of a target object and a second object shape of a collision object, wherein the first object shape indicates a spatial region occupied by the target object and the second object shape indicates a spatial region occupied by the collision object;
[0104] S2, determining a reference collision condition based on the first object shape and the second object shape, wherein the reference collision condition indicates a distance threshold at which a collision event occurs between the target object and the collision object;
[0105] S3: determining the spatial position relationship according to a distance between the first estimated trajectory and the second estimated trajectory, wherein the first estimated trajectory and the second estimated trajectory are line segment trajectories between a current image frame and a next image frame, respectively.
[0106] In the field of mobile games, due to the real-time requirements, collision processing can adopt the solution of Discrete Collision Detection (DCD) plus Sign Distance Function (SDF). DCD detects the collision status at each detection moment. As shown in Figure 7, at three moments T = 0s, T = 0.5s, and T = 1.0s, the collision is detected based on the respective positions of the two spheres. As shown in Figure 7, at the three detection moments of t = 0s, t = 0.5s, and t = 1.0s, the target object 701 and the collision object 702 did not collide. Therefore, the detection result is: the target object 701 and the collision object 702 did not collide, but in fact, the two spheres collided at T = 0.9s.
[0107] Therefore, if the two detection times are far apart, or the ball moves too fast, the collision may be missed at the detection time, resulting in penetration and unrealistic simulation. If the detection density is increased to avoid missed collisions, the computational overhead increases proportionally with the detection density.
[0108] Through the above-mentioned implementation mode of the present application, the shapes of the target object and the collision object can be obtained first, and then the distance conditions for pre-collision detection can be determined as reference collision conditions, and the possibility of collision between the target object and the collision object can be determined based on the interval distance between the two estimated trajectories and the above-mentioned distance conditions.
[0109] It can be understood that when the distance threshold indicated by the volume of the target object and the collision object is less than the shortest distance between the two estimated trajectories, it is determined that no collision will occur between the target object and the collision object, and the subsequent collision detection step is skipped; when the distance threshold indicated by the volume of the target object and the collision object is greater than or equal to the shortest distance between the two estimated trajectories, it is determined that a collision may occur between the target object and the collision object, and the subsequent collision detection step is executed, thereby avoiding high-density and high-frequency collision detection and improving the recognition efficiency of collision events.
[0110] As an optional embodiment, when the target object and the collision object are both spheres, the sum of the first radius of the target object and the second radius of the collision object is determined as the distance threshold; the shortest distance between the first estimated trajectory and the second estimated trajectory is determined as the interval distance, wherein the first estimated trajectory is the moving trajectory of the first sphere center corresponding to the target object, and the second estimated trajectory is the moving trajectory of the second sphere center corresponding to the collision object.
[0111] It is understood that in this embodiment, when both the target object and the collision object are spherical models, the distance threshold can be determined based on the sum of the radii of the two spheres. The collision detection method between the spherical models is described below with reference to FIG8 .
[0112] As shown in FIG8(a), a target object 801 and a first estimated trajectory 803 of the target object 801 within a movement period, and a collision object 802 and a second estimated trajectory 804 of the collision object 802 within a movement period are shown. In this embodiment, the first estimated trajectory 803 and the second estimated trajectory 804 may be line segment-shaped movement trajectories estimated for two spherical objects between two adjacent image frames.
[0113] First, a reference vector 805 corresponding to the shortest distance between the first estimated trajectory 803 and the second estimated trajectory 804 is determined.
[0114] Next, the conditions for creating candidate collision spaces, i.e., reference collision conditions, can be determined by the following formula: minDistance <r1+r2+r0 (1)
[0115] Where minDistance is the shortest distance between the first estimated trajectory 803 and the second estimated trajectory 804, i.e., the modulus of the reference vector 805, r1 is the radius of the target object 801, r2 is the radius of the target object 802, and r0 is the pre-detection radius (which can be set as needed). If the above reference collision conditions are met, a corresponding candidate collision space is generated based on the collision object 802.
[0116] Specifically, as shown in FIG8(b), based on the above constrained half-space SDF method, the normal of the candidate collision space is calculated as follows: normal = Normalize((x1, y1, z1) - (x2, y2, z2)) (2)
[0117] Where (x1, y1, z1) is the real-time position of target object 801 on first estimated trajectory 803, and (x2, y2, z2) is the real-time position of collision object 802 corresponding to (x1, y1, z1) on second estimated trajectory 804. According to the above formula, the direction of the normal vector of the candidate collision space is the direction from the center of the collision object to the center of the target object.
[0118] Furthermore, the position of the normal plane of the candidate collision space can be determined by the following formula: normal =(x2,y2,z2)+(r1+r2)*normal (3)
[0119] According to the above formula, the position of the normal plane of the candidate collision space is the position obtained by offsetting the center position of the collision object from the target object by a reference distance, where the reference distance is the sum of the radii of the target object and the collision object.
[0120] In this embodiment, the candidate object position and candidate collision position for collision detection are the end point and starting point of the trajectory, respectively. In (b) of Figure 8, at the initial position of the estimated trajectory, the normal vector used to indicate the candidate collision space is determined to be normal vector 806, and the normal plane is 807. It can be understood that since the basis for judging the positional relationship between the target object and the candidate collision space is the position of the center of the target object, it is necessary to continue moving the distance r1 according to the radius of the target object outside the tangent of the collision object to obtain the normal plane 809 and the normal vector 808 as the candidate collision space for determining the collision event. During actual rendering, the image for collision constraint can be rendered according to the normal plane 809 and the normal vector 808.
[0121] Furthermore, as shown in FIG8(b), a candidate collision space can be further constructed based on the above method at the end point of the trajectory, including normal vector 810 and normal plane 811, as well as normal vector 812 and normal plane 813 after moving distance r1. At this time, if it is detected that the target object 801' is located in the first half-space area of normal plane 813 indicated by the reverse direction of normal vector 812 (i.e., outside the normal line), it is determined that the target object 801' is located in the collision space, thereby determining that a collision event has occurred between the current target object and the collision object.
[0122] Through the above-mentioned implementation mode of the present application, when the target object and the collision object are both spheres, the first radius of the target object and the second radius of the collision object are obtained; the distance threshold determined according to the sum of the radii of the first radius and the second radius is used as the reference collision condition; the shortest distance between the first estimated trajectory and the second estimated trajectory is determined as the target interval distance, wherein the first estimated trajectory is the moving trajectory of the first sphere center corresponding to the target object, and the second estimated trajectory is the moving trajectory of the second sphere center corresponding to the collision object; when the target interval distance is less than the distance threshold, it is determined that the spatial position relationship between the first estimated trajectory and the second estimated trajectory meets the reference collision condition; when the target interval distance is greater than or equal to the distance threshold, it is determined that the spatial position relationship between the first estimated trajectory and the second estimated trajectory does not meet the reference collision condition, and it is determined that no collision event occurs between the target object and the collision object within the moving period, thereby achieving accurate detection of collision events when the target object and the collision object are both spherical models.
[0123] As an optional embodiment, the target object is a sphere, the collision object is a capsule, and the capsule is composed of two identical hemispheres and a cylinder, the two hemispheres are respectively spliced with the two bottom surfaces of the cylinder, and the radius of the hemisphere is the same as the bottom radius of the cylinder; the sum of the third radius of the target object and the fourth radius of the collision object is determined as the distance threshold, wherein the fourth radius is the radius of the hemisphere; the shortest distance between the first estimated trajectory and the second estimated trajectory is determined as the interval distance, wherein the first estimated trajectory is the moving trajectory of the third sphere center corresponding to the target object, and the second estimated trajectory is the moving trajectory of the reference point in the capsule, and the reference point is the point on the axis of the capsule that is closest to the third sphere center.
[0124] It should be noted that, in this embodiment, when the target object is a spherical model and the collision object is a capsule model, the method for determining the reference collision condition in the model system can be determined by the above method.
[0125] As an optional implementation manner, determining the shortest distance between the first estimated trajectory and the second estimated trajectory as the separation distance includes:
[0126] S1, determining a reference vector according to the center position of the third sphere center and the position of the reference point, wherein the indication direction of the reference vector is the direction from the position of the reference point to the center position of the sphere;
[0127] S2, obtaining a first projection distance of a vector corresponding to the first estimated trajectory on the reference vector, and a second projection distance of a vector corresponding to the second estimated trajectory on the reference vector;
[0128] S3: Determine the separation distance based on the first projection distance, the second projection distance, and a third distance indicated by the reference vector, wherein the third distance is the shortest distance between the first estimated trajectory and the second estimated trajectory, that is, the modulus of the reference vector.
[0129] The collision detection method in the sphere-capsule model system is described below with reference to Figure 9. As shown in Figure 9(a), a target object 901 and a first estimated trajectory 903 of the target object 901 within a movement period are shown.
[0130] First, the closest point of the center of target object 901 on axis 905 of capsule-shaped collision object 902 is determined as reference point 907, a reference vector 906 pointing from reference point 907 to the center of target object 901, and a second estimated trajectory 904 of reference point 907 within the movement period. In this embodiment, the first estimated trajectory 903 and the second estimated trajectory 904 may be line segment-shaped movement trajectories estimated for the target object and the collision object between two image frames.
[0131] Then, the reference collision condition of the candidate collision space can be determined by the following formula: minDistance+close1DistProjN-close2DistProjN <r1+r2+r0 (4)
[0132] Among them, minDistance is the shortest distance between the first estimated trajectory 903 and the second estimated trajectory 904, that is, the modulus of the reference vector 906; close1DistProjN is the projection result of the first estimated trajectory 903 on the reference vector 906, close2DistProjN is the projection result of the second estimated trajectory 904 on the reference vector 906, r0 is the pre-detection radius (which can be set according to actual needs), r1 is the radius of the target object 901, and r2 is the radius of the collision object 902, that is, the capsule body (that is, the radius of the hemisphere).
[0133] Then, when the above reference collision condition is satisfied, a corresponding collision space is generated according to the collision object 902. Specifically, as shown in FIG9(b): normal=Normalize((x1, y1, z1)-(x2, y2, z2)) (5)
[0134] Where (x1, y1, z1) is the real-time position of target object 901 on first estimated trajectory 903, and (x2, y2, z2) is the real-time position of reference point 907 on collision object 902 corresponding to (x1, y1, z1) on second estimated trajectory 904. According to the above formula, the direction of the normal vector of the candidate collision space is the direction from reference point 907 of the collision object to the center of the target object.
[0135] Furthermore, the position of the normal plane of the candidate collision space can be determined by the following formula: normal =(x2,y2,z2)+(r1+r2)*normal (6)
[0136] According to the above formula, the position of the normal plane of the candidate collision space is the position obtained by offsetting the reference distance to the target object based on the position of the reference point 907 of the collision object. Among them, the reference distance is the sum of the radius of the target object and the radius of the collision object. As shown in Figure 9 (b), at the initial position of the estimated trajectory, the normal vector used to indicate the candidate collision space is determined to be the normal vector 908 and the normal plane 909. It can be understood that since the basis for judging the positional relationship between the target object and the candidate collision space is the position of the center of the target object, it is necessary to continue to move r1 distance according to the radius of the target object outside the tangent of the collision object to obtain the normal vector 910 and the normal plane 911, which are used to determine the candidate collision space of the collision event. In actual rendering, the image for collision constraint can be rendered according to the normal plane 911 and the normal vector 910.
[0137] Furthermore, assuming that in this embodiment, the candidate object position and the candidate collision position for collision detection are the end point and the starting point of the trajectory, respectively, as shown in FIG9(b), a candidate collision space can be further constructed at the end point of the trajectory based on the above method, including a normal vector 912 and a normal plane 913, as well as a normal vector 914 and a normal plane 915 after moving the reference distance. At this time, if it is detected that the target object 901' is located in the first half-space area of the normal plane 915 indicated by the reverse direction of the normal vector 914 (i.e., outside the normal line), it is determined that the target object 901' is located in the collision space, thereby determining that a collision event has occurred between the current target object and the collision object.
[0138] Through the above-mentioned implementation of the present application, when the target object is a sphere and the collision object is a capsule, the third radius of the target object and the fourth radius of the collision object are obtained; the distance threshold determined according to the sum of the third radius and the fourth radius is used as a reference collision condition; the shortest distance between the first estimated trajectory and the second estimated trajectory is determined as the target interval distance; when the target interval distance is less than the distance threshold, it is determined that the spatial position relationship between the first estimated trajectory and the second estimated trajectory meets the reference collision condition; when the target interval distance is greater than or equal to the distance threshold, it is determined that the spatial position relationship between the first estimated trajectory and the second estimated trajectory does not meet the reference collision condition, and it is determined that no collision event occurs between the target object and the collision object within the moving period, thereby achieving accurate detection of collision events when the target object is a spherical model and the collision object is a capsule model.
[0139] The following describes another collision detection method in a model scenario with reference to Figure 10. As shown in Figure 10, the target object 1001 is a combined model obtained by connecting two sphere models and the line segments between the spheres, and the collision object 1004 is a capsule model.
[0140] Before performing collision detection on the combined model and the capsule model, the two points closest to the axis of the target object 1001 and the axis 1008 of the collision object 1004 can be determined. That is, a first reference point 1002 is determined on the axis of the target object 1001, and a second reference point 1005 is determined on the axis 1008 of the collision object 1004. A first estimated trajectory 1003 corresponding to the first reference point 1002 and a second estimated trajectory 1006 corresponding to the second reference point 1005 are then determined.
[0141] Then, the reference collision condition of the candidate collision space corresponding to the collision object 1004 can be determined by the following formula: minDistance+close1DistProjN-close2DistProjN <r1+r2+r0 (7)
[0142] Among them, minDistance is the shortest distance between the first estimated trajectory 1003 and the second estimated trajectory 1006, that is, the modulus of the reference vector 1007, wherein the reference vector 1007 is the vector from the second reference point 1005 to the first reference point 1002; close1DistProjN is the projection result of the first estimated trajectory 1003 on the reference vector 1007, close2DistProjN is the projection result of the second estimated trajectory 1006 on the reference vector 1007, r0 is the pre-detection radius (which can be set according to actual needs), r1 is the radius of the target object 1001 (that is, the radius of the spherical model in the combined model), and r2 is the radius of the collision object 1004, that is, the capsule body (that is, the radius of the hemisphere).
[0143] It is understandable that, when the conditions are met according to the first estimated trajectory 1003 and the second estimated trajectory 1006, collision detection can be further performed by referring to the collision detection method under the aforementioned sphere-capsule model system. Specifically, normal = Normalize((x1, y1, z1) - (x2, y2, z2)) (8)
[0144] Where (x1, y1, z1) is the real-time position of first reference point 1002 on first estimated trajectory 1003, and (x2, y2, z2) is the real-time position of second reference point 1005 on collision object 1004 on second estimated trajectory 1006 corresponding to (x1, y1, z1). According to the above formula, the direction of the normal vector of the candidate collision space is the direction from second reference point 1005 of the collision object to first reference point 1002.
[0145] Furthermore, the position of the normal plane of the candidate collision space can be determined by the following formula: normal=(x2,y2,z2)+(r1+r2)*normal (9)
[0146] According to the above formula, the position of the normal plane of the candidate collision space is the position obtained by offsetting the reference distance from the second reference point 1005 of the collision object to the target object. The reference distance is the sum of the radius of the target object and the radius of the collision object capsule.
[0147] As an optional implementation manner, after determining that a collision event occurs between the target object and the collision object, the method further includes:
[0148] S1, determining the intersection of the first estimated trajectory and the spatial boundary of the candidate collision space when a collision event occurs;
[0149] S2, determining the position corresponding to the intersection as the target collision position;
[0150] S3: Using the target collision position as the end point position of the target object moving along the first estimated trajectory.
[0151] It can be understood that in this embodiment, when it is determined that a collision event occurs between the target object and the collision object, the intersection position of the first estimated trajectory of the target object and the spatial boundary of the collision space can be determined as the target collision position, and the target object can be controlled to move to the target collision position, thereby avoiding the phenomenon of "penetration" of the target object in the area where it is not allowed to pass.
[0152] Through the above-mentioned implementation method of the present application, the intersection of the first estimated trajectory and the spatial boundary of the candidate collision space is determined; the position corresponding to the intersection is determined as the target collision position; the target collision position is used as the end point position of the target object moving along the first estimated trajectory, thereby determining the precise collision position based on the collision space determined in real time, thereby improving the detection accuracy of the collision event.
[0153] The above-mentioned embodiment will be described below with reference to specific examples.
[0154] In this embodiment, a pre-detection technique is adopted. By utilizing the impenetrability of the half-space SDFf, pre-detection is performed before the start of each frame of motion simulation to determine whether to create collision constraints for a single bone. This method solves the penetration problem in DCD+SDF without increasing the detection density. The following will illustrate through cases such as a bone and a sphere, a bone and a capsule, and a bone connecting line segment and a capsule. In the embodiments of this application, a bone is a part on a virtual object that requires collision detection, corresponding to the target object in the above embodiment, and a bone connecting line segment indicates two connected parts on the virtual object that require collision detection. The above sphere and capsule are used to indicate virtual items in the virtual scene, corresponding to the above collision objects.
[0155] In a specific embodiment, a collision detection method for a bone-sphere model is proposed. As shown in Figure 8: On a 2D plane, the white sphere represents the bone, and the gray sphere represents the collision object. First, calculate the motion trajectory line segment of the bone in the current frame, and then calculate the motion trajectory line segment of the sphere. Then, find the minimum distance minDistance between the two line segments, that is, the reference vector 805. Given the bone radius r1, the sphere radius r2, and a pre-detection radius r0. When minDistance < r1 + r2 + r0, the reference collision condition is satisfied. The constraint half-space SDF normal = Normalize(bone coordinate - spherical coordinate), and the position = spherical center + (bone radius + spherical radius) * SDF normal. As shown in Figure 8(b), there is no overlapping area between the position of the bone (dashed white sphere) and the position of the sphere during detection, and the traditional detection scheme cannot detect the collision. However, in this embodiment, as the candidate collision space created by the pre-detection moves with the sphere, the bone motion is finally correctly constrained within the feasible region.
[0156] In another specific embodiment, when determining a bone and a capsule, as shown in Figure 9, first, calculate the nearest reference point of the bone on the capsule axis and the reference vector 906 between the bone and the reference point. Then, project the bone motion trajectory line segment and the motion trajectory line segment of the reference point on the capsule axis onto the reference vector 906 to obtain the projected lengths close1DistProjN and close2DistProjN respectively. Given the bone radius r1, the capsule radius r2, and the pre-detection radius r0. When minDistance + close1DistProjN - close2DistProjN < r1 + r2 + r0, the reference collision condition is satisfied. Normal = Normalize(bone coordinate - capsule axis reference point), and the position = capsule axis reference point + (bone radius + capsule radius) * SDF normal. As shown in Figure 9(b), the constraint of the bone moves and rotates with the capsule body, and the bone motion is constrained within the feasible region.
[0157] In another specific embodiment, when the skeleton connecting line segment and the capsule are judged, the method is similar to the judgment method of the skeleton and the capsule, except that the vector between the reference point of the skeleton connecting line segment and the reference point of the capsule axis is used as the reference vector at the start frame, and the projection length of the motion trajectory segment of the two reference points on the reference vector is determined. When the reference collision condition is met, the constrained half-space SDF normal = Normalize (reference point of the skeleton connecting line segment - reference point of the capsule axis), position = reference point of the capsule axis + (skeleton radius + capsule radius) * SDF normal. When solving the edge constraint, both reference points need to be restricted outside the candidate collision space.
[0158] Through the above-mentioned implementation of the present application, a discrete collision detection scheme is provided. Before the collision check, it is determined whether to create a half-space SDF constraint for the current simulated bone in the current simulation frame based on the distance relationship between the starting and ending positions of the simulated bone and the linear trajectory of the movement and the starting and ending positions and the linear trajectory of the movement of the collision body. Due to the position constraint characteristics of the half-space SDF constraint, even if the movement distance of the simulated bone is too large, the phenomenon of penetrating the collision body cannot occur. This achieves the solution to the penetration problem in the DCD+SDF scheme without increasing the detection density, while reducing computational overhead and improving detection efficiency.
[0159] It should be noted that for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by this application.
[0160] According to another aspect of the embodiments of the present application, a device for determining a collision event for implementing the above-mentioned method for determining a collision event is also provided. As shown in FIG11 , the device includes:
[0161] an acquisition unit 1102 configured to acquire a first estimated trajectory associated with the target object and a second estimated trajectory associated with the collision object, wherein the first estimated trajectory is a movement trajectory that the target object will pass through in a next movement cycle, and the second estimated trajectory is a movement trajectory that the collision object will pass through in the next movement cycle;
[0162] A first determining unit 1104 is configured to determine a candidate collision space associated with the collision object when the spatial position relationship between the first estimated trajectory and the second estimated trajectory satisfies a reference collision condition, wherein the candidate collision space indicates a space through which the target object is not allowed to move; and
[0163] The second determining unit 1106 is configured to determine that a collision event occurs between the target object and the collision object when the plurality of candidate object positions on the first estimated trajectory include a target object position located in the candidate collision space.
[0164] Optionally, in this embodiment, the embodiments to be implemented by the above-mentioned various unit modules can refer to the above-mentioned various method embodiments, which will not be repeated here.
[0165] According to another aspect of an embodiment of the present application, an electronic device for implementing the above-described method for determining a collision event is also provided. The electronic device may be a terminal device or a server as shown in FIG12 . This embodiment is described using the terminal device as an example. As shown in FIG12 , the electronic device includes a memory 1202 and a processor 1204. The memory 1202 stores a computer program, and the processor 1204 is configured to execute the steps of any of the above-described method embodiments using the computer program.
[0166] Optionally, in this embodiment, the electronic device may be located in at least one network device among a plurality of network devices of a computer network.
[0167] Optionally, in this embodiment, the processor may be configured to execute the following steps through a computer program:
[0168] S1, obtaining a first estimated trajectory associated with a target object and a second estimated trajectory associated with a collision object, wherein the first estimated trajectory is a movement trajectory that the target object will pass through in a next movement cycle, and the second estimated trajectory is a movement trajectory that the collision object will pass through in the next movement cycle;
[0169] S2, when the spatial position relationship between the first estimated trajectory and the second estimated trajectory satisfies a reference collision condition, determining a candidate collision space associated with the collision object, wherein the candidate collision space is used to indicate a space through which the target object is not allowed to move; and
[0170] S3: When the plurality of candidate object positions on the first estimated trajectory includes a target object position located in the candidate collision space, determining that a collision event occurs between the target object and the collision object.
[0171] Alternatively, those skilled in the art will appreciate that the structure shown in FIG12 is for illustration only, and the electronic device may also be a vehicle-mounted terminal, a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (MID), a PAD, or other terminal device. FIG12 does not limit the structure of the above-mentioned electronic device. For example, the electronic device may include more or fewer components (such as a network interface, etc.) than those shown in FIG12, or have a configuration different from that shown in FIG12.
[0172] Memory 1202 can be used to store software programs and modules, such as program instructions / modules corresponding to the collision event determination method and apparatus in the embodiments of the present application. Processor 1204 executes the software programs and modules stored in memory 1202 to execute various functional applications and data processing, thereby implementing the collision event determination method described above. Memory 1202 may include high-speed random access memory (RAM) and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some embodiments, memory 1202 may further include memory remotely located from processor 1204, which can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof. Memory 1202 can specifically, but is not limited to, be used to store file information such as target logical files. As an example, as shown in FIG12 , memory 1202 may, but is not limited to, include the acquisition unit 1102, the first determination unit 1104, and the second determination unit 1106 of the collision event determination apparatus described above. In addition, it may also include but is not limited to other module units in the above-mentioned collision event determination device, which will not be repeated in this example.
[0173] Optionally, the transmission device 1206 is configured to receive or send data via a network. Specific examples of the network may include a wired network and a wireless network. In one embodiment, the transmission device 1206 includes a network interface controller (NIC), which can be connected to other network devices and a router via a network cable to communicate with the Internet or a local area network. In one embodiment, the transmission device 1206 is a radio frequency (RF) module, which is configured to communicate with the Internet wirelessly.
[0174] In addition, the electronic device further includes: a display 1208 and a connection bus 1210 for connecting various module components in the electronic device.
[0175] In other embodiments, the terminal device or server may be a node in a distributed system, wherein the distributed system may be a blockchain system, and the blockchain system may be a distributed system formed by connecting multiple nodes through network communication. The nodes may form a peer-to-peer (P2P) network, and any computing device, such as a server, terminal, or other electronic device, may become a node in the blockchain system by joining the peer-to-peer network.
[0176] According to one aspect of the present application, a computer program product is provided, comprising a computer program / instructions containing program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via a communication component and / or installed from a removable medium. When the computer program is executed by a central processing unit, the various functions provided in the embodiments of the present application are performed.
[0177] The serial numbers of the above embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0178] According to one aspect of the present application, a computer-readable storage medium is provided. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the above-mentioned method for determining a collision event.
[0179] Optionally, in this embodiment, the computer-readable storage medium may be configured to store a computer program for performing the following steps:
[0180] S1, obtaining a first estimated trajectory associated with a target object and a second estimated trajectory associated with a collision object, wherein the first estimated trajectory is a movement trajectory that the target object will pass through in a next movement cycle, and the second estimated trajectory is a movement trajectory that the collision object will pass through in the next movement cycle;
[0181] S2, when the spatial position relationship between the first estimated trajectory and the second estimated trajectory satisfies a reference collision condition, determining a candidate collision space associated with the collision object, wherein the candidate collision space is used to indicate a space through which the target object is not allowed to move; and
[0182] S3: When the plurality of candidate object positions on the first estimated trajectory includes a target object position located in the candidate collision space, determining that a collision event occurs between the target object and the collision object.
[0183] Optionally, in this embodiment, a person of ordinary skill in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by instructing the hardware related to the terminal device through a program, and the program may be stored in a computer-readable storage medium, which may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0184] If the integrated units in the above embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above-mentioned computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling one or more computer devices (which can be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the above-mentioned methods in each embodiment of the present application.
[0185] In the above embodiments of the present application, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0186] In the several embodiments provided in this application, it should be understood that the disclosed client can be implemented in other ways. Among them, the device embodiments described above are merely illustrative. For example, the division of the above-mentioned units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0187] The units described above as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0188] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0189] The above is only a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A method for determining a collision event, performed by an electronic device, include: Acquire a first estimated trajectory associated with the target object and a second estimated trajectory associated with the collision object, wherein the first estimated trajectory is a movement trajectory that the target object will pass through in the next movement cycle, and the second estimated trajectory is a movement trajectory that the collision object will pass through in the next movement cycle; When the spatial position relationship between the first estimated trajectory and the second estimated trajectory satisfies a reference collision condition, determining a candidate collision space associated with the collision object, wherein the candidate collision space is used to indicate a space through which the target object is not allowed to move; and When the plurality of candidate object positions on the first estimated trajectory include a target object position located in the candidate collision space, it is determined that a collision event occurs between the target object and the collision object.
2. The method according to claim 1, in, When the spatial position relationship between the first estimated trajectory and the second estimated trajectory satisfies a reference collision condition, determining a candidate collision space associated with the collision object comprises: acquiring a plurality of candidate collision positions of the collision object from the second estimated trajectory; For each candidate collision position in the plurality of candidate collision positions, Determining a candidate reference position of the candidate collision space according to the candidate collision position; The candidate collision space under the candidate collision position is determined according to the candidate reference position and the spatial shape information of the candidate collision space.
3. The method according to claim 2, in, The step of determining a candidate reference position of the candidate collision space according to the candidate collision position includes: Determining a position offset distance according to a first object shape of the target object and a second object shape of the collision object, wherein the first object shape indicates a spatial region occupied by the target object and the second object shape indicates a spatial region occupied by the collision object; According to the position offset direction, the candidate collision position is moved by the position offset distance to obtain the candidate reference position, wherein the position offset direction is the direction in which the candidate collision position points to the candidate object position corresponding to the candidate collision position.
4. The method according to claim 3, in, The step of determining the candidate collision space under the candidate collision position according to the candidate reference position and the spatial shape information of the candidate collision space comprises: When the spatial shape information indicates that the candidate collision space is a half-space area, obtaining a reference object position of the target object and a reference collision position of the collision object, wherein the reference object position is the candidate object position corresponding to the target object at a reference time, and the reference collision position is the candidate collision position corresponding to the collision object at the reference time; Determine a reference space normal vector according to the reference object position and the reference collision position, wherein the position offset direction is the same as the direction of the reference space normal vector, and the direction of the reference space normal vector is the direction from the reference collision position to the reference object position; According to the reference space normal vector and the candidate reference position corresponding to the reference collision position, a normal plane for indicating the candidate collision space is determined, wherein a first side bounded by the normal plane is a first half-space region that does not allow the target object to pass through, and a second side bounded by the normal plane is a second half-space region that allows the target object to pass through, and the second half-space region is a half-space region indicated by the reference space normal vector.
5. The method according to claim 1, in, Before determining a candidate collision space associated with the collision object when the spatial position relationship between the first estimated trajectory and the second estimated trajectory satisfies a reference collision condition, the method further includes: Acquire a first object shape of the target object and a second object shape of the collision object, wherein the first object shape indicates a spatial region occupied by the target object, and the second object shape indicates a spatial region occupied by the collision object; Determining the reference collision condition according to the first object shape and the second object shape, wherein the reference collision condition indicates a distance threshold at which the collision event occurs between the target object and the collision object; The spatial position relationship is determined according to a spacing distance between the first estimated trajectory and the second estimated trajectory, wherein the first estimated trajectory and the second estimated trajectory are line segment trajectories between a current image frame and a next image frame, respectively.
6. The method according to claim 5, in, When both the target object and the collision object are spheres, the sum of the first radius of the target object and the second radius of the collision object is determined as the distance threshold; the shortest distance between the first estimated trajectory and the second estimated trajectory is determined as the interval distance, wherein the first estimated trajectory is the moving trajectory of the first sphere center corresponding to the target object, and the second estimated trajectory is the moving trajectory of the second sphere center corresponding to the collision object.
7. The method according to claim 5, in, The target object is a sphere, and the collision object is a capsule, which is composed of two identical hemispheres and a cylinder. The two hemispheres are respectively spliced with two bottom surfaces of the cylinder, and the radius of the hemisphere is the same as the radius of the bottom surface of the cylinder; Determine the sum of the third radius of the target object and the fourth radius of the collision object as the distance threshold, wherein the fourth radius is the radius of the hemisphere; The shortest distance between the first estimated trajectory and the second estimated trajectory is determined as the interval distance, wherein the first estimated trajectory is the moving trajectory of the third sphere center corresponding to the target object, and the second estimated trajectory is the moving trajectory of the reference point in the capsule body, and the reference point is the point on the axis of the capsule body that is closest to the third sphere center.
8. The method according to claim 6 or 7, further comprising: include: When the interval distance is less than the distance threshold, determining that the spatial position relationship between the first estimated trajectory and the second estimated trajectory satisfies the reference collision condition; When the interval distance is greater than or equal to the distance threshold, it is determined that the spatial position relationship between the first estimated trajectory and the second estimated trajectory does not satisfy the reference collision condition, and it is determined that the collision event does not occur between the target object and the collision object within the movement period.
9. The method according to claim 7, in, The step of determining the shortest distance between the first estimated trajectory and the second estimated trajectory as the interval distance includes: Determine a reference vector according to the center position of the third sphere center and the position of the reference point, wherein the indication direction of the reference vector is the direction in which the position of the reference point points to the center position; Acquire a first projection distance of a vector corresponding to the first estimated trajectory on the reference vector, and a second projection distance of a vector corresponding to the second estimated trajectory on the reference vector; The interval distance is determined according to the first projection distance, the second projection distance, and a third distance indicated by the reference vector.
10. The method according to any one of claims 1 to 7, in, After determining that a collision event occurs between the target object and the collision object, the method further includes: determining an intersection point of the first estimated trajectory and a spatial boundary of the candidate collision space when a collision event occurs; Determine the position corresponding to the intersection as the target collision position; The target collision position is used as the end point position of the target object moving along the first estimated trajectory.
11. A device for determining a collision event, include: an acquisition unit, configured to acquire a first estimated trajectory associated with a target object and a second estimated trajectory associated with a collision object, wherein the first estimated trajectory is a movement trajectory that the target object will pass through in a next movement cycle, and the second estimated trajectory is a movement trajectory that the collision object will pass through in the next movement cycle; A first determining unit is configured to determine a candidate collision space associated with the collision object when a spatial position relationship between the first estimated trajectory and the second estimated trajectory satisfies a reference collision condition, wherein the candidate collision space is used to indicate a space through which the target object is not allowed to move; and The second determining unit is configured to determine that a collision event occurs between the target object and the collision object when the plurality of candidate object positions on the first estimated trajectory include a target object position located in the candidate collision space.
12. The device according to claim 11, in, The first determination unit is used to obtain multiple candidate collision positions of the collision object from the second estimated trajectory; for each candidate collision position among the multiple candidate collision positions, determine a candidate reference position of the candidate collision space according to the candidate collision position; and determine the candidate collision space under the candidate collision position according to the candidate reference position and spatial shape information of the candidate collision space.
13. The device according to claim 12, in, The first determination unit is used to determine a position offset distance according to a first object shape of the target object and a second object shape of the collision object, wherein the first object shape indicates a spatial area occupied by the target object and the second object shape indicates a spatial area occupied by the collision object; and to move the candidate collision position by the position offset distance according to a position offset direction to obtain the candidate reference position, wherein the position offset direction is a direction in which the candidate collision position points to a candidate object position corresponding to the candidate collision position.
14. The device according to claim 13, in, The first determination unit is used to, when the spatial shape information indicates that the candidate collision space is a half-space area, obtain a reference object position of the target object and a reference collision position of the collision object, wherein the reference object position is the candidate object position corresponding to the target object at a reference time, and the reference collision position is the candidate collision position corresponding to the collision object at the reference time; determine a reference space normal vector according to the reference object position and the reference collision position, wherein the position offset direction is the same as the direction of the reference space normal vector, and the direction of the reference space normal vector is the direction from the reference collision position to the reference object position; determine a normal plane indicating the candidate collision space according to the reference space normal vector and the candidate reference position corresponding to the reference collision position, wherein a first side bounded by the normal plane is a first half-space area that does not allow the target object to pass through, and a second side bounded by the normal plane is a second half-space area that allows the target object to pass through, and the second half-space area is a half-space area indicated by the reference space normal vector.
15. The device according to claim 11, in, The first determination unit is further used to obtain a first object shape of the target object and a second object shape of the collision object, wherein the first object shape indicates a spatial area occupied by the target object and the second object shape indicates a spatial area occupied by the collision object; determine the reference collision condition based on the first object shape and the second object shape, wherein the reference collision condition indicates a distance threshold at which the collision event occurs between the target object and the collision object; determine the spatial position relationship based on an interval distance between the first estimated trajectory and the second estimated trajectory, wherein the first estimated trajectory and the second estimated trajectory are line segment trajectories between a current image frame and a next image frame, respectively.
16. The device according to claim 15, in, When both the target object and the collision object are spheres, the sum of the first radius of the target object and the second radius of the collision object is determined as the distance threshold; the shortest distance between the first estimated trajectory and the second estimated trajectory is determined as the interval distance, wherein the first estimated trajectory is the moving trajectory of the first sphere center corresponding to the target object, and the second estimated trajectory is the moving trajectory of the second sphere center corresponding to the collision object.
17. The device according to claim 15, in, The target object is a sphere, and the collision object is a capsule, which is composed of two identical hemispheres and a cylinder, the two hemispheres are respectively spliced with the two bottom surfaces of the cylinder, and the radius of the hemisphere is the same as the bottom radius of the cylinder; the sum of the third radius of the target object and the fourth radius of the collision object is determined as the distance threshold, wherein the fourth radius is the radius of the hemisphere; the shortest distance between the first estimated trajectory and the second estimated trajectory is determined as the interval distance, wherein the first estimated trajectory is the moving trajectory of the third sphere center corresponding to the target object, and the second estimated trajectory is the moving trajectory of the reference point in the capsule, and the reference point is the point on the axis of the capsule that is closest to the third sphere center.
18. A computer-readable storage medium comprising a stored program, in, When the program is executed, the method according to any one of claims 1 to 10 is executed.
19. A computer program product, comprising a computer program / instructions, which when executed by a processor implement the steps of the method according to any one of claims 1 to 10.
20. An electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the method according to any one of claims 1 to 10 through the computer program.
Citation Information
Patent Citations
Data analysis method and device and readable storage medium
CN110019402A
Associated object identification method and device and computer readable storage medium
CN112818173A
Collision detection method and device, electronic equipment and storage medium
CN114225413A
Collision detection method and device in virtual environment, equipment, medium and program
CN115430153A
Image generation system, program and information storage medium
JP2007272267A
