Anti-collision detection method, device, equipment and storage medium during model loading
Through the anti-collision detection method during model loading, the collision of the three-dimensional model is judged by using the ray method and step size data, which solves the problem of high collision detection cost of three-dimensional models in the prior art and realizes efficient collision detection.
Patent Information
- Application Number
- CN202311790381.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-22
- Publication Date
- 2024-12-24
- Estimated Expiration
- 2043-12-22
AI Technical Summary
The existing three-dimensional model collision detection cost is high, mainly because it requires special plug-ins for detection, and the software version does not match the plug-in and needs to be compatible with the plug-in, which increases the development cost.
The anti-collision detection method during model loading is used to construct a collision model by obtaining the dimension information of the target person and obstacle body, and use the ray method to determine whether there is a collision model within the line of sight, and judge the collision based on step size data and distance value to reduce the calculation complexity and the number of selected models.
It reduces the cost and computational complexity of collision detection, improves detection efficiency, reduces the number of selected models, and provides more accurate collision detection results.
Smart Images

Figure CN117788701B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of three-dimensional model processing, and in particular to a method, device, equipment and storage medium for anti-collision detection during model loading. Background Art
[0002] With the rapid development of computer technology and Internet technology, the application of three-dimensional models has penetrated into various fields, such as architecture, gaming and virtual reality.
[0003] In the field of gaming and virtual reality, model collision detection is usually required to determine whether collision occurs between virtual objects.
[0004] At present, model collision detection requires the use of special plug-ins for detection. Model collision detection plug-ins may be developed for specific versions of software. If the software version does not match the plug-in, compatibility processing is required, which increases development costs and therefore leads to higher model collision detection costs. Summary of the invention
[0005] In order to reduce the cost of model collision detection, the present application provides a method, device, equipment and storage medium for anti-collision detection during model loading.
[0006] In the first aspect, the present application provides a method for anti-collision detection during model loading, which adopts the following technical solution:
[0007] A method for anti-collision detection during model loading, comprising:
[0008] Acquire first size information of a target person, and construct a first collision model of the target person based on the first size information; acquire second size information of an obstacle in a target scene, and construct a second collision model of the obstacle based on the second size information;
[0009] In response to a current movement operation instruction of the user on the target person, obtaining a direction in which the target person is to move;
[0010] Determining whether there is the second collision model within the line of sight of the first collision model based on the direction to be moved; if there is the second collision model within the line of sight of the first collision model, calculating the distance value between the first collision model and the second collision model within the line of sight of the first collision model;
[0011] Based on the step length data of the target person and the distance value, determining whether there is a second collision model to be collided with the target person;
[0012] If there is a second collision model to be collided with the target person, then stop responding to the current movement operation instruction and wait for a new movement operation instruction.
[0013] By adopting the above technical solution, the number of selected second collision models can be reduced by judging whether there is a second collision model to be collided with the first collision model within the line of sight through the ray method; by determining whether the target person and the second collision model collide with each other through the step data and the distance value, the calculation complexity of the collision detection can be greatly reduced, the detection efficiency is improved, and compared with the method of using a dedicated plug-in for collision detection, the cost of collision detection is greatly saved.
[0014] Optionally, judging whether there is the second collision model within the sight range of the first collision model based on the direction to be moved includes:
[0015] Determining an exit surface of the first collision model based on the direction to be moved;
[0016] Taking each first pixel point in the exit surface as a ray endpoint, generating horizontal rays based on the ray endpoints, wherein the direction of the ray is the same as the direction to be moved;
[0017] If any of the rays intersects with the second collision model, it is determined that there is the second collision model within the line of sight of the first collision model.
[0018] By adopting the above technical solution, the exit surface of the first collision model is determined based on the direction to be moved, and rays with the same direction to be moved are generated. It is possible to more accurately judge whether there is a collision risk within the line of sight, and only select the second collision model within the line of sight. This can reduce the number of selected second collision models, reduce the amount of calculation, and improve the efficiency of collision detection.
[0019] Optionally, calculating the distance value between the first collision model and the second collision model located within the line of sight of the first collision model includes:
[0020] Extracting all rays intersecting with the second collision model, and using the extracted rays as rays to be processed;
[0021] Calculate the length value of each ray to be processed;
[0022] The minimum length value is selected as the distance value.
[0023] By adopting the above technical solution, by extracting all rays intersecting with the second collision model and using these rays as rays to be processed, the number of rays that need to be processed can be greatly reduced; by calculating the distance value to determine the distance between the first collision model and the second collision model, a more accurate collision detection result can be provided.
[0024] Optionally, calculating the length value of each ray to be processed includes:
[0025] Obtaining an intersection point between the ray to be processed and the second collision model;
[0026] The ray endpoints and intersection points corresponding to the ray to be processed are combined into a calculation group;
[0027] Obtain the first pixel three-dimensional coordinate point of the ray endpoint and the second pixel three-dimensional coordinate point corresponding to the intersection point in each of the calculation groups; calculate the length value based on the first pixel three-dimensional coordinate point, the second pixel three-dimensional coordinate point and a distance calculation formula.
[0028] By adopting the above technical solution, by obtaining the intersection of the ray to be processed and the second collision model, and forming a calculation group with the ray endpoints and intersection points corresponding to the ray to be processed, the length value of the ray can be calculated more accurately, and by forming a calculation group with the ray endpoints and intersection points, repeated calculation of the same length value can be avoided.
[0029] Optionally, after the stopping of responding to the current moving operation instruction, the method further includes:
[0030] Extracting ray endpoints of all the rays to be processed;
[0031] Determining a maximum vertical height based on the extracted ray endpoints;
[0032] The moving operation prompt information is generated based on the maximum vertical height.
[0033] By adopting the above technical solution and generating mobile operation prompt information, the user can be more clearly prompted with the next operation, thus avoiding the trouble caused by unclear operation.
[0034] Optionally, judging whether there is a second collision model to be collided with the target person based on the step length data of the target person and the distance value includes:
[0035] When the step length data is greater than the distance value, it is determined that there is a second collision model to be collided with the target person.
[0036] Optionally, before determining whether there is a second collision model to be collided with the target person, the method further includes:
[0037] Determining whether the second collision model is a moving object;
[0038] If it is not a moving object, executing the step of determining whether there is a second collision model to be collided with the target person;
[0039] If it is a moving object, determining whether the moving object has a motion trend;
[0040] If there is a movement trend, determining the moving direction of the moving body;
[0041] When the moving direction of the moving object is opposite to the moving direction of the target person, the sum of the step length data of the target person and the step length data of the moving object is calculated, and the sum of the step length data is used as the preset distance;
[0042] Determining whether the distance value is less than the preset distance;
[0043] If it is less than the preset distance, it is determined that there is a second collision model to be collided with the target person.
[0044] By adopting the above technical solution, when the second collision model is a moving body, it is determined whether the moving body has a movement trend. If there is a movement trend, the moving direction of the moving body is determined. In this way, the movement state of the moving body can be predicted more accurately, and a collision judgment can be made in advance, thereby reducing the possibility of a collision between the first collision model and the second collision model.
[0045] In a second aspect, the present application provides a model loading anti-collision detection device, which adopts the following technical solution:
[0046] A model loading anti-collision detection device, comprising:
[0047] A first acquisition module, used to acquire first size information of a target person, and construct a first collision model of the target person based on the first size information;
[0048] A second acquisition module, used to acquire second size information of an obstacle in the target scene, and construct a second collision model of the obstacle based on the second size information;
[0049] A response module, used for obtaining a direction in which the target person is to move in response to a current movement operation instruction of the user to the target person;
[0050] A first judgment module is used to judge whether there is the second collision model located within the line of sight of the first collision model based on the direction to be moved; if there is the second collision model located within the line of sight of the first collision model, calculate the distance value between the first collision model and the second collision model located within the line of sight of the first collision model;
[0051] The second judgment module is used to judge whether there is a second collision model to be collided with the target person based on the step data of the target person and the distance value; if there is a second collision model to be collided with the target person, stop responding to the current movement operation instruction and wait for a new movement operation instruction.
[0052] By adopting the above technical solution, the number of selected second collision models can be reduced by judging whether there is a second collision model to be collided with the first collision model within the line of sight through the ray method; by determining whether the target person and the second collision model collide with each other through the step data and the distance value, the calculation complexity of the collision detection can be greatly reduced, the detection efficiency is improved, and compared with the method of using a dedicated plug-in for collision detection, the cost of collision detection is greatly saved.
[0053] In a third aspect, the present application provides an electronic device, which adopts the following technical solution:
[0054] An electronic device comprises a processor and a memory, wherein the processor is coupled to the memory;
[0055] The processor is used to execute the computer program stored in the memory so that the electronic device performs the method as described in any one of the first aspects.
[0056] In a fourth aspect, the present application provides a computer-readable storage medium, which adopts the following technical solution:
[0057] A computer-readable storage medium comprises a computer program or an instruction, and when the computer program or the instruction is executed on a computer, the computer is caused to execute the method as described in any one of the first aspects.
[0058] In summary, the present application includes at least one of the following beneficial technical effects: BRIEF DESCRIPTION OF THE DRAWINGS
[0059] Figure 1 It is a flow chart of an anti-collision detection method in model loading in an embodiment of the present application.
[0060] Figure 2 It is a structural block diagram of an anti-collision detection device during model loading in an embodiment of the present application.
[0061] Figure 3 It is a structural block diagram of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION
[0062] The present application is further described in detail below in conjunction with the accompanying drawings.
[0063] This specific embodiment is merely an explanation of the present application and is not a limitation of the present application. After reading this specification, those skilled in the art may make modifications to the present embodiment without any creative contribution as needed, but such modifications are protected by the patent law as long as they are within the scope of the claims of the present application.
[0064] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0065] In addition, the term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article, unless otherwise specified, generally means that the associated objects before and after are in an "or" relationship.
[0066] The embodiments of the present application are further described in detail below in conjunction with the drawings in the specification.
[0067] The embodiment of the present application provides a method for anti-collision detection during model loading, which can be executed by an electronic device, which can be a server or a terminal device, wherein the server can be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. The terminal device can be a smart phone, a tablet computer, a desktop computer, etc., but is not limited thereto.
[0068] like Figure 1 As shown, a method for anti-collision detection during model loading is described as follows (steps S101 to S108):
[0069] Step S101, obtaining first size information of a target person, and constructing a first collision model of the target person based on the first size information;
[0070] In this embodiment, the electronic device obtains first size information of the target person, wherein the first size information includes but is not limited to the height and width of the target person. The target person may be a virtual character in a game or a virtual character in virtual reality, and no specific limitation is made to this.
[0071] In this embodiment, the first collision model is a cylindrical capsule body. The electronic device generates a corresponding cylindrical capsule body according to the height and width of the target person, and uses the cylindrical capsule body to wrap the target person.
[0072] Step S102, obtaining second size information of an obstacle in the target scene, and constructing a second collision model of the obstacle based on the second size information;
[0073] In this embodiment, the obstacle can be a fixed object in the target scene, that is, a fixed body, or a moving object, that is, a mobile body. Other mobile bodies can be other target characters, which are not specifically limited in this embodiment. The target scene can be a game scene or a virtual reality scene. The second collision model corresponding to the fixed body is a rectangular parallelepiped, and the second collision model corresponding to the mobile body is a cylindrical capsule body. The height and width of the second collision model can be set according to the second size information of the obstacle; wherein the second size information includes but is not limited to the height and width of the obstacle.
[0074] Step S103, in response to the user's current movement operation instruction for the target person, obtaining the target person's moving direction;
[0075] In this embodiment, when the target scene is a game scene and the user operates the target character, the user needs to input the current movement operation instruction through the mouse, keyboard, touch screen, etc. of the electronic device; when the target scene is a virtual reality scene, the user can use devices such as a head-mounted display and a handle to realize the current movement operation of the target character, and electronically obtain the current movement operation instruction of the target character, wherein the current movement operation instruction includes but is not limited to the direction to be moved, and the stride data of the target character is preset in the electronic device, and the stride data is the distance traveled by the target character in one step.
[0076] Step S104, judging whether there is a second collision model within the sight range of the first collision model based on the direction to be moved, if so, executing step S105, otherwise executing step S108;
[0077] When the electronic device obtains a moving operation instruction, it is necessary to determine whether the target person collides with an obstacle when the electronic device executes the moving operation instruction.
[0078] Specifically, the exit surface of the first collision model is determined based on the direction to be moved; each first pixel point in the exit surface is used as a ray endpoint, and horizontal rays are generated based on the ray endpoints, wherein the direction of the ray is the same as the direction to be moved; if any ray intersects with the second collision model, it is determined that there is a second collision model within the line of sight of the first collision model.
[0079] In this embodiment, the electronic device obtains the surface of the first collision model on the side of the direction to be moved, wherein the surface is the side of the cylindrical capsule body, and the cross-section corresponding to the side is a semicircle. The electronic device uses the obtained side as the exit surface, and each pixel point in the exit surface as a ray endpoint, and a horizontal ray is sent by the ray endpoint, and each ray is the same as the direction to be moved, wherein the second collision model located within the line of sight of the first collision model is the second collision model located in the moving direction of the first collision model.
[0080] Step S105, calculating a distance value between the first collision model and a second collision model located within the sight range of the first collision model;
[0081] Specifically, all rays intersecting with the second collision model are extracted, and the extracted rays are used as rays to be processed; the length value of each ray to be processed is calculated; and the minimum length value is selected as the distance value.
[0082] The calculation of the length of each ray to be processed specifically includes:
[0083] Obtain the intersection of the ray to be processed and the second collision model; group the ray endpoints and intersection points corresponding to the ray to be processed into a calculation group; obtain the first pixel three-dimensional coordinate point of the ray endpoint in each calculation group and the second pixel three-dimensional coordinate point corresponding to the intersection point; calculate the length value based on the first pixel three-dimensional coordinate point, the second pixel three-dimensional coordinate point and the distance calculation formula.
[0084] In this embodiment, the electronic device establishes a three-dimensional coordinate system of the target scene in advance. Therefore, when the first collision model is located in the target scene, the three-dimensional coordinate point of the first pixel corresponding to the pixel point in the first collision model can be obtained, that is, the three-dimensional coordinate point of the first pixel corresponding to the transmitting endpoint can be obtained.
[0085] When there is a second collision model within the line of sight of the first collision model, all rays intersecting with the second collision model are obtained, and the rays are used as the rays to be processed. The points where the rays to be processed intersect with the second model are called intersection points. The electronic device obtains the second pixel three-dimensional coordinate points corresponding to the intersection points in each ray to be processed. After obtaining the first pixel three-dimensional coordinate points corresponding to the emission endpoints in the ray to be processed and the second pixel three-dimensional coordinate points corresponding to the intersection points, the electronic device combines the first pixel three-dimensional coordinate points and the second pixel three-dimensional coordinate points of the ray to be processed into a calculation group.
[0086] By formula The length value of each ray to be processed is calculated, wherein the three-dimensional coordinate point of the first pixel is (x1, y1, z1) and the three-dimensional coordinate point of the second pixel is (x2, y2, z2).
[0087] Step S106, based on the step length data and the distance value of the target person, determine whether there is a second collision model to be collided with the target person, if yes, execute step S107, otherwise execute step S108;
[0088] Specifically, when the step length data is greater than the distance value, it is determined that there is a second collision model to be collided with the target person.
[0089] In this embodiment, when the step length data is greater than the distance value, it proves that the target person will collide with the second collision model when moving according to the current operation instruction. Therefore, when the step length data is greater than the distance value, it is determined that there is a second collision model to be collided with the target person.
[0090] Before determining whether there is a second collision model to be collided with the target person, the following contents are also included:
[0091] Specifically, determine whether the second collision model is a mobile body; if not, execute the step of determining whether there is a second collision model to be collided with the target person; if it is a mobile body, obtain and determine whether the mobile body has a motion trend; if there is a motion trend, determine the moving direction of the mobile body; when the moving direction of the mobile body is relative to the moving direction of the target person, calculate the sum of the step data of the target person and the step data of the mobile body, and use the sum of the step data as a preset distance; determine whether the distance value is less than the preset distance; if it is less than the preset distance, determine that there is a second collision model to be collided with the target person.
[0092] In this embodiment, the obstacle includes a moving body and a fixed body, wherein the preset distance between the fixed body and the target person is the step data of the target person, and the preset distance between the moving body and the target person is the sum of the step data of the moving body and the step data of the target person.
[0093] In this embodiment, when the electronic device obtains the current moving operation instruction for the target person, it obtains the obstacles within the target person's line of sight to query whether there is a moving object in the obstacles, wherein the electronic device sets corresponding marks for the moving object and the fixed object, and the marks include but are not limited to symbol marks, digital marks, etc., wherein the number of the fixed body can be an odd number, and the number of the moving body can be an even number, and there is no specific limitation on this.
[0094] When there is a moving object within the sight range of the target person, the electronic device obtains the historical operation data or preset operation data of the moving object. For NPC characters, the preset operation data can be obtained, and for other target persons, the historical operation data is obtained, where the historical operation data can be the movement operation instructions for other target persons, and can also be the movement operation instructions of the previous step. In this embodiment, the movement trend of the moving object is the same as the movement operation instructions of the previous step.
[0095] When there is a moving object within the target person's line of sight, determine whether the distance value is less than the preset distance. When the distance value is less than the sum of the moving object's step data and the target person's step data, determine that the target person will collide with the moving object; when there is no moving object around the target person and the distance value is less than the target person's step data, determine that the target person will collide with a fixed object.
[0096] Step S107, stop responding to the current moving operation instruction and wait for a new moving operation instruction;
[0097] In this embodiment, when there is a second collision model to be collided with the target person, the current movement operation instruction will not be responded to. At this time, the user will be fed back that the current movement operation instruction cannot be executed, and movement operation prompt information will be generated for the user's reference.
[0098] The generating of the moving operation prompt information specifically includes: extracting the ray endpoints of all the rays to be processed; determining the maximum vertical height based on the extracted ray endpoints; and generating the moving operation prompt information based on the maximum vertical height.
[0099] In this embodiment, the maximum vertical height of the second collision model can be determined by the ray endpoint of the ray to be processed. When the maximum vertical height is less than the preset height, the target person can be allowed to jump, and the target person can be determined to walk forward, backward, left and right based on other obstacles around. The prompt information includes but is not limited to forward, backward, left, right and jumping.
[0100] The maximum vertical height of the second collision model can be determined by the ray endpoint of the ray to be processed by using the binary method. For example, the length value of the ray to be processed corresponding to the first pixel three-dimensional coordinate point corresponding to the height of half the target person's height is selected. When the length value is greater than the preset distance, the length value of the ray to be processed corresponding to the first pixel three-dimensional coordinate point corresponding to the middle value of the height of half the target person and the target person's height is selected; when the ray length is not greater than the preset distance, the middle value between the height of half the target person and the height of 0 is selected, corresponding to the length value of the ray to be processed corresponding to the first pixel three-dimensional coordinate point, until the height of the obstacle is determined.
[0101] Step S108, responding to the current moving operation instruction.
[0102] In this embodiment, when there is a moving object within the sight range of the target person, it is determined whether the distance value is less than the preset distance. When the distance value is greater than the sum of the stride data of the moving object and the stride data of the target person, it is determined that the target person will not collide with the moving object, and the moving operation instruction is executed at this time; when there is no moving object within the sight range of the target person and the distance value is greater than the stride data of the target person, it is determined whether the target person will collide with the fixed object, and the current moving operation instruction is executed at this time.
[0103] Figure 2 This is a structural block diagram of a model loading anti-collision detection device 200 provided in this application. Figure 2 As shown, a model loading anti-collision detection device 200, the model loading anti-collision detection device 200 includes:
[0104] A first acquisition module 201 is used to acquire first size information of a target person and construct a first collision model of the target person based on the first size information;
[0105] A second acquisition module 202 is used to acquire second size information of an obstacle in the target scene, and construct a second collision model of the obstacle based on the second size information;
[0106] A response module 203 is used to obtain the target person's moving direction in response to the user's current moving operation instruction for the target person;
[0107] A first judgment module 204 is used to judge whether there is a second collision model located within the sight range of the first collision model based on the direction to be moved; if there is a second collision model located within the sight range of the first collision model, calculate the distance value between the first collision model and the second collision model located within the sight range of the first collision model;
[0108] The second judgment module 205 is used to judge whether there is a second collision model to be collided with the target person based on the step data and distance value of the target person; if there is a second collision model to be collided with the target person, stop responding to the current movement operation instruction and wait for a new movement operation instruction.
[0109] As an optional implementation in this embodiment, the first determination module 204 includes:
[0110] An exit surface acquisition submodule, used to determine the exit surface of the first collision model based on the direction to be moved;
[0111] As a generating submodule, it is used to take each first pixel point in the exit surface as a ray endpoint, and generate horizontal rays based on the ray endpoints, wherein the direction of the ray is the same as the direction to be moved;
[0112] The model determination submodule is used to determine whether there is a second collision model within the sight range of the first collision model if any ray intersects with the second collision model.
[0113] As an optional implementation manner in this embodiment, the first determination module 204 further includes:
[0114] A ray extraction submodule is used to extract all rays intersecting with the second collision model and use the extracted rays as rays to be processed; a length value calculation submodule is used to calculate the length value of each ray to be processed;
[0115] The length value selection submodule is used to select the minimum length value as the distance value.
[0116] In this optional embodiment, the length value calculation submodule is specifically used to:
[0117] Obtain the intersection of the ray to be processed and the second collision model; group the ray endpoints and intersection points corresponding to the ray to be processed into a calculation group; obtain the first pixel three-dimensional coordinate point of the ray endpoint in each calculation group and the second pixel three-dimensional coordinate point corresponding to the intersection point; calculate the length value based on the first pixel three-dimensional coordinate point, the second pixel three-dimensional coordinate point and the distance calculation formula.
[0118] As an optional implementation of this embodiment, the anti-collision detection device 200 during model loading further includes:
[0119] An endpoint extraction module, used for extracting the ray endpoints of all rays to be processed after stopping responding to the current movement operation instruction; a height determination module, used for determining the maximum vertical height based on the extracted ray endpoints;
[0120] The information generation module is used to generate movement operation prompt information based on the maximum vertical height.
[0121] As an optional implementation of this embodiment, the second determination module 205 is specifically configured to:
[0122] When the step length data is greater than the distance value, it is determined that there is a second collision model to be collided with the target person.
[0123] As an optional implementation of this embodiment, the anti-collision detection device 200 during model loading further includes:
[0124] The model judgment module is used to judge whether the second collision model is a moving body before judging whether there is a second collision model to be collided with the target person; if it is not a moving body, then the step of judging whether there is a second collision model to be collided with the target person is performed; if it is a moving body, then the step of judging whether there is a movement trend of the moving body is obtained; if there is a movement trend, then the moving direction of the moving body is determined;
[0125] The distance module is used to calculate the sum of the step length data of the target person and the step length data of the moving body when the moving direction of the moving body is opposite to the moving direction of the target person, and use the sum of the step length data as the preset distance;
[0126] The distance judgment module is used to judge whether the distance value is less than a preset distance; if it is less than the preset distance, it is determined that there is a second collision model to be collided with the target person.
[0127] The functional modules in the embodiments of the present application can be integrated together to form an independent part, or each module can exist separately, or two or more modules can be integrated to form an independent part. If the function is implemented in the form of a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable an electronic device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of a model loading anti-collision detection method in each embodiment of the present application.
[0128] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and modules described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0129] Figure 3 FIG. 1 is a structural block diagram of an electronic device 300 provided in an embodiment of the present application. Figure 3 As shown, the electronic device 300 includes a memory 301, a processor 302 and a communication bus 303; the memory 301 and the processor 302 are connected via the communication bus 303. The memory 301 stores a method for anti-collision detection in model loading provided in the above embodiment, which can be loaded and executed by the processor 302.
[0130] The memory 301 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 301 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function, and instructions for implementing a method for anti-collision detection in model loading provided in the above embodiment, etc.; the data storage area may store data involved in a method for anti-collision detection in model loading provided in the above embodiment, etc.
[0131] The processor 302 may include one or more processing cores. The processor 302 calls the data stored in the memory 301 by running or executing the instructions, programs, code sets or instruction sets stored in the memory 301, and performs various functions and processes data of the present application. The processor 302 may be at least one of an application-specific integrated circuit (ASIC), a digital signal processor (DSP), a digital signal processing device (DSPD), a programmable logic device (PLD), a field programmable gate array (FPGA), a central processing unit (CPU), a controller, a microcontroller and a microprocessor. It is understandable that for different devices, the electronic device used to implement the above-mentioned processor 302 function can also be other, and the embodiment of the present application is not specifically limited.
[0132] The communication bus 303 may include a path to transmit information between the above components. The communication bus 303 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The communication bus 303 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 Only one double arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0133] An embodiment of the present application provides a computer-readable storage medium storing a computer program that can be loaded by a processor and executes a method for anti-collision detection during model loading as provided in the above embodiment.
[0134] In this embodiment, the computer-readable storage medium may be a tangible device that holds and stores instructions used by the instruction execution device. The computer-readable storage medium may be, but is not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any combination thereof. Specifically, the computer-readable storage medium may be a portable computer disk, a hard disk, a USB flash drive, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a podium random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, an optical disk, a magnetic disk, a mechanical encoding device, and any combination thereof.
[0135] The terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion such that a process, method, article, or apparatus that includes a list of elements includes not only those elements but also other elements not expressly listed, or also includes elements inherent to such process, method, article, or apparatus.
[0136] The above description is only a preferred embodiment of the present application and an explanation of the technical principles used. Those skilled in the art should understand that the scope of application involved in the present application is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the aforementioned application concept. For example, the above features are replaced with (but not limited to) technical features with similar functions applied in the present application.
Claims
1. A method for anti-collision detection during model loading, characterized in that: include: Acquire first size information of a target person, and construct a first collision model of the target person based on the first size information; Acquire second size information of an obstacle in the target scene, and construct a second collision model of the obstacle based on the second size information; and acquire a direction in which the target person is to move in response to a current movement operation instruction of the user to the target person; Determining whether there is the second collision model within the line of sight of the first collision model based on the direction to be moved; if there is the second collision model within the line of sight of the first collision model, calculating the distance value between the first collision model and the second collision model within the line of sight of the first collision model; Based on the step data of the target person and the distance value, judging whether there is a second collision model to be collided with the target person, when the step data is greater than the distance value, judging that there is a second collision model to be collided with the target person; if there is a second collision model to be collided with the target person, stopping responding to the current movement operation instruction and waiting for a new movement operation instruction; The method of judging whether there is the second collision model within the sight range of the first collision model based on the direction to be moved includes: determining the exit surface of the first collision model based on the direction to be moved, obtaining the surface of the first collision model located on the side of the direction to be moved, wherein the surface is the side surface of the cylindrical capsule body, and the cross section corresponding to the side surface is a semicircle, and the obtained side surface is used as the exit surface; each first pixel point in the exit surface is used as a ray endpoint, and horizontal rays are generated based on the ray endpoints, wherein the direction of the ray is the same as the direction to be moved; if any of the rays intersects with the second collision model, it is determined that there is the second collision model within the sight range of the first collision model; The calculating of the distance value between the first collision model and the second collision model located within the line of sight of the first collision model comprises: extracting all rays intersecting with the second collision model, and using the extracted rays as rays to be processed; calculating the length value of each ray to be processed; and selecting the smallest length value as the distance value. After stopping responding to the current moving operation instruction, it also includes: extracting the ray endpoints of all the rays to be processed; determining the maximum vertical height based on the extracted ray endpoints, and using the dichotomy method to determine the maximum vertical height of the second collision model; generating moving operation prompt information based on the maximum vertical height.
2. The method according to claim 1, characterized in that The calculation of the length value of each ray to be processed includes: obtaining the intersection point of the ray to be processed and the second collision model; forming a calculation group with the ray endpoints and intersection points corresponding to the ray to be processed; obtaining the first pixel three-dimensional coordinate point of the ray endpoint in each calculation group and the second pixel three-dimensional coordinate point corresponding to the intersection point; and calculating the length value based on the first pixel three-dimensional coordinate point, the second pixel three-dimensional coordinate point and a distance calculation formula.
3. The method according to claim 2, characterized in that Before determining whether there is a second collision model to be collided with the target person, it also includes: determining whether the second collision model is a mobile body; if not, executing the step of determining whether there is a second collision model to be collided with the target person; if it is a mobile body, obtaining a determination as to whether the mobile body has a motion trend; if there is a motion trend, determining the moving direction of the mobile body; when the moving direction of the mobile body is relative to the moving direction of the target person, calculating the sum of the step data of the target person and the step data of the mobile body, and taking the sum of the step data as a preset distance; determining whether the distance value is less than the preset distance; if less than the preset distance, determining that there is a second collision model to be collided with the target person.
4. A model loading anti-collision detection device, characterized in that: include: A first acquisition module, used to acquire first size information of a target person, and construct a first collision model of the target person based on the first size information; A second acquisition module is used to acquire second size information of an obstacle in the target scene, and to construct a second collision model of the obstacle based on the second size information; a response module is used to acquire a direction in which the target person is to move in response to a current movement operation instruction of the user to the target person; A first judgment module is used to judge whether there is the second collision model located within the line of sight of the first collision model based on the direction to be moved; if there is the second collision model located within the line of sight of the first collision model, calculate the distance value between the first collision model and the second collision model located within the line of sight of the first collision model; A second judgment module is used to judge whether there is a second collision model to be collided with the target person based on the step data of the target person and the distance value, and when the step data is greater than the distance value, it is determined that there is a second collision model to be collided with the target person; if there is a second collision model to be collided with the target person, stop responding to the current movement operation instruction and wait for a new movement operation instruction; The method of judging whether there is the second collision model within the sight range of the first collision model based on the direction to be moved includes: determining the exit surface of the first collision model based on the direction to be moved, obtaining the surface of the first collision model located on the side of the direction to be moved, wherein the surface is the side surface of the cylindrical capsule body, and the cross section corresponding to the side surface is a semicircle, and the obtained side surface is used as the exit surface; each first pixel point in the exit surface is used as a ray endpoint, and horizontal rays are generated based on the ray endpoints, wherein the direction of the ray is the same as the direction to be moved; if any of the rays intersects with the second collision model, it is determined that there is the second collision model within the sight range of the first collision model; The calculating of the distance value between the first collision model and the second collision model located within the line of sight of the first collision model comprises: extracting all rays intersecting with the second collision model, and using the extracted rays as rays to be processed; calculating the length value of each ray to be processed; and selecting the smallest length value as the distance value. After stopping responding to the current moving operation instruction, it also includes: extracting the ray endpoints of all the rays to be processed; determining the maximum vertical height based on the extracted ray endpoints, and using the dichotomy method to determine the maximum vertical height of the second collision model; generating moving operation prompt information based on the maximum vertical height.
5. An electronic device, characterized in that: The electronic device comprises a processor and a memory, wherein the processor is coupled to the memory; the processor is used to execute a computer program stored in the memory, so that the electronic device executes the method according to any one of claims 1 to 3.
6. A computer-readable storage medium, characterized in that: The method comprises a computer program or an instruction, which, when executed on a computer, causes the computer to execute the method according to any one of claims 1 to 3.
