Method, device, electronic device, storage medium and program product for simulating virtual objects
Patent Information
- Application Number
- CN202510472381.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-15
- Publication Date
- 2026-10-23
AI Technical Summary
[0002]物理模拟是一种通过计算机程序在虚拟场景中模拟真实世界中物理现象的技术,然而,物理模拟需要大量的计算资源,尤其是进行实时物理模拟时,虚拟场景中的物理模型是物理模拟的基础,虚拟场景的物理模型精度越高,加载的物理模型的数量越多,会显著增加计算资源的消耗,计算复杂性也越高,降低了物理模拟的效率
[0022]基于第一虚拟对象的运动信息,确定第一虚拟对象在虚拟场景中的可运动距离,如此,限制了第一虚拟对象的活动范围,避免第一虚拟对象超出虚拟场景的边界,基于可运动距离,确定第一虚拟对象在虚拟场景的可运动范围,如此,提高了确定第一虚拟对象的可运动范围的准确性,加载虚拟场景中可运动范围内的第二虚拟对象,并基于加载后的第二虚拟对象,对第一虚拟对象的运动过程进行物理模拟,如此,只需加载可运动范围中的虚拟对象进行物理模拟,无需加载虚拟场景中全部的虚拟对象,从而减少了资源浪费,提高了物理模拟的效率。
Smart Images

Figure CN122955200A_ABST
Abstract
Description
Technical Field
[0001] This application relates to computer technology, and more particularly to a method, apparatus, electronic device, storage medium, and program product for simulating virtual objects. Background Technology
[0002] Physics simulation is a technique that uses computer programs to simulate physical phenomena in the real world in a virtual scene. However, physics simulation requires a lot of computing resources, especially when performing real-time physics simulation. The physical model in the virtual scene is the foundation of physics simulation. The higher the accuracy of the physical model in the virtual scene and the more physical models are loaded, the more computing resources are consumed, the higher the computational complexity is, and the lower the efficiency of physics simulation. Summary of the Invention
[0003] This application provides a method, apparatus, electronic device, storage medium, and program product for simulating virtual objects, which can improve the efficiency of physical simulation of virtual objects.
[0004] The technical solution of this application embodiment is implemented as follows:
[0005] This application provides a method for simulating a virtual object, the method comprising:
[0006] Retrieve the first virtual object in the virtual scene;
[0007] Based on the motion information of the first virtual object, the movable distance of the first virtual object is determined;
[0008] Based on the movable distance, the movable range of the first virtual object in the virtual scene is determined;
[0009] Load the second virtual object within the movable range of the virtual scene;
[0010] Based on the loaded second virtual object, a physical simulation is performed on the motion process of the first virtual object.
[0011] This application provides a virtual object simulation device, including:
[0012] The data acquisition module is used to acquire the first virtual object in the virtual scene;
[0013] The range determination module is used to determine the movable distance of the first virtual object based on the motion information of the first virtual object; and to determine the movable range of the first virtual object in the virtual scene based on the movable distance.
[0014] An object loading module is used to load a second virtual object within the movable range of the virtual scene.
[0015] The physics simulation module is used to perform physical simulation of the motion process of the first virtual object based on the loaded second virtual object.
[0016] This application provides an electronic device, including:
[0017] Memory is used to store executable instructions for a computer;
[0018] The processor, when executing computer-executable instructions stored in the memory, implements the virtual object simulation method provided in the embodiments of this application.
[0019] This application provides a computer-readable storage medium storing a computer program or computer-executable instructions for implementing the virtual object simulation method provided in this application when executed by a processor.
[0020] This application provides a computer program product, including a computer program or computer executable instructions. When the computer program or computer executable instructions are executed by a processor, they implement the virtual object simulation method provided in this application.
[0021] The embodiments of this application have the following beneficial effects:
[0022] Based on the motion information of the first virtual object, the movable distance of the first virtual object in the virtual scene is determined. This limits the activity range of the first virtual object and prevents it from exceeding the boundary of the virtual scene. Based on the movable distance, the movable range of the first virtual object in the virtual scene is determined, thus improving the accuracy of determining the movable range of the first virtual object. A second virtual object within the movable range of the virtual scene is loaded, and the motion process of the first virtual object is physically simulated based on the loaded second virtual object. In this way, only virtual objects within the movable range need to be loaded for physical simulation, without loading all virtual objects in the virtual scene, thereby reducing resource waste and improving the efficiency of physical simulation. Attached Figure Description
[0023] Figure 1 This is a schematic diagram of the architecture of the virtual object simulation system provided in the embodiments of this application;
[0024] Figure 2 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application;
[0025] Figure 3A This is a first flowchart illustrating the virtual object simulation method provided in this application embodiment;
[0026] Figure 3BThis is a second flowchart illustrating the virtual object simulation method provided in the embodiments of this application;
[0027] Figure 3C This is a third flowchart illustrating the virtual object simulation method provided in the embodiments of this application;
[0028] Figure 3D This is a schematic diagram of the fourth process of the virtual object simulation method provided in the embodiments of this application;
[0029] Figure 4 This is a schematic diagram of a regular shape structure provided in an embodiment of this application;
[0030] Figure 5 This is a schematic diagram of the motion trajectory construction provided in the embodiments of this application;
[0031] Figure 6 This is a schematic diagram of the area provided in the embodiments of this application;
[0032] Figure 7 This is a schematic diagram of regional displacement provided in an embodiment of this application;
[0033] Figure 8 This is a schematic diagram of the first prediction range provided in the embodiments of this application;
[0034] Figure 9 This is a schematic diagram of the second prediction range provided in the embodiments of this application;
[0035] Figure 10 This is a flowchart of the physical simulation provided in the embodiments of this application;
[0036] Figure 11 This is a schematic diagram of region conversion provided in an embodiment of this application;
[0037] Figure 12 This is a schematic diagram of area determination provided in an embodiment of this application;
[0038] Figure 13 This is a schematic diagram of the reachable area of the role provided in the embodiments of this application.
[0039] It should be noted that the terms "first" and "second" mentioned above are only used to distinguish between different options and do not represent the degree of superiority or inferiority of the options or their priority in the implementation process. Detailed Implementation
[0040] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. The described embodiments should not be regarded as limitations on this application. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0041] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0042] In the following description, the terms "first, second, third" are used merely to distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first, second, third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.
[0043] In this application embodiment, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.
[0044] In the implementation of this application, the collection and processing of relevant data should strictly comply with the requirements of relevant national laws and regulations, obtain the informed consent or separate consent of the personal information subject, and carry out subsequent data use and processing within the scope of laws and regulations and the authorization of the personal information subject.
[0045] Unless otherwise defined, all technical and scientific terms used in the embodiments of this application have the same meaning as commonly understood by one of ordinary skill in the art. The terminology used in the embodiments of this application is for the purpose of describing the embodiments of this application only and is not intended to limit this application.
[0046] Before providing a further detailed description of the embodiments of this application, the nouns and terms involved in the embodiments of this application will be explained, and the nouns and terms involved in the embodiments of this application shall be interpreted as follows.
[0047] 1) A virtual scene is a virtual game scene displayed (or provided) by a game program when it runs on a terminal. This virtual scene can be a simulation of the real world, a semi-simulated / semi-fictional virtual environment, or a purely fictional virtual environment. A virtual scene can be any of a two-dimensional, 2.5-dimensional, or three-dimensional virtual scene; this application does not limit the dimension of the virtual scene. For example, a virtual scene may include the sky, land, ocean, etc., and the land may include environmental elements such as deserts and cities. Users can control virtual objects to move within this virtual scene.
[0048] 2) Virtual Objects: These are interactive images of people and objects within a virtual scene, or movable objects within the virtual scene. These movable objects can be virtual characters, virtual animals, anime characters, etc., such as people or animals displayed in a virtual scene. A virtual object can be a virtual character representing the user within the virtual scene. A virtual scene can include multiple virtual objects, each with its own shape and volume, occupying a portion of the space within the virtual scene.
[0049] In related technologies, physics simulation is one of the core functions in game development. It is used to detect physical interactions between game objects (such as collisions, overlaps, and trigger events), character movement, collision detection, and other related game logic operations. The prerequisite for physics simulation is to preload the physical models of game objects. However, in large-scale games, due to the large map area, numerous game objects, and higher precision of game models, the precision of physical models is also very high. When there is a lot of data, the loading and calculation of physical models become a significant performance bottleneck, thereby reducing the efficiency of physics simulation. To address the above problems, this application provides a method, apparatus, electronic device, computer-readable storage medium, and computer program product for simulating virtual objects, thereby improving the efficiency of physics simulation of virtual objects.
[0050] The virtual object simulation method described in this application embodiment can be applied to various fields, such as the gaming field. That is, the virtual object simulation method in this application embodiment is not limited to a certain field.
[0051] The following describes exemplary applications of the electronic device provided in the embodiments of this application. The device provided in the embodiments of this application can be implemented as a terminal or as a server. The following will describe exemplary applications when the device is implemented as a server.
[0052] See Figure 1 , Figure 1 This is a schematic diagram of the architecture of the virtual object simulation system 100 provided in the embodiments of this application. In order to realize the simulation application supporting a virtual object, the terminal (terminal 400 is shown as an example) connects to the server 200 through the network 300. The network 300 can be a wide area network or a local area network, or a combination of the two.
[0053] Terminal 400 sends a first virtual object in the virtual scene to server 200 via network 300. Server 200 determines the movable distance of the first virtual object based on its motion information; determines the movable range of the first virtual object within the virtual scene based on its movable distance; loads a second virtual object within the movable range of the virtual scene; and performs a physical simulation of the motion process of the first virtual object based on the loaded second virtual object. The simulated motion process of the first virtual object is then returned to terminal 400, which displays the simulated motion process of the first virtual object through a graphical interface 410.
[0054] The following is an example of how terminal 400 simulates virtual objects.
[0055] In some embodiments, the terminal 400 can independently complete the simulation task of the virtual object. For example, the terminal 400 is used to acquire a first virtual object in a virtual scene; determine the movable distance of the first virtual object based on the motion information of the first virtual object; determine the movable range of the first virtual object in the virtual scene based on the movable distance; load a second virtual object within the movable range in the virtual scene; and perform physical simulation of the motion process of the first virtual object based on the loaded second virtual object, and display the simulated motion process of the first virtual object through the graphical interface 410.
[0056] In one implementation scenario, a server or terminal can simulate the movement of a character in a game, acquire the character's information, determine the character's movable distance based on the character's movement information, determine the character's movable range within the game based on the movable distance, load buildings within the movable range of the game, and perform physical simulation of the character's movement based on the loaded buildings.
[0057] In some embodiments, server 200 may be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms.
[0058] Terminal 400 can be a smartphone, tablet computer, laptop computer, desktop computer, smart speaker, smartwatch, smart voice interaction device, smart home appliance, vehicle terminal, aircraft, etc., but is not limited to these. The terminal and server can be directly or indirectly connected via wired or wireless communication, which is not limited in this embodiment.
[0059] See Figure 2, Figure 2 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Figure 2 The electronic device 500 shown can be Figure 1 The terminal 400 or server 200, and the electronic device 500 include: at least one processor 510, memory 550, and at least one network interface 520. The various components in server 200 are coupled together via a bus system 540. It is understood that the bus system 540 is used to implement communication between these components. In addition to a data bus, the bus system 540 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in... Figure 2 The general labeled all buses as Bus System 540.
[0060] The processor 510 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor, etc.
[0061] User interface 530 includes one or more output devices 531 that enable the presentation of media content, including one or more speakers and / or one or more visual displays. User interface 530 also includes one or more input devices 532, including user interface components that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, other input buttons and controls;
[0062] In some embodiments, when the simulation task of the virtual object is completed independently by the terminal 400, the server 200 provided in this application embodiment does not include the user interface 530.
[0063] The memory 550 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state storage, hard disk drives, optical disk drives, etc. The memory 550 may optionally include one or more storage devices physically located away from the processor 510.
[0064] The memory 550 may include volatile memory or non-volatile memory, or both. The non-volatile memory may be read-only memory (ROM), and the volatile memory may be random access memory (RAM). The memory 550 described in this application embodiment is intended to include any suitable type of memory.
[0065] In some embodiments, memory 550 is capable of storing data to support various operations, examples of which include programs, modules, and data structures or subsets or supersets thereof, as illustrated below.
[0066] Operating system 551 includes system programs for handling various basic system services and performing hardware-related tasks, such as the framework layer, core library layer, driver layer, etc., for implementing various basic business functions and handling hardware-based tasks;
[0067] The network communication module 552 is used to reach other computing devices via one or more (wired or wireless) network interfaces 520, exemplary network interfaces 520 including: Bluetooth, WiFi, and Universal Serial Bus (USB), etc.
[0068] Presentation module 553 is configured to enable the presentation of information (e.g., a user interface for operating peripheral devices and displaying content and information) via one or more output devices 531 (e.g., a display screen, a speaker, etc.) associated with user interface 530;
[0069] In some embodiments, when the simulation task of the virtual object is completed independently by the terminal 400, the server 200 provided in this application embodiment may not include the presentation module 553.
[0070] The input processing module 554 is used to detect and translate one or more user inputs or interactions from one or more input devices 532; in some embodiments, when the embodiment is completed independently by the terminal 400 to simulate the virtual object, the server 200 provided in this application embodiment may not include the presentation module 553.
[0071] In some embodiments, the apparatus provided in this application can be implemented in software. Figure 2 A simulation device 555 storing virtual objects in memory 550 is shown. This device can be software in the form of programs and plug-ins, and includes the following software modules: a data acquisition module 5551, a range determination module 5552, an object loading module 5553, and a physical simulation module 5554. These modules are logically connected and can therefore be arbitrarily combined or further separated according to the functions they implement. The functions of each module will be described below.
[0072] It should be noted that, in the examples of virtual object simulation below, those skilled in the art, based on their understanding of the following text, can apply the virtual object simulation method provided in the embodiments of this application to simulate the motion process of virtual objects.
[0073] See Figure 3A , Figure 3A This is a first flowchart illustrating the virtual object simulation method provided in this application embodiment, which will be combined with... Figure 3A The steps shown will be explained below. The virtual object simulation method provided in this application embodiment can be implemented by the server or the terminal alone, or by the server and the terminal working together. The following will be explained using the implementation by the server and the terminal working together as an example.
[0074] In step 101, the first virtual object in the virtual scene is obtained.
[0075] Here, the virtual scene in step 101 is a virtual scene that is not fully loaded. The virtual scene in step 101 has a first virtual object that can be moved and interacted with preloaded, but the second virtual object is not loaded. The second virtual object can be a virtual object that can be moved or a fixed virtual object. The second virtual object is different from the first virtual object.
[0076] In step 102, the movable distance of the first virtual object is determined based on the motion information of the first virtual object.
[0077] Here, motion information describes the motion of the first virtual object in the virtual scene. This application embodiment does not limit the motion information of the first virtual object. The motion information can be the motion speed, motion speed direction, motion acceleration, and motion acceleration direction of the first virtual object. Motion speed refers to the distance the first virtual object moves per unit time, describing the speed of the first virtual object's movement. This embodiment does not limit the motion speed of the first virtual object; it can be a specific speed value expressed numerically or a set speed range. Motion speed direction is the direction in which the first virtual object moves, used to determine the path of the first virtual object in the virtual scene. This embodiment does not limit the motion speed direction; it can be a basic direction such as north, south, east, or west, or a precise direction value determined based on a specific coordinate system. Motion acceleration is a physical quantity describing how quickly the motion speed of the first virtual object changes, reflecting the rate of increase or decrease in motion speed. This embodiment does not limit the motion acceleration of the first virtual object; it can be positive, negative, or zero, where a positive value indicates accelerated motion, a negative value indicates decelerated motion, and zero indicates uniform motion. Motion acceleration direction refers to the direction of the acceleration vector, used to indicate the direction of the speed change of the first virtual object during movement. The movable distance is the maximum distance range that the object can move within a certain time, determined based on the motion information of the first virtual object.
[0078] In some embodiments, motion information includes the velocity and acceleration of the first virtual object during motion, see [reference]. Figure 3B , Figure 3B This is a second flowchart illustrating the virtual object simulation method provided in this application embodiment, specifically for... Figure 3A Step 102 shown can be achieved through... Figure 3B Steps 1021A to 1023A are implemented, and will be explained in detail below.
[0079] In step 1021A, the motion duration of the first virtual object is obtained, and a preset distance threshold for the first virtual object is obtained.
[0080] Among them, the distance threshold is greater than or equal to the distance from the center point of the first virtual object to the edge of the first virtual object.
[0081] Here, motion duration refers to the length of time the first virtual object is in motion information. Distance threshold is a preset distance value for each first virtual object; each first virtual object corresponds to its own distance threshold, which is equal to the distance from the center point of the first virtual object to its edge. The center point is a specific point of the first virtual object in the virtual scene. This embodiment does not limit the center point; it can be the geometric center, centroid, etc., of the first virtual object. The edge is the boundary portion of the first virtual object, used to characterize the range limit of the first virtual object.
[0082] In step 1022A, in response to the direction of velocity being consistent with the direction of acceleration, the distance traveled by the first virtual object within the motion duration is determined based on the acceleration and velocity.
[0083] Here, the motion distance is the simulated distance that the first virtual object moves within the motion duration during the simulation of the first virtual object's motion.
[0084] In some embodiments, step 1022A can be implemented by: determining a first product (e.g., 3 meters per second) of speed and motion time (e.g., 1 second) (e.g., 3 meters), determining a second product (e.g., 1 meter) of a preset coefficient (e.g., 0.5) and acceleration (e.g., the square of 2 meters per second) and motion duration (e.g., 1 second), and determining the sum of the first product and the second product as the motion distance (e.g., 4 meters) of the first virtual object within the motion duration.
[0085] In step 1023A, the sum of the movement distance and the distance threshold is determined as the movable distance of the first virtual object.
[0086] For example, the sum of the movement distance (e.g., 4 meters) and the distance threshold (e.g., 0.5 meters) is determined as the movable distance of the first virtual object (e.g., 4.5 meters).
[0087] In this embodiment, by calculating the sum of the movement distance and the distance threshold, the movement range of the first virtual object is precisely controlled, avoiding the movement range of the first virtual object from exceeding the preset boundary or the first virtual object from overlapping with other virtual objects. This helps to improve the realism of the virtual scene. The movable distance of the first virtual object is updated in real time according to the movement information of the first virtual object. For example, in variable speed motion, the movable distance can be dynamically calculated according to the change in acceleration. The movable distance is calculated through simple mathematical operations, avoiding complex geometric calculations or collision detection, thereby improving the running efficiency of the algorithm.
[0088] In some embodiments, motion information includes the velocity and acceleration of the first virtual object during motion, see [reference]. Figure 3C , Figure 3C This is a schematic diagram of the third process of the virtual object simulation method provided in the embodiments of this application, targeting... Figure 3A Step 102 shown can be achieved through... Figure 3C Steps 1021B to 1024B are implemented, and will be explained in detail below.
[0089] In step 1021B, in response to the fact that the direction of velocity is inconsistent with the direction of acceleration, two decomposition directions are obtained, and the two decomposition directions are perpendicular to each other.
[0090] Here, the direction of velocity refers to the direction of motion of the first virtual object, used to describe the direction in which the first virtual object moves within the virtual scene. This embodiment does not limit the direction of velocity; it can be the direction of linear motion, the tangent direction at a point in a curve, etc. The direction of acceleration refers to the direction of the velocity change of the first virtual object, used to represent the trend of the velocity change of the first virtual object. This embodiment does not limit the direction of acceleration; it can be consistent with the direction of velocity change, or inconsistent with the direction of velocity change, etc. Decomposition direction decomposes a physical quantity (such as velocity or acceleration) into several directions according to specific requirements. This embodiment decomposes velocity and acceleration into two mutually perpendicular decomposition directions. Mutually perpendicular means that the angle between two straight lines or two directions is 90 degrees, used to describe a specific positional relationship between two directions. This embodiment does not limit the mutually perpendicular cases; the two mutually perpendicular directions can be any two perpendicular directions in a plane, the horizontal direction in the plane of the spatial coordinate system of the virtual scene, or the vertical direction, etc.
[0091] In step 1022B, for each decomposition direction, the velocity and acceleration are decomposed according to the decomposition direction to obtain the decomposed velocity and the decomposed acceleration.
[0092] Here, the decomposed velocity is the velocity obtained by decomposing the velocity of the first virtual object according to the decomposition direction. This embodiment of the application does not limit the decomposed velocity; the decomposed velocity can be the velocity value in each decomposition direction. The decomposed acceleration is the acceleration component obtained by decomposing the acceleration of the first virtual object according to the decomposition direction. This embodiment of the application does not limit the decomposed acceleration; the decomposed acceleration can be the acceleration value in each decomposition direction.
[0093] In some embodiments, step 1022B can be implemented as follows: for each decomposition direction, determine a first angle between the direction of velocity and the decomposition direction, and determine the product of the cosine of the first angle and the velocity as the decomposed velocity; determine a second angle between the direction of acceleration and the decomposition direction, and determine the product of the cosine of the second angle and the acceleration as the decomposed acceleration.
[0094] For example, let's take the decomposition of velocity as an example to explain in detail. Determine the first angle (e.g., 60 degrees) between the direction of velocity (e.g., rotating 60 degrees counterclockwise along the horizontal direction) and the decomposition direction (e.g., the horizontal direction). The product of the cosine value of the first angle (e.g., 0.5) and the velocity (e.g., 2 meters per second) is determined as the decomposed velocity (e.g., 1 meter per second).
[0095] In step 1023B, the decomposition distance of the first virtual object in each decomposition direction is determined based on the decomposed velocity and the decomposed acceleration.
[0096] It should be noted that step 1023B is similar to step 102 and can be achieved through steps 1021A to 1023A, so it will not be described again here.
[0097] In step 1024B, the decomposition distances corresponding to the first virtual object in the two decomposition directions are determined as the movable distances of the first virtual object.
[0098] For example, the decomposition distances of the first virtual object in the two decomposition directions (e.g., the horizontal decomposition distance is 5 meters and the vertical decomposition distance is 3 meters) are determined as the movable distance of the first virtual object.
[0099] In this embodiment, by decomposing the directions of velocity and acceleration, the movable distance of the virtual object in different directions is calculated respectively, the motion information of the virtual object is accurately simulated, the motion trajectory of the first virtual object in each direction is determined, and a complex motion path is generated. By decomposing the velocity and acceleration, the decomposed distance in each decomposed direction is calculated, thereby generating the movable range of the first virtual object and improving the accuracy of determining the movable range of the first virtual object.
[0100] In step 103, the range of motion of the first virtual object in the virtual scene is determined based on the movable distance.
[0101] Here, the movable range is the area in which the first virtual object can move in the virtual scene. In this embodiment of the application, the movable range is not limited, and the movable range can be a circular area, a rectangular area, etc.
[0102] In some embodiments, the two decomposition directions are a first direction and a second direction in the virtual scene, respectively. After executing steps 1021B to 1024B, see [link to documentation]. Figure 3D , Figure 3D This is a schematic diagram of the fourth process of the virtual object simulation method provided in the embodiments of this application, which is aimed at... Figure 3A Step 103 shown can be achieved through... Figure 3D Steps 1031 to 1034 are implemented, and will be explained in detail below.
[0103] In step 1031, when the velocity direction is opposite to the acceleration direction, a regular shape is constructed based on the decomposition distances corresponding to the first virtual object in the two decomposition directions.
[0104] Wherein, the velocity direction is the direction of the velocity after decomposition in the first direction, and the acceleration direction is the direction of the acceleration after decomposition in the first direction.
[0105] Here, a regular shape is a shape with certain geometric features and regularities, such as a square, a circle, a triangle, etc. The regular shape constructed in the embodiments of this application can be a rectangle.
[0106] It should be noted that the first and second directions can be horizontal or vertical. When the first direction is horizontal and the second direction is vertical, the regular shape is a rectangle, with the length of the regular shape being the decomposition distance corresponding to the first direction and the width being the decomposition distance corresponding to the second direction. When the second direction is horizontal and the first direction is vertical, the regular shape is a rectangle, with the length of the regular shape being the decomposition distance corresponding to the second direction and the width being the decomposition distance corresponding to the first direction. The velocity direction is opposite to the acceleration direction and is used to represent that the first virtual object decelerates in the first direction. After the velocity of the first virtual object decreases to zero in the velocity direction, the velocity of the first virtual object increases sequentially from zero in the acceleration direction.
[0107] See Figure 4 , Figure 4 This is a schematic diagram of a regular shape structure provided in an embodiment of this application, such as... Figure 4As shown, when the first direction 401 represents the horizontal direction and the second direction 402 represents the vertical direction, the regular shape 403 is a rectangle. The length of the regular shape 403 is the decomposition distance corresponding to the first direction 402, and the width of the regular shape is the decomposition distance corresponding to the second direction 402.
[0108] In step 1032, the motion trajectory of the first virtual object in the virtual scene is simulated based on the speed and acceleration of the first virtual object during the motion process.
[0109] Here, the motion trajectory is the path traversed by the first virtual object during its movement. This application embodiment does not limit the motion trajectory, which can be a straight line, a curve, a broken line, etc.
[0110] In some embodiments, step 1032 can be implemented as follows: obtaining the motion duration of the first virtual object and dividing the motion duration into N motion sub-durations, where N is the number of motion sub-durations; determining the speed of the first virtual object as the speed of the first round and the acceleration of the first virtual object as the acceleration of the first round; determining the current position of the first virtual object as the position of the first round; based on the speed and acceleration of the nth round, performing position offset processing on the position of the nth round within the motion sub-duration of the nth round to obtain the position of the (n+1)th round; determining the acceleration of the nth round as the acceleration of the (n+1)th round, and determining the speed of the (n+1)th round by multiplying the acceleration of the nth round by the motion sub-duration of the nth round and the speed of the nth round, where n is a positive integer that increases sequentially, 1≤n<N; connecting the positions of the first N rounds to obtain the motion trajectory of the first virtual object in the virtual scene.
[0111] Following the above embodiments, the above "based on the speed and acceleration of the nth round, perform position offset processing on the position of the nth round within the motion sub-duration of the nth round to obtain the position of the (n+1)th round" can be implemented in the following way: based on the speed and acceleration of the nth round, determine the motion distance of the first virtual object in the nth round within the motion sub-duration of the nth round (e.g., offset 2 meters in the horizontal direction and 1 meter in the vertical direction), and determine the position of the (n+1)th round (e.g., (3, 3)) by summing the motion distance of the nth round and the position of the nth round (e.g., (1, 2)).
[0112] See Figure 5 , Figure 5 This is a schematic diagram of the motion trajectory construction provided in the embodiments of this application, such as... Figure 5 As shown, the regular shape 501 contains a motion trajectory 502. The starting point of the motion trajectory 502 is the current position of the first virtual object, and the ending point of the motion trajectory 502 is the predicted position of the first virtual object within the motion duration.
[0113] Following the above embodiments, the step of "determining the movement distance of the first virtual object in the nth round within the movement sub-duration of the nth round based on the speed and acceleration of the nth round" is similar to step 1022, and will not be repeated here.
[0114] In step 1033, the area covered by the regular shape is determined in the virtual scene.
[0115] The area includes the movement trajectory.
[0116] Here, the covered area refers to the spatial range occupied by the regular shape. In a virtual scene, this area is determined by the size, shape, and position of the regular shape. This application embodiment does not limit the covered area, and the covered area can be any part of the virtual scene.
[0117] In some embodiments, the first decomposition distance is the decomposition distance of the first virtual object in the first direction, and the second decomposition distance is the decomposition distance of the first virtual object in the second direction. Step 1033 can be implemented in the following way: during the simulation of the motion trajectory, determine the motion distance when the velocity of the first virtual object after decomposition in the first direction decreases to zero; obtain the first coordinate value of the first virtual object in the first direction and the second coordinate value in the second direction, and sum the first coordinate value and the motion distance to obtain the third coordinate value in the first direction; determine the first coordinate point and the second coordinate point in the virtual scene, wherein the coordinate value of the first coordinate point in the first direction is the third coordinate value, the coordinate value of the first coordinate point in the second direction is the second coordinate value, the coordinate value of the second coordinate point in the first direction is the difference between the third coordinate value and the first decomposition distance, and the coordinate value of the second coordinate point in the second direction is the sum of the second coordinate value and the second decomposition distance; determine the first coordinate point as the first vertex of the region, and determine the second coordinate point as the second vertex of the region, wherein the line connecting the first vertex and the second vertex is the diagonal of the region.
[0118] Here, the first decomposition distance is the decomposition distance of the first virtual object in the first direction, used to represent the distance component of the first virtual object's movement in the first direction. The first direction is a direction used to decompose the movement of the first virtual object. The value of the movement distance depends on the movement speed, movement acceleration, and movement time of the first virtual object. The coordinate value is used to determine the position of the first virtual object in the virtual scene. In this embodiment, the first coordinate value is the current position identifier of the first virtual object in the first direction, and the second coordinate value is the current position identifier of the first virtual object in the second direction. This embodiment does not limit the coordinate values; the coordinate values can be values set according to the horizontal coordinate system of the virtual scene. The first coordinate point is a position point in the virtual scene determined based on the movement information of the first virtual object. The second coordinate point is another position point in the virtual scene determined based on the movement information of the first virtual object. The region is the range in the virtual scene determined by specific coordinate points. Vertices are key position points that constitute the region. In this embodiment, the first coordinate point is determined as the first vertex of the region, and the second coordinate point is determined as the second vertex of the region. The line connecting the first vertex and the second vertex is the diagonal of the region, which is a line segment connecting two non-adjacent vertices of the region.
[0119] In some embodiments, the above-mentioned "determining the movement distance when the velocity of the first virtual object after decomposition in the first direction decreases to zero" can be achieved in the following way: based on the velocity and acceleration of the first virtual object after decomposition in the first direction, determine the deceleration time when the velocity of the first virtual object after decomposition in the first direction decreases to zero; based on the velocity and acceleration of the first virtual object after decomposition in the first direction, determine the movement distance of the first virtual object within the deceleration time; and determine the movement distance of a virtual object within the deceleration time as the movement distance when the velocity of the first virtual object after decomposition in the first direction decreases to zero.
[0120] Following the above embodiments, the above-mentioned "determining the deceleration duration when the velocity of the first virtual object after decomposition in the first direction decreases to zero based on the velocity and acceleration of the first virtual object after decomposition in the first direction" can be achieved in the following way: the deceleration duration is determined by the ratio (e.g., 3 seconds) of the velocity (e.g., 6 meters per second) and the acceleration (e.g., the square of 2 meters per second) of the first virtual object after decomposition in the first direction.
[0121] Following the above embodiments, the step of "determining the distance the first virtual object moves during the deceleration period based on the velocity and acceleration of the first virtual object after decomposition in the first direction" is similar to step 1022, and will not be repeated here.
[0122] See Figure 6 , Figure 6This is a schematic diagram of the area provided in the embodiments of this application, such as... Figure 6 As shown, region 601 contains a first virtual object 602 and its motion trajectory 603. The coordinates of the first virtual object 602 are (x0, y0), where y0 represents the first coordinate value of the first virtual object 602 in the vertical direction, and x0 represents the second coordinate value of the first virtual object 602 in the horizontal direction. The motion distance (r) 604 of the first virtual object when its decomposed velocity in the vertical direction decreases to zero is determined. The first coordinate point 605 of the region is determined, and its coordinates are (x0, y0+r). Where y0+r represents the sum of the first coordinate value of the first virtual object in the vertical direction and the movement distance; the second coordinate point 606 of the region is determined, and the coordinates of the second coordinate point 606 are (x0+L, y0+rW), where the difference between the vertical coordinate value (y0+r) of the second coordinate point 606 and the first decomposition distance (W), and the sum of the horizontal coordinate value (x0) and the second decomposition distance (L) of the second coordinate point 606. The line connecting the first coordinate point and the second coordinate point is the diagonal of the region.
[0123] In this embodiment, the first coordinate point and the second coordinate point are respectively defined as the first vertex and the second vertex of the region, and a line is drawn to form the diagonal of the region, thereby organizing the spatial relationships in the virtual scene. When simulating complex scenes, the efficiency and accuracy of scene rendering are improved by clearly defining the boundaries and vertices of the region. By accurately simulating the motion trajectory of virtual objects, a realistic and smooth interactive experience is provided to the user. For example, in application scenarios such as virtual driving or motion capture, by decomposing the calculation of distance and coordinate values, the user's operational intentions are accurately reflected, thereby enhancing the user's immersion and satisfaction.
[0124] In some embodiments, step 1033 can also be implemented by: obtaining a preset distance threshold for the first virtual object, performing displacement processing on the region according to the preset distance threshold, and determining the region after displacement processing as the region covered by a regular shape in the virtual scene.
[0125] Following the above embodiments, the above-mentioned "displacement processing of the region according to the preset distance threshold" can be achieved in the following way: the difference between the coordinate value of the region in the horizontal direction and the preset distance threshold is determined as the fourth coordinate value, the sum of the coordinate value of the region in the vertical direction and the preset distance threshold is determined as the fifth coordinate value, the coordinate value of the region in the horizontal direction is replaced with the fourth coordinate value, and the coordinate value of the region in the vertical direction is replaced with the fifth coordinate value.
[0126] See Figure 7 , Figure 7 This is a schematic diagram of regional displacement provided in an embodiment of this application, such as... Figure 7 As shown, region 701 contains a first virtual object 702. The difference between the horizontal coordinate value of region 701 and a preset distance threshold 703 is determined as the fourth coordinate value. The sum of the vertical coordinate value of region 701 and the preset distance threshold is determined as the fifth coordinate value. The horizontal coordinate value of region 701 is replaced with the fourth coordinate value, and the vertical coordinate value of region 701 is replaced with the fifth coordinate value to obtain a new region 704.
[0127] In step 1034, the region is defined as the movable range of the first virtual object.
[0128] In the embodiments of this application, the simulation method based on velocity and acceleration can accurately reflect the motion information of the first virtual object, avoid errors caused by ignoring acceleration, support complex motion scenarios, such as curvilinear motion or non-uniform motion, and further, determining the area covered by the regular shape helps to limit the activity range of the first virtual object and prevent it from exceeding the boundary of the virtual scene, which not only improves the accuracy of the simulation, but also reduces unnecessary computational overhead.
[0129] In some embodiments, when the direction of velocity is consistent with the direction of acceleration, during execution Figure 3B After steps 1021A to 1023A, the movable distance of the first virtual object is obtained, or when the direction of velocity is not consistent with the direction of acceleration, the following steps are performed: Figure 3C After steps 1021B to 1024B, the square root of the sum of the squares of the decomposition distances corresponding to the first virtual object in the two decomposition directions is determined as the movable distance of the first virtual object. Figure 3A Step 103 shown can also be implemented in the following way: obtain a set shape, and scale the set shape based on the movable distance to obtain a target shape; determine the area covered by the target shape in the virtual scene, wherein the center point of the area coincides with the position of the first virtual object in the virtual scene; and determine the area as the movable range of the first virtual object.
[0130] Here, the set shape is a shape with a preset range of motion. This application embodiment does not limit the set shape, and the set shape can be a square, a circle, etc.
[0131] In some embodiments, the above-mentioned "scaling the set shape based on the movable distance to obtain the target shape" can be achieved by: determining the initial parameters of the set shape, determining the ratio of the movable distance to the initial parameters as the scaling factor, and scaling the set shape according to the scaling factor to obtain the target shape.
[0132] For example, taking a circle as the set shape, determine the initial parameters of the set shape (e.g., the radius of the circle is 2), determine the ratio of the movable distance (e.g., 4) to the initial parameters as the scaling factor (e.g., 2), scale the set shape according to the scaling factor to obtain the target shape (e.g., a circle with a radius of 4), and determine the area covered by the target shape in the virtual scene (e.g., a circular area with a radius of 4, the center point of the circular area coincides with the position of the first virtual object in the virtual scene).
[0133] Continuing with the example above, let's take a square as an example. We determine the initial parameters of the set shape (e.g., a square with a side length of 2). We determine the ratio of the movable distance (e.g., 4) to the initial parameters as the scaling factor (e.g., 2). We scale the set shape according to the scaling factor to obtain the target shape (e.g., a square with a side length of 4). We then determine the area covered by the target shape in the virtual scene (e.g., a square area with a side length of 4, where the center point of the square area coincides with the position of the first virtual object in the virtual scene).
[0134] In this embodiment, precise calculation and scaling ensure that the movable range effectively covers the active area of the first virtual object, improving the accuracy of loading virtual objects. Since there are no restrictions on the set shape, it adapts to various loading needs, enhancing the flexibility of loading virtual objects. During the loading of the second virtual object, the movable range is ensured to completely cover the area where the first virtual object can move, further improving the accuracy of loading virtual objects.
[0135] In step 104, a second virtual object within the movable range of the virtual scene is loaded.
[0136] Here, loading is the process of introducing a second virtual object within the movable range into the virtual scene.
[0137] In some embodiments, when there are multiple movable ranges, step 104 can be implemented by steps 1041A to 1045A (not shown in the figure).
[0138] In step 1041A, the overlapping portion between any two movable ranges is determined.
[0139] Here, the overlapping part is the region where any two movable ranges overlap.
[0140] It should be noted that the intersection between any two movable ranges is the overlapping part between any two movable ranges.
[0141] In step 1042A, when one of the two movable ranges is the same as the corresponding overlapping part, one movable range is deleted from the multiple movable ranges to obtain the remaining movable range.
[0142] Here, deletion refers to the operation of removing a specified object or element (such as a movable range) from a collection (such as multiple movable ranges). Remaining movable ranges refer to the other movable ranges remaining after the deletion operation.
[0143] For example, given a movable range A and a movable range B, determine the overlapping portion C between movable range A and movable range B. When movable range B is the same as the overlapping portion C, it means that movable range A contains movable range B. Only the second virtual object corresponding to movable range A needs to be loaded. Therefore, movable range B is deleted.
[0144] In step 1043A, the remaining movable range is grouped based on the overlapping portion to obtain a first group and at least one second group.
[0145] In this group, the movable ranges included in the first group do not overlap, while any movable range included in the second group overlaps with at least one other movable range, and the other movable ranges are the movable ranges in the second group other than any one movable range.
[0146] Here, grouping refers to dividing the remaining movable range into different groups based on whether there is overlap between the movable ranges. The first group is one of the grouped groups, in which the movable ranges included do not overlap. The second group is another group or more of the grouped groups, in which any movable range included overlaps with at least one other movable range.
[0147] In some embodiments, step 1043A can be implemented as follows: for each of the remaining movable ranges, the following operations are performed: when no overlapping portion corresponding to the movable range is found, the movable range is assigned to a first group; when an overlapping portion corresponding to the movable range is found, the movable range and another movable range corresponding to the overlapping portion are assigned to a second group.
[0148] It should be noted that when assigning the movable range and the other movable range corresponding to the overlapping part to a second group, if the movable range has already been assigned to any second group, the other movable range corresponding to the overlapping part will also be assigned to any second group; if the movable range has not been assigned to any second group, the movable range and the other movable range corresponding to the overlapping part will be assigned to a new second group.
[0149] In step 1044A, a second virtual object within the movable range of the first group is loaded.
[0150] In some embodiments, the following steps are performed before step 1044A: querying the object configuration table based on the movable range in the first group, wherein the object configuration table includes the correspondence between different candidate movable ranges and different virtual objects; when a candidate movable range corresponding to the movable range in the first group is found from the object configuration table, the virtual object corresponding to the queried candidate movable range is determined as the second virtual object within the movable range in the first group.
[0151] It should be noted that the object configuration table is a data structure used to store the correspondence between different candidate movable ranges and different virtual objects. This application embodiment does not limit the object configuration table. The object configuration table can be a data structure implemented as a hash table, a data structure implemented as an array, etc., used to quickly perform lookup, insertion, and deletion operations on the correspondence between candidate movable ranges and virtual objects. The hash table uses a hash function to calculate the index value, mapping the movable range in the first group of inputs to the position in the hash table to access the virtual object.
[0152] In some embodiments, the above-mentioned "querying the candidate movable range corresponding to the movable range in the first group from the object configuration table" can be implemented in the following way: when any movable range in the object configuration table overlaps with the movable range in the first group, the arbitrary movable range in the object configuration table is determined as the candidate movable range.
[0153] In some embodiments, the above-mentioned "querying the candidate movable range corresponding to the movable range in the first group from the object configuration table" can also be implemented in the following way: when the ratio of the area of the overlapping part of any movable range in the object configuration table and the movable range in the first group (e.g., 20) to the area of any movable range (e.g., 25) (e.g., 0.8) is greater than a preset value (e.g., 0.75), any movable range in the object configuration table is determined as a candidate movable range.
[0154] In step 1045A, the second virtual objects within the movable range of the second group are loaded sequentially according to the order of the movable range in the second group.
[0155] Here, sequential loading means loading the second virtual objects in a specific order of the movable range in the second group, and there is overlap between adjacent movable ranges in the second group.
[0156] In some embodiments, step 1045A can be implemented as follows: loading a second virtual object within the first movable range of the second group; detecting any second virtual object within the nth movable range of the second group to obtain a detection result; when the detection result indicates that any second virtual object is to be loaded, loading any second virtual object, where n is a positive integer that increases sequentially, 1 < n ≤ N, and N is the number of movable ranges in the second group.
[0157] Here, the detection is a check and test performed on whether the second virtual object within the nth movable range of the second group is yet to be loaded. The detection result is a conclusion drawn after the detection operation, indicating the state of the detected second virtual object, such as whether it is yet to be loaded.
[0158] In some embodiments, the above-mentioned "detecting any second virtual object within the nth movable range in the second group and obtaining a detection result" can be implemented in the following way: querying at least one second virtual object corresponding to the nth movable range in the second range group from the object configuration table, wherein the object configuration table includes the correspondence between different movable ranges and different virtual objects; when any second virtual object among the at least one second virtual object queried has been loaded, the detection result is determined as a first preset result (e.g., 1), the first preset result is used to characterize that any second virtual object has been loaded; when any second virtual object among the at least one second virtual object queried has not been loaded (e.g., 0), the detection result is determined as a second preset result, the second preset result is used to characterize that any second virtual object is to be loaded.
[0159] Following the above embodiments, the step of "querying out at least one second virtual object corresponding to the nth movable range in the second range group from the object configuration table" is similar to the step of "querying out the candidate movable range corresponding to the movable range in the first group from the object configuration table", and will not be repeated here.
[0160] In this embodiment, within the virtual scene, the movable range in the second group is traversed using sequentially increasing positive integers n. Second virtual objects within each movable range are detected, and their states are systematically identified and processed to ensure that the state of each second virtual object is correctly recorded and updated. When any second virtual object is detected to be loaded, it is loaded promptly, improving the real-time performance and interactivity of virtual object control. This avoids reloading already loaded second virtual objects, preventing unnecessary resource waste and thus improving loading efficiency.
[0161] In this embodiment, unnecessary computation is reduced by calculating overlapping areas, algorithm efficiency is improved by deleting movable ranges contained in other movable ranges and grouping them, and the independence and stability between virtual objects are ensured by loading virtual objects in the second group in sequence.
[0162] In some embodiments, when there are multiple movable ranges, step 104 can be implemented by steps 1041B to 1045B (not shown in the figure).
[0163] In step 1041B, the positional relationship between any two movable ranges is verified to obtain the verification result.
[0164] Here, positional relationship verification is an operation that checks and verifies the relative positional relationship between any two movable ranges in space to determine the positional relationship between them, such as whether they intersect, contain each other, or are adjacent. The verification result is the conclusion drawn after the positional relationship verification operation, which is used to indicate the positional relationship between the two movable ranges.
[0165] In some embodiments, any two movable ranges include a first movable range and a second movable range, wherein the side length of the first movable range is greater than the side length of the second movable range. Step 1041B can be implemented as follows: determine the difference between the side length of the first movable range and the side length of the second movable range, and determine the ratio of the difference to the side length of the first movable range as a first scaling ratio; scale the first movable range based on the first scaling ratio to obtain a first predicted range centered on the center point of the first movable range; when the center point of the second movable range is within the first predicted range, determine the verification result as a first preset result, wherein the first preset result indicates that the second movable range is included in the first movable range.
[0166] Here, the scaling process adjusts the size of the first movable range based on a first scaling ratio. The first predicted range is the range obtained after scaling the first movable range, centered on the center point of the first movable range, and used to determine its positional relationship with the center point of the second movable range. The center point refers to the geometric center of a region (such as the first or second movable range).
[0167] For example, see Figure 8 , Figure 8 This is a schematic diagram of the first prediction range provided in the embodiments of this application, such as... Figure 8 As shown, the difference (e.g., 8) between the side length of the first movable range (e.g., 10) and the side length of the second movable range (e.g., 2) is determined, and the ratio of the difference to the side length of the first movable range (e.g., 0.8) is determined as the first scaling ratio; the first movable range 801 is scaled based on the first scaling ratio to obtain a first predicted range 803 centered on the center point 802 of the first movable range; when the center point of the second movable range is within the first predicted range, the verification result is determined as the first preset result, which indicates that the second movable range is included in the first movable range.
[0168] In this embodiment, by calculating a first scaling factor and scaling the first movable range based on the first scaling factor, the possible location and coverage of the center point of the second movable range when it is contained within the first movable range can be accurately predicted. This reduces prediction errors caused by size differences, improves the overall prediction accuracy, avoids calculating the overlapping portion between the two movable ranges, and improves the efficiency of virtual object loading.
[0169] In some embodiments, step 1041B can also be implemented by: determining the sum of the side lengths of the first movable range and the second movable range, and determining the ratio of the sum to the side length of the first movable range as a second scaling ratio; scaling the first movable range based on the first scaling ratio to obtain a second predicted range centered on the center point of the first movable range; when the center point of the second movable range is outside the first predicted range but within the second predicted range, determining the verification result as a second preset result, the second preset result indicating that the second movable range and the first movable range overlap; when the center point of the second movable range is outside the second predicted range, determining the verification result as a third preset result, the third preset result indicating that the second movable range and the first movable range do not overlap.
[0170] Here, the side length refers to the boundary length of the movable range. This embodiment does not limit the side length; it can be the length and width of a rectangle, the diameter of a circle, etc. Taking a square region as an example where both the first and second movable ranges are movable, the side length is the length of each side within the movable range. The second preset result is the verification result determined when the center point of the second movable range is outside the first predicted range but within the second predicted range, indicating that the second movable range overlaps with the first movable range. The third preset result is the verification result determined when the center point of the second movable range is outside the second predicted range, indicating that the second movable range does not overlap with the first movable range.
[0171] For example, see Figure 9 , Figure 9 This is a schematic diagram of the second prediction range provided in the embodiments of this application, such as... Figure 9 As shown, the side lengths of the first movable range (e.g., 10) and the second movable range (e.g., 2) are determined, and the sum of the side lengths of the first and second movable ranges (e.g., 12) is determined. The ratio of the sum to the side length of the first movable range (e.g., 1.2) is determined as the second scaling ratio. The first movable range 901 is scaled based on the first scaling ratio to obtain a second prediction range 903 centered on the center point 902 of the first movable range. When the center point of the second movable range is outside the first prediction range but inside the second prediction range 903, the verification result is determined as the second preset result, which indicates that the second movable range and the first movable range overlap. When the center point of the second movable range is outside the second prediction range 903, the verification result is determined as the third preset result, which indicates that the second movable range and the first movable range do not overlap.
[0172] In this embodiment of the application, the first movable range is dynamically adjusted through mathematical operations, and a second predicted range is generated with the center point of the first movable range as the center. The relative positional relationship between the center point of the second movable range and the second predicted range is reflected based on the positional relationship between the two movable ranges, which improves the accuracy of positional relationship verification and enhances the flexibility and adaptability of positional relationship verification.
[0173] In step 1042B, when the verification result indicates that one of the two movable ranges is contained within the other movable range, one movable range is deleted from the multiple movable ranges to obtain the remaining movable ranges.
[0174] Here, step 1042B is similar to step 1042A, and will not be described again.
[0175] In step 1043B, based on the verification results, the remaining movable range is grouped to obtain a first group and at least one second group.
[0176] In this group, the movable ranges included in the first group do not overlap, while any movable range included in the second group overlaps with at least one other movable range, and the other movable ranges are the movable ranges in the second group other than any one movable range.
[0177] In some embodiments, step 1043B can be implemented as follows: for each of the remaining movable ranges, the following operations are performed: when a verification result corresponding to the movable range indicates that the movable range does not overlap with other movable ranges, the movable range is assigned to a first group; when a verification result corresponding to the movable range indicates that the movable range overlaps with other movable ranges, the movable range and other movable ranges are assigned to a second group.
[0178] In step 1044B, a second virtual object within the movable range of the first group is loaded.
[0179] Here, step 1044B is similar to step 1044A, and will not be described again.
[0180] In step 1045B, the second virtual objects within the movable range of the second group are loaded sequentially according to the order of the movable range in the second group.
[0181] Here, step 1045B is similar to step 1045A, and will not be described again.
[0182] In this embodiment, by deleting movable ranges with an inclusion relationship, redundant data is reduced, improving the speed and efficiency of subsequent loading of second virtual objects. Processing the movable ranges of the first and second groups independently avoids resource allocation conflicts, improving system stability and reliability. By sequentially loading the second virtual objects within the movable range of the second group, the logic and stability of the loading process are ensured, preventing the omission of necessary second virtual objects and thus enhancing the user experience.
[0183] In step 105, the motion process of the first virtual object is physically simulated based on the loaded second virtual object.
[0184] Here, physics simulation is the process of simulating the motion trajectory of a first virtual object using a physics engine (such as Unity3D or Open Dynamics Engine). The physics engine can calculate the acceleration, velocity, and position changes of the first virtual object based on its motion and pose information, combined with the loaded second virtual object and the external forces (such as gravity and friction) generated by the first virtual object during the collision.
[0185] In some embodiments, step 105 can be implemented in the following manner: in response to the first virtual object triggering a physical event for the loaded second virtual object during the simulation of the first virtual object's motion, the first virtual object updates its current motion information based on the attribute information of the loaded second virtual object to obtain target motion information; and controls the first virtual object to move according to the target motion information.
[0186] Here, the motion process refers to the trajectory and state changes of the first virtual object in the virtual environment. This embodiment does not limit the motion process; it can be a combination of various actions such as walking, running, and jumping. Physical events are interactive events triggered by the first virtual object during its motion and related to the second virtual object, such as collisions and pushes. Attribute information describes the characteristics of the second virtual object, such as mass, shape, and material. Motion information describes the motion of the first virtual object in the virtual environment. This embodiment does not limit the motion information; it can be the position, speed, and direction of the first virtual object. Target motion information is the new motion information obtained by updating the current motion information of the first virtual object based on the attribute information of the second virtual object.
[0187] In some embodiments, the above-mentioned "updating the current motion information of the first virtual object based on the attribute information of the loaded second virtual object to obtain the target motion information" can be achieved in the following way: obtaining the attribute information of the first virtual object (e.g., the mass of the first virtual object is 100kg); adjusting the current motion information of the first virtual object based on the attribute information of the first virtual object and the attribute information of the second virtual object according to the law of conservation of momentum and the law of conservation of kinetic energy to obtain the target motion information.
[0188] For example, the first virtual object (i.e., the player character) moves forward at a speed of v1 = 10 m / s, and the second virtual object is a stationary wall (with extremely large mass). When the distance between the player's coordinates (x1, y1) and the wall's coordinates is less than or equal to a distance threshold, a collision event is triggered. Here, the player's speed is v1, the player's mass is m1 (equal to 100 kg), and the wall's mass is m2 (approximately positive infinity). Due to the extremely large mass of the wall, in virtual engines (such as Unity), the wall is usually set as an infinitely large mass static rigid body. According to the laws of conservation of momentum and kinetic energy, the collision handling can be simplified to v′ = -e*v (e is the elastic coefficient, 0 ≤ e ≤ 1). When e = 0, the movement is a completely inelastic collision, and the player remains stationary (e.g., hitting a soft wall). When e = 1, the movement is a completely elastic collision, and the player's speed reverses and remains the same (e.g., a bouncy ball). When e = 0.5, the player's speed reverses and decays to 0.5v, and the player moves according to the new speed after colliding with the first virtual object.
[0189] In this embodiment, after a first virtual object triggers a physical event (such as a collision) during its movement, the motion information of the first virtual object is updated based on the attribute information of the second virtual object. This simulates the physical interaction between objects in the real world, such as the application of the laws of conservation of momentum and kinetic energy, improving the realism and physical consistency of the virtual environment. For example, in the example, when a player character collides with a wall, a new velocity is calculated according to the laws of conservation of momentum and kinetic energy, making the collision result conform to physical laws and enhancing the user's immersion and gaming experience. Updating the motion information of virtual objects through physical events reduces unnecessary calculation and rendering operations. For example, in collision detection, only new motion information needs to be calculated according to physical laws, without the need for complex re-rendering of the entire virtual environment, improving computational efficiency, reducing system resource consumption, and thus improving overall performance.
[0190] In this embodiment, by acquiring a first virtual object, the objects that need to be interacted with or simulated in the virtual scene are identified. Based on the motion information of the first virtual object, the movable distance of the first virtual object is determined, and the movable range of the first virtual object in the virtual scene is determined. That is, the movement area of the first virtual object is determined and the first virtual object is controlled to move within the corresponding movement area, effectively limiting the activity range of the virtual object and preventing it from exceeding the boundaries of the virtual scene. Based on the movable distance, the movable range of the first virtual object in the virtual scene is determined, and a second virtual object within the movable range of the virtual scene is loaded, enriching the interactivity of the virtual scene and simulating the interaction between the first and second virtual objects, such as collisions and friction, further enhancing the realism and interactivity of the virtual scene. At the same time, loading the physical model of all areas in the virtual scene is avoided, reducing resource waste and improving the efficiency of virtual object simulation and loading. Based on the loaded second virtual object, the motion process of the first virtual object is physically simulated, simulating the physical properties and motion laws of the object, making the behavior of the virtual object natural and realistic, and enhancing the realism and immersion of the virtual scene.
[0191] The following will describe an exemplary application of the virtual object simulation method provided in this application embodiment in a real-world application scenario.
[0192] In related technologies, physics simulation is one of the core functions in game development. It is used to detect physical interactions between game objects (such as collisions, overlaps, and trigger events), character movement, collision detection, and other related game logic operations. The prerequisite for physics simulation is to preload the physical models of game objects. In large-scale games, due to the large map area, the large number of game objects, and the higher precision of game models, the precision of physical models is also very high. When there is a lot of data, the loading and calculation of physical models becomes a very large performance bottleneck.
[0193] To address the aforementioned issues, this application proposes a virtual object simulation method. Since the character (i.e., the first virtual object mentioned above) has a limited movement speed, it is impossible for the character to physically collide with all objects (i.e., the second virtual object mentioned above) within a fixed time period (generally, a physical simulation is performed once per frame, with the longest possible time being a single frame). Therefore, it is only necessary to calculate the maximum reachable range of the character and load the objects within the maximum reachable range for physical simulation.
[0194] For example, see the simulation of virtual objects. Figure 10 , Figure 10 This is a flowchart of the physical simulation provided in the embodiments of this application. The physical simulation process provided in the embodiments of this application will be explained below.
[0195] When physical simulation is required during each frame of the game, step 1001 is executed.
[0196] In step 1001, the roles are determined.
[0197] Here, all characters that will move in the current frame are identified.
[0198] In step 1002, all characters are traversed, and it is determined whether all characters have been traversed.
[0199] Here, when all characters have been traversed, step 4 is executed; when there are characters that have not been traversed, step 1003 is executed.
[0200] In step 1003, the reachable area of the character (i.e., the first movement area mentioned above) is calculated.
[0201] Here, the maximum area that the current character can reach is confirmed as the character's reachable area. The process of calculating the maximum area that the character can reach will be explained in detail below.
[0202] 1) Calculate the farthest distance the character can reach (i.e., the above-mentioned movable distance).
[0203] Here, the maximum distance R that the character can reach is calculated as shown in Formula 1.
[0204] R=(v+0.5*a*S)*S+L (1)
[0205] Where R represents the farthest distance the character can reach, v represents the character's current speed (i.e., the speed in the above motion information), in meters per second, a represents the maximum acceleration the character may reach under the current conditions (i.e., the acceleration in the above motion information), and the factors affecting the maximum acceleration include the current scene, the character's state, the user's operation, and the items used by the character (such as acceleration items), etc. The character's maximum acceleration can be updated according to the magnitude of the collision force, S represents the single frame time (i.e., the above motion duration), the single frame time is related to the current target frame rate, and the single frame time is 1 second divided by the target frame rate, L represents the current character's maximum physical collision distance (i.e., the above preset distance threshold), and (v+0.5*a*S)*S represents the distance the current character moves during the motion.
[0206] 2) Determine the maximum area that the character can reach (i.e., the range of motion mentioned above) based on the farthest distance the character can reach.
[0207] Draw a circular area with radius R; this represents the maximum reachable area for the character. Since maps are typically stored and calculated in squares, this area also needs to be converted to a square (i.e., the shape defined above). See [link to relevant documentation]. Figure 11, Figure 11 This is a schematic diagram of region conversion provided in an embodiment of this application, such as... Figure 11 As shown, the square region 1102, which is circumscribed by the circular region 1101, is taken as the final region, wherein the centroid of the square region 1102 is the same as the centroid of the circular region 1101.
[0208] Let {x, y, r} represent the square region 1102, where x and y are the x and y coordinates of the top-left vertex of the square region (the top-left corner of the entire map 1103 is the origin), and r is the calculated side length of the square region 1102, which is twice the radius R of the circular region 1101 mentioned above. Thus, when performing physics simulations, only all physical models within the square region 1102 need to be loaded, significantly reducing the performance overhead of loading unnecessary physical models.
[0209] The maximum area calculated using the above method is suitable for characters with low movement speeds. If the movement speed is high, the determined area will increase. The area can be further narrowed down by accurately calculating the character's movement trajectory. See also... Figure 12 , Figure 12 This is a schematic diagram of area determination provided in an embodiment of this application, such as... Figure 12 As shown, the character's motion can be simplified into a physical motion model, that is, the character starts moving from point A with an initial velocity V, and at the same time has an acceleration K with a certain angle to the initial velocity. The character's motion trajectory 1202 is similar to an approximate parabola from point A to point B in the figure above.
[0210] Since the character itself is not a point mass but has a certain size, it will collide with other physical models within a specific range. Therefore, this range can be the area enclosed by the five points A2, C, B1, B2, and A2. To simplify the calculation process, this area is simplified to a rectangle, namely region 1201. The top left vertex D(x, y) of this rectangle (i.e., the first vertex mentioned above) and the two side lengths a and b of the rectangle are calculated.
[0211] The character's initial velocity and acceleration are decomposed into the x-axis and y-axis directions (i.e., the two decomposition directions mentioned above), namely Vx, Vy and Kx, Ky, respectively. In the x-axis direction, based on the initial velocity Vx (i.e., the velocity after decomposition above), acceleration Kx (i.e., the acceleration after decomposition above), and time (i.e., the time per frame), the farthest distance b1 that the character can reach in the x-axis direction is determined. b1 plus twice the radius of the character itself gives the side length b of the rectangular region (i.e., the decomposed distance in the decomposition direction mentioned above). The x-axis coordinate of point D is the x-axis coordinate of point A (i.e., the second coordinate value mentioned above) minus the radius of the character. Similarly, based on the character's initial velocity Vy, acceleration Ky, and time (i.e., the time per frame) in the y-axis direction, the farthest distance a1 that the character can reach in the y-axis direction is obtained. a1 plus twice the radius of the character itself gives the side length a of the rectangular region (i.e., the regular shape mentioned above). The y-axis coordinate of point D is the maximum y-axis value that the character can reach (i.e., the third coordinate value mentioned above). Then, subtract the character's radius. When the character's trajectory reaches point C, the maximum y-axis value that the character can reach is the maximum value.
[0212] Based on the coordinates of vertex D and the lengths of the two sides a and b, the rectangular region is labeled as {x, y, a, b}.
[0213] In step 1004, the overlapping area (i.e., the aforementioned movable range) is eliminated.
[0214] Here, after calculating the reachable areas of all characters, completely overlapping areas are removed to avoid reloading the physics model.
[0215] During actual gameplay, there will be many movable characters. It's necessary to calculate the movement range (reachable area) of all characters sequentially. However, the movement ranges of characters may overlap. (See below for details.) Figure 13 , Figure 13 This is a schematic diagram of the reachable area of the role provided in the embodiments of this application, such as... Figure 13 As shown, Figure 13 It contains reachable areas for different roles, namely A1, A2, B, C1, C2, and C3. There are three types of relationships between reachable areas: complete overlap, partial overlap, and no overlap. The relationships between reachable areas are explained in detail below.
[0216] 1) Complete overlap relationship (i.e., the above verification result indicates that one of the two movable ranges is contained in the other movable range).
[0217] Here, as Figure 13 In the example, A1 and A2 are completely covered by A2. Only the physical model within the A2 region needs to be loaded. A1 is a subset of A2.
[0218] 2) Partial overlap (i.e., the above second preset result indicates that the second movable range overlaps with the first movable range).
[0219] Here, as Figure 13 C1, C2, and C3 overlap to some extent but not completely. Considering the region description {x, y, r}, merging C1, C2, and C3 would affect the loading of the physics model due to their irregular shapes. Either more rectangular regions would be divided for loading the physics model separately, or C1, C2, and C3 would be merged into a larger rectangle. Both methods would incur additional overhead. Therefore, C1, C2, and C3 are treated as three independent regions. However, when loading the physics model, an additional check is added: if the physics model of a certain region has already been loaded in a previous region, it will not be loaded again.
[0220] 3) Completely non-overlapping relationship (i.e., the above third preset result indicates that the second movable range and the first movable range do not overlap).
[0221] Here, for example, in region B, regions that do not overlap can be processed separately.
[0222] In step 1005, the regions are grouped to obtain independent region groups (i.e., the first group mentioned above) and overlapping region groups (i.e., the second group mentioned above).
[0223] Here, according to the aforementioned rules, the regions calculated in the aforementioned steps are divided into two categories: independent regions and overlapping regions. Regions with overlapping relationships are grouped together; all independent regions are added to the same group.
[0224] In step 1006, the physical model corresponding to the independent region group is loaded.
[0225] Here, the physical models of all independent regions within the independent region group are loaded. When loading physical models, unconnected regions are grouped together and placed in the same group. For each group, all physical models within that region are loaded sequentially. For example, in... Figure 6 In this case, region B and region A2 are placed in the same group, and the physical models in these two regions can be loaded in full directly.
[0226] In step 1007, the physical model corresponding to the overlapping region group is loaded.
[0227] Here, the physical model of each overlapping region in the overlapping region group is loaded. Before loading the physical model, overlapping regions are grouped together, for example... Figure 6Regions C1, C2, and C3 are grouped together. For this group, the first region C1 (the first movable area mentioned above) can directly load all physical models. Starting with the second region (such as C2), it's necessary to first check if the corresponding model for that region has already been loaded. If not, then load the model to avoid duplicate loading of models from overlapping regions. Taking regions C1, C2, and C3 as an example, for region C1, all physical models within region C1 can be loaded directly. However, for regions C2 and C3, it's necessary to first check if the corresponding physical models have already been loaded, and then load them if not.
[0228] In step 1008, a physical simulation of the character is performed based on the loaded physical model.
[0229] Here, after loading the physical models of all areas, the characters are physically simulated according to the game logic.
[0230] In summary, the number of physical models loaded in this embodiment is significantly reduced, and the time consumed per frame is significantly reduced. This avoids the lag that occurs when users interact with virtual scenes due to loading a large number of physical models, thus improving the user's gaming experience.
[0231] The following description continues to illustrate the exemplary structure of the virtual object simulation device 555 provided in the embodiments of this application as a software module. In some embodiments, such as... Figure 2 As shown, the software modules in the simulation device 555 storing virtual objects in memory 550 may include:
[0232] The data acquisition module 5551 is used to acquire the first virtual object in the virtual scene.
[0233] The range determination module 5552 is used to determine the movable distance of the first virtual object based on the motion information of the first virtual object; and to determine the movable range of the first virtual object in the virtual scene based on the movable distance.
[0234] Object loading module 5553 is used to load a second virtual object within the movable range of the virtual scene.
[0235] The physics simulation module 5554 is used to perform physical simulation of the motion process of the first virtual object based on the loaded second virtual object.
[0236] In some embodiments, the range determination module 5552 is further configured to obtain the motion duration of the first virtual object and obtain a preset distance threshold for the first virtual object; in response to the direction of velocity being consistent with the direction of acceleration, determine the motion distance of the first virtual object within the motion duration based on acceleration and velocity; and sum the motion distance and the distance threshold to determine the movable distance of the first virtual object, wherein the motion information includes the velocity and acceleration of the first virtual object during the motion process.
[0237] In some embodiments, the range determination module 5552 is further configured to, in response to the inconsistency between the direction of velocity and the direction of acceleration, acquire two decomposition directions, the two decomposition directions being perpendicular to each other; for each decomposition direction, decompose the velocity and acceleration according to the decomposition direction to obtain the decomposed velocity and the decomposed acceleration; based on the decomposed velocity and the decomposed acceleration, determine the decomposition distance of the first virtual object in each decomposition direction; and determine the decomposition distances of the first virtual object corresponding to the two decomposition directions as the movable distance of the first virtual object, wherein the motion information includes the velocity and acceleration of the first virtual object during the motion process.
[0238] In some embodiments, the range determination module 5552 is further configured to: construct a regular shape based on the decomposition distances corresponding to the first virtual object in the two decomposition directions when the velocity direction is opposite to the acceleration direction, wherein the velocity direction is the direction of the velocity after decomposition in the first direction, and the acceleration direction is the direction of the acceleration after decomposition in the first direction; simulate the motion trajectory of the first virtual object in the virtual scene based on the velocity and acceleration of the first virtual object during the motion process; determine the area covered by the regular shape in the virtual scene, wherein the area includes the motion trajectory; and determine the area as the movable range of the first virtual object, wherein the two decomposition directions are the first direction and the second direction in the virtual scene, respectively.
[0239] In some embodiments, the range determination module 5552 is further configured to: determine the motion distance of the first virtual object when its velocity decreases to zero after decomposition in the first direction during the simulation of the motion trajectory; obtain the first coordinate value of the first virtual object in the first direction and the second coordinate value in the second direction, and sum the first coordinate value and the motion distance to obtain the third coordinate value in the first direction; determine the first coordinate point and the second coordinate point in the virtual scene, wherein the coordinate value of the first coordinate point in the first direction is the third coordinate value, the coordinate value of the first coordinate point in the second direction is the second coordinate value, the coordinate value of the second coordinate point in the first direction is the difference between the third coordinate value and the first decomposition distance, and the coordinate value of the second coordinate point in the second direction is the sum of the second coordinate value and the second decomposition distance; determine the first coordinate point as the first vertex of the region, and determine the second coordinate point as the second vertex of the region, wherein the line connecting the first vertex and the second vertex is the diagonal of the region, wherein the first decomposition distance is the decomposition distance of the first virtual object in the first direction, and the second decomposition distance is the decomposition distance of the first virtual object in the second direction.
[0240] In some embodiments, the range determination module 5552 is further configured to acquire a set shape, and scale the set shape based on the movable distance to obtain a target shape; determine the area covered by the target shape from the virtual scene, wherein the center point of the area coincides with the position of the first virtual object in the virtual scene; and determine the area as the movable range of the first virtual object.
[0241] In some embodiments, the object loading module 5553 is further configured to: determine the overlapping portion between any two movable ranges when there are multiple movable ranges; delete one movable range from the multiple movable ranges when one of the movable ranges is the same as the corresponding overlapping portion, to obtain the remaining movable ranges; group the remaining movable ranges based on the overlapping portion to obtain a first group and at least one second group, wherein there is no overlap between the movable ranges included in the first group, and any movable range included in the second group overlaps with at least one other movable range, wherein the other movable ranges are the movable ranges in the second group other than any one of the movable ranges; load the second virtual objects within the movable ranges in the first group; and load the second virtual objects within the movable ranges in the second group in sequence according to the order of the movable ranges in the second group.
[0242] In some embodiments, the object loading module 5553 is further configured to load a second virtual object within the first movable range of the second group; detect any second virtual object within the nth movable range of the second group to obtain a detection result; and load any second virtual object when the detection result indicates that any second virtual object is to be loaded, where n is a positive integer that increases sequentially, 1 < n ≤ N, and N is the number of movable ranges in the second group.
[0243] In some embodiments, the object loading module 5553 is further configured to: when there are multiple movable ranges, perform positional relationship verification on any two movable ranges to obtain a verification result; when the verification result indicates that one movable range is contained within another movable range, delete one movable range from the multiple movable ranges to obtain the remaining movable ranges; based on the verification result, group the remaining movable ranges to obtain a first group and at least one second group, wherein the movable ranges included in the first group do not overlap, and any movable range included in the second group overlaps with at least one other movable range, wherein the other movable ranges are the movable ranges in the second group other than any one of the movable ranges; load the second virtual objects within the movable ranges in the first group; and load the second virtual objects within the movable ranges in the second group sequentially according to the order of the movable ranges in the second group.
[0244] In some embodiments, the object loading module 5553 is further configured to determine the difference between the side length of the first movable range and the side length of the second movable range, and to determine the ratio of the difference to the side length of the first movable range as a first scaling ratio; to scale the first movable range based on the first scaling ratio to obtain a first predicted range centered on the center point of the first movable range; and to determine the verification result as a first preset result when the center point of the second movable range is within the first predicted range, wherein the first preset result indicates that the second movable range is included in the first movable range, wherein any two movable ranges include the first movable range and the second movable range, and the side length of the first movable range is greater than the side length of the second movable range.
[0245] In some embodiments, the object loading module 5553 is further configured to determine the sum of the side length of the first movable range and the side length of the second movable range, and determine the ratio of the sum to the side length of the first movable range as a second scaling ratio; scale the first movable range based on the first scaling ratio to obtain a second predicted range centered on the center point of the first movable range; when the center point of the second movable range is outside the first predicted range but within the second predicted range, determine the verification result as a second preset result, the second preset result indicating that the second movable range and the first movable range overlap; when the center point of the second movable range is outside the second predicted range, determine the verification result as a third preset result, the third preset result indicating that the second movable range and the first movable range do not overlap.
[0246] In some embodiments, the physics simulation module 5554 is further configured to respond to the first virtual object triggering a physical event against the loaded second virtual object during the simulation of the first virtual object's motion, update the current motion information of the first virtual object based on the attribute information of the loaded second virtual object, obtain target motion information, and control the first virtual object to move according to the target motion information.
[0247] This application provides a computer program product including computer-executable instructions stored in a computer-readable storage medium. The processor of an electronic device reads the computer-executable instructions from the computer-readable storage medium and executes the computer-executable instructions, causing the electronic device to perform the virtual object simulation method described above in this application embodiment.
[0248] This application provides a computer-readable storage medium storing computer-executable instructions or a computer program. When the computer-executable instructions or the computer program are executed by a processor, the processor will execute the simulation method for virtual objects provided in this application. For example, ... Figures 3A to 3D The simulation method of the virtual object is shown.
[0249] In some embodiments, the computer-readable storage medium may be a memory such as RAM, ROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; or it may be a variety of devices including one or any combination of the above-mentioned memories.
[0250] In some embodiments, computer-executable instructions may take the form of programs, software, software modules, scripts, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as stand-alone programs or as modules, components, subroutines, or other units suitable for use in a computing environment.
[0251] As an example, computer-executable instructions may, but do not necessarily, correspond to files in a file system. They may be stored as part of a file that holds other programs or data, for example, in one or more scripts in a Hyper Text Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple co-located files (e.g., files that store one or more modules, subroutines, or code sections).
[0252] As an example, computer-executable instructions can be deployed to execute on a single electronic device, or on multiple electronic devices located at one location, or on multiple electronic devices distributed across multiple locations and interconnected via a communication network.
[0253] In summary, based on the motion information of the first virtual object, the movable distance of the first virtual object in the virtual scene is determined, thus limiting the activity range of the first virtual object and preventing it from exceeding the boundaries of the virtual scene. Based on the movable distance, the movable range of the first virtual object in the virtual scene is determined, thus improving the accuracy of determining the movable range of the first virtual object. A second virtual object within the movable range of the virtual scene is loaded, and the motion process of the first virtual object is physically simulated based on the loaded second virtual object. In this way, only virtual objects within the movable range need to be loaded for physical simulation, without loading all virtual objects in the virtual scene, thereby reducing resource waste and improving the efficiency of physical simulation.
[0254] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, and improvements made within the spirit and scope of this application are included within the scope of protection of this application.
Claims
1. A method for simulating virtual objects, characterized in that, The method includes: Retrieve the first virtual object in the virtual scene; Based on the motion information of the first virtual object, the movable distance of the first virtual object is determined; Based on the movable distance, the movable range of the first virtual object in the virtual scene is determined; Load the second virtual object within the movable range of the virtual scene; Based on the loaded second virtual object, a physical simulation is performed on the motion process of the first virtual object.
2. The method according to claim 1, characterized in that, The motion information includes the velocity and acceleration of the first virtual object during its motion. Determining the movable distance of the first virtual object based on its motion information includes: Obtain the motion duration of the first virtual object, and obtain a preset distance threshold for the first virtual object; In response to the fact that the direction of the velocity is consistent with the direction of the acceleration, the distance traveled by the first virtual object within the motion duration is determined based on the acceleration and the velocity; The sum of the movement distance and the distance threshold is determined as the movable distance of the first virtual object.
3. The method according to claim 1, characterized in that, The motion information includes the velocity and acceleration of the first virtual object during its motion. Determining the movable distance of the first virtual object based on its motion information includes: In response to the fact that the direction of the velocity is not consistent with the direction of the acceleration, two decomposition directions are obtained, the two decomposition directions being perpendicular to each other; For each of the decomposition directions, the velocity and the acceleration are decomposed according to the decomposition direction to obtain the decomposed velocity and the decomposed acceleration; Based on the decomposed velocity and the decomposed acceleration, the decomposition distance of the first virtual object in each decomposition direction is determined; The decomposition distances corresponding to the first virtual object in the two decomposition directions are determined as the movable distances of the first virtual object.
4. The method according to claim 3, characterized in that, The two decomposition directions are respectively the first direction and the second direction in the virtual scene. Determining the movable range of the first virtual object based on the movable distance includes: When the velocity direction is opposite to the acceleration direction, a regular shape is constructed based on the decomposition distances corresponding to the first virtual object in the two decomposition directions, wherein the velocity direction is the direction of the velocity after decomposition in the first direction, and the acceleration direction is the direction of the acceleration after decomposition in the first direction; Based on the speed and acceleration of the first virtual object during its movement, the motion trajectory of the first virtual object in the virtual scene is simulated. In the virtual scene, the area covered by the regular shape is determined, wherein the area includes the motion trajectory; The area is defined as the movable range of the first virtual object.
5. The method according to claim 4, characterized in that, The first decomposition distance is the decomposition distance of the first virtual object in the first direction, and the second decomposition distance is the decomposition distance of the first virtual object in the second direction. Determining the area covered by the regular shape in the virtual scene includes: During the simulation of the motion trajectory, the distance the first virtual object moves when its velocity after decomposition in the first direction is reduced to zero is determined; Obtain the first coordinate value of the first virtual object in the first direction and the second coordinate value in the second direction, and sum the first coordinate value and the movement distance to obtain the third coordinate value in the first direction; A first coordinate point and a second coordinate point are determined in the virtual scene. The coordinate value of the first coordinate point in the first direction is the third coordinate value. The coordinate value of the first coordinate point in the second direction is the second coordinate value. The coordinate value of the second coordinate point in the first direction is the difference between the third coordinate value and the first decomposition distance. The coordinate value of the second coordinate point in the second direction is the sum of the second coordinate value and the second decomposition distance. The first coordinate point is determined as the first vertex of the region, and the second coordinate point is determined as the second vertex of the region. The line connecting the first vertex and the second vertex is the diagonal of the region.
6. The method according to any one of claims 1-5, characterized in that, Determining the movable range of the first virtual object based on the movable distance includes: A set shape is obtained, and the set shape is scaled based on the movable distance to obtain the target shape; The region covered by the target shape is determined from the virtual scene, wherein the center point of the region coincides with the position of the first virtual object in the virtual scene; The area is defined as the movable range of the first virtual object.
7. The method according to any one of claims 1-5, characterized in that, When there are multiple movable ranges, loading the second virtual object within the movable range in the virtual scene includes: Determine the overlapping portion between any two of the said movable ranges; When one of the two movable ranges is the same as the corresponding overlapping portion, the movable range is deleted from the plurality of movable ranges to obtain the remaining movable ranges; Based on the overlapping portion, the remaining movable range is grouped to obtain a first group and at least one second group. The movable ranges included in the first group do not overlap with each other. Any movable range included in the second group overlaps with at least one other movable range. The other movable ranges are the movable ranges in the second group other than the aforementioned movable range. Load the second virtual object within the movable range of the first group; The second virtual objects within the movable range of the second group are loaded sequentially according to their order.
8. The method according to claim 7, characterized in that, The step of loading the second virtual objects within the movable range of the second group sequentially according to the loading order of the movable range in the second group includes: Load the second virtual object within the first movable range of the second group; Detect any second virtual object within the nth movable range in the second group and obtain the detection result; When the detection result indicates that the arbitrary second virtual object is to be loaded, the arbitrary second virtual object is loaded, where n is a positive integer that increases sequentially, 1 < n ≤ N, and N is the number of movable ranges in the second group.
9. The method according to any one of claims 1 to 6, characterized in that, When there are multiple movable ranges, loading the second virtual object within the movable range in the virtual scene includes: The positional relationship between any two of the movable ranges is verified to obtain the verification result. When the verification result indicates that one of the two movable ranges is contained within the other movable range, the one movable range is deleted from the plurality of movable ranges to obtain the remaining movable ranges; Based on the verification results, the remaining movable ranges are grouped to obtain a first group and at least one second group. The movable ranges included in the first group do not overlap with each other. Any movable range included in the second group overlaps with at least one other movable range. The other movable ranges are the movable ranges in the second group other than the aforementioned movable range. Load the second virtual object within the movable range of the first group; The second virtual objects within the movable range of the second group are loaded sequentially according to their order.
10. The method according to claim 9, characterized in that, Any two movable ranges include a first movable range and a second movable range, wherein the side length of the first movable range is greater than the side length of the second movable range. The step of verifying the positional relationship between any two movable ranges to obtain a verification result includes: Determine the difference between the side length of the first movable range and the side length of the second movable range, and determine the ratio of the difference to the side length of the first movable range as the first scaling ratio; Based on the first scaling ratio, the first movable range is scaled to obtain a first predicted range centered on the center point of the first movable range. When the center point of the second movable range is within the first prediction range, the verification result is determined as the first preset result, which indicates that the second movable range is included in the first movable range.
11. The method according to claim 10, characterized in that, The step of verifying the positional relationship between any two movable ranges to obtain the verification result includes: Determine the sum of the side lengths of the first movable range and the second movable range, and determine the ratio of the sum to the side length of the first movable range as the second scaling ratio; Based on the first scaling ratio, the first movable range is scaled to obtain a second predicted range centered on the center point of the first movable range. When the center point of the second movable range is outside the first predicted range but within the second predicted range, the verification result is determined as the second preset result. The second preset result indicates that the second movable range overlaps with the first movable range. When the center point of the second movable range is outside the second predicted range, the verification result is determined as the third preset result, which indicates that the second movable range does not overlap with the first movable range.
12. The method according to claim 1, characterized in that, The physical simulation of the motion process of the first virtual object based on the loaded second virtual object includes: In response to the first virtual object triggering a physical event against the loaded second virtual object during the simulation of the first virtual object's motion, the first virtual object updates its current motion information based on the attribute information of the loaded second virtual object to obtain the target motion information; Control the first virtual object to move according to the target motion information.
13. A device for simulating virtual objects, characterized in that, The device includes: The data acquisition module is used to acquire the first virtual object in the virtual scene; The range determination module is used to determine the movable distance of the first virtual object based on the motion information of the first virtual object; and to determine the movable range of the first virtual object in the virtual scene based on the movable distance. An object loading module is used to load a second virtual object within the movable range of the virtual scene. The physics simulation module is used to perform physical simulation of the motion process of the first virtual object based on the loaded second virtual object.
14. An electronic device, characterized in that, The electronic device includes: Memory is used to store executable instructions for a computer; A processor, when executing computer-executable instructions or computer programs stored in the memory, implements the simulation method of the virtual object according to any one of claims 1 to 12.
15. A computer-readable storage medium storing computer-executable instructions or a computer program, characterized in that, When the computer-executable instructions or computer program are executed by a processor, they implement the simulation method of the virtual object according to any one of claims 1 to 12.
16. A computer program product comprising computer-executable instructions or a computer program, characterized in that, When the computer-executable instructions or computer program are executed by a processor, they implement the simulation method of the virtual object according to any one of claims 1 to 12.
