Method, apparatus, device and storage medium for loading virtual objects in a virtual scene

By dividing the virtual objects in the virtual scene into multiple sets and using multiple threads to perform loading tasks, the main thread's lag problem when loading a large number of virtual objects is solved, and more efficient virtual object loading is achieved.

CN114489987BActive Publication Date: 2025-05-30TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210104541.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-28
Publication Date
2025-05-30
Estimated Expiration
2042-01-28

AI Technical Summary

Technical Problem

When a large number of virtual objects are loaded dynamically in a virtual scene, the main thread consumes a lot of computing resources and time, resulting in lag in running and affecting the normal operation of the game.

Method used

By dividing multiple virtual objects into multiple virtual objects collections and creating corresponding loading tasks, multiple threads perform these loading tasks separately, thereby optimizing the loading process of virtual objects.

Benefits of technology

By loading virtual objects asynchronously, the burden on the main thread is reduced, the loading efficiency of virtual objects is improved, and the operation is reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114489987B_ABST
    Figure CN114489987B_ABST
Patent Text Reader

Abstract

The present application discloses a method, apparatus, device, and storage medium for loading virtual objects in a virtual scene, belonging to the field of computer technology. Through the technical solution provided by the embodiments of the present application, in response to a loading instruction for a virtual scene, the multiple virtual objects are divided into multiple virtual object sets, and subsequently, the virtual objects can be loaded into the virtual scene in units of virtual object sets. Multiple loading tasks corresponding to the multiple virtual object sets are created, and the multiple loading tasks are respectively executed by multiple threads, thereby optimizing the synchronous loading of virtual objects into asynchronous loading and improving the loading efficiency of virtual objects. At the same time, the process of loading virtual objects into the virtual scene does not require the main thread to execute, reducing the situation of running jams.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and particularly to a method, apparatus, device, and storage medium for loading virtual objects in a virtual scene. Background Art

[0002] With the development of multimedia technology and the diversification of terminal functions, there are more and more types of games that can be played on terminals. Role-playing games are a relatively popular type of game. Role-playing games provide players with a virtual scene, and players can control game characters to perform various operations in the virtual scene. The virtual scene includes multiple virtual objects. For example, the virtual objects are virtual houses, virtual grasslands, and virtual trees in the virtual scene. To save computing resources, the server does not load all virtual objects in the virtual scene at once, but dynamically adds virtual objects to the virtual scene, that is, when the player controls the game character to meet certain conditions, the virtual objects will be gradually loaded.

[0003] In the related art, dynamically adding virtual objects to the virtual scene is completed by the main thread. In addition to dynamically adding virtual objects to the virtual scene, the main thread also needs to handle other affairs in the game, such as controlling game characters to fight with other game characters in the virtual scene based on the player's operations, or building virtual houses in the virtual scene.

[0004] However, when the number of virtual objects dynamically loaded into the virtual scene is relatively large, the main thread needs to consume a large amount of computing resources and time, which easily causes running lags and affects the normal operation of the game. Summary of the Invention

[0005] Embodiments of this application provide a method, apparatus, device, and storage medium for loading virtual objects in a virtual scene, which can alleviate the situation of running lags. The technical solutions are as follows:

[0006] On the one hand, a method for loading virtual objects in a virtual scene is provided. The method includes:

[0007] In response to a loading instruction for a virtual scene including multiple virtual objects, determining multiple virtual object sets, where the virtual object sets include at least one of the virtual objects;

[0008] Creating multiple loading tasks corresponding to the multiple virtual object sets, where the loading tasks are used to load the virtual objects in the virtual object sets into the virtual scene;

[0009] Invoking multiple threads to respectively execute the multiple loading tasks to load the multiple virtual objects into the virtual scene.

[0010] On the one hand, a loading device for virtual objects in a virtual scene is provided. The device includes:

[0011] A set determination module, configured to determine multiple virtual object sets in response to a loading instruction for a virtual scene including multiple virtual objects. The virtual object sets include at least one of the virtual objects;

[0012] A task creation module, configured to create multiple loading tasks corresponding to the multiple virtual object sets. The loading tasks are used to load the virtual objects in the virtual object sets into the virtual scene;

[0013] A thread invocation module, configured to invoke multiple threads to respectively execute the multiple loading tasks and load the multiple virtual objects into the virtual scene.

[0014] In a possible implementation manner, the set determination module is configured to perform any one of the following:

[0015] In response to a loading instruction for a virtual scene, determine the multiple virtual object sets based on a preset number of objects;

[0016] In response to a loading instruction for a virtual scene, determine the multiple virtual object sets based on a preset number of sets;

[0017] In response to a loading instruction for a virtual scene, determine the multiple virtual object sets based on the number of threads;

[0018] In response to a loading instruction for a virtual scene, determine the multiple virtual object sets based on the types of the multiple virtual objects;

[0019] In response to a loading instruction for a virtual scene, determine the multiple virtual object sets based on the storage space occupied by the multiple virtual objects.

[0020] In a possible implementation manner, the triggering manner of the loading instruction includes any one of the following:

[0021] A target virtual object moves to a target position in the virtual scene;

[0022] The target virtual object executes a target virtual task in the virtual scene;

[0023] The target virtual object enters the virtual scene.

[0024] In a possible implementation manner, the method for determining the preset number of sets includes:

[0025] Obtain multiple candidate set numbers corresponding to a sample virtual scene. The sample virtual scene includes multiple sample virtual objects to be loaded;

[0026] For any one of the multiple candidate set quantities, based on the candidate set quantity, divide the multiple sample virtual objects into multiple sample virtual object sets;

[0027] Determine the loading time consumed by the multiple threads, where the loading time is the time consumed to load the sample virtual objects in the multiple sample virtual object sets into the sample virtual scene;

[0028] Determine the target candidate set quantity as the preset set quantity, where the target candidate set quantity is the candidate set quantity that meets the target condition among the multiple candidate set quantities.

[0029] In a possible implementation manner, the set determination module is configured to determine the quantity of the virtual object sets as the target quantity, where the target quantity is N times the quantity of the threads, and N is a positive integer; divide the multiple virtual objects into the multiple virtual object sets of the target quantity.

[0030] In a possible implementation manner, the set determination module is configured to divide the virtual objects of the same type among the multiple virtual objects into the same virtual object set.

[0031] In a possible implementation manner, the set determination module is configured to divide multiple target virtual objects among the multiple virtual objects into one virtual object set, where the sum of the storage spaces occupied by the multiple target virtual objects is less than or equal to the target threshold.

[0032] In a possible implementation manner, the task creation module is configured to create multiple loading tasks corresponding to the multiple virtual object sets in the task queue;

[0033] The thread calling module is configured to respectively obtain the corresponding loading tasks from the task queue by the multiple threads; respectively execute the loading tasks obtained from the task queue by the multiple threads to load the multiple virtual objects into the virtual scene.

[0034] In a possible implementation manner, the device further includes:

[0035] The dequeue module is configured to, when any loading task in the task queue is executed by the multiple threads, perform a dequeue operation on the loading task by the main thread.

[0036] In a possible implementation manner, the device is applied to a server, and the device further includes:

[0037] A thread creation module, configured to create the multiple threads based on the configuration information of the server, where the configuration information is used to indicate the computing power of the server, and the number of the threads is positively correlated with the computing power of the server.

[0038] In a possible implementation manner, the apparatus further includes:

[0039] A thread creation module, configured to create the multiple threads based on the number of the virtual objects, where the number of the threads is positively correlated with the number of the virtual objects.

[0040] On the one hand, a computer device is provided, which includes one or more processors and one or more memories. At least one computer program is stored in the one or more memories, and the computer program is loaded and executed by the one or more processors to implement the method for loading virtual objects in the virtual scene.

[0041] On the one hand, a computer-readable storage medium is provided, in which at least one computer program is stored, and the computer program is loaded and executed by a processor to implement the method for loading virtual objects in the virtual scene.

[0042] On the one hand, a computer program product or a computer program is provided. The computer program product or the computer program includes program code, the program code is stored in a computer-readable storage medium, a processor of a computer device reads the program code from the computer-readable storage medium, and the processor executes the program code, so that the computer device executes the method for loading virtual objects in the virtual scene as described above.

[0043] Through the technical solution provided by the embodiments of the present application, in response to a loading instruction for a virtual scene, the multiple virtual objects are divided into multiple virtual object sets, and subsequently, the virtual objects can be loaded into the virtual scene in units of the virtual object sets. Multiple loading tasks corresponding to the multiple virtual object sets are created, and the multiple loading tasks are respectively executed by multiple threads, so as to optimize the synchronous loading of virtual objects into asynchronous loading, and improve the loading efficiency of virtual objects. At the same time, the main thread does not need to execute during the process of loading virtual objects into the virtual scene, reducing the situation of running jams. Description of the Drawings

[0044] To more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0045] Figure 1It is a schematic diagram of the implementation environment of a method for loading virtual objects in a virtual scene provided by an embodiment of the present application;

[0046] Figure 2 It is a flowchart of a method for loading virtual objects in a virtual scene provided by an embodiment of the present application;

[0047] Figure 3 It is a flowchart of a method for loading virtual objects in a virtual scene provided by an embodiment of the present application;

[0048] Figure 4 It is a schematic structural diagram of a thread model provided by an embodiment of the present application;

[0049] Figure 5 It is a flowchart of a method for loading virtual objects in a virtual scene provided by an embodiment of the present application;

[0050] Figure 6 It is a flowchart of a method for loading virtual objects in a virtual scene provided by an embodiment of the present application;

[0051] Figure 7 It is a bar chart showing the average loading duration provided by an embodiment of the present application;

[0052] Figure 8 It is a bar chart showing the average waiting duration provided by an embodiment of the present application;

[0053] Figure 9 It is a schematic structural diagram of a device for loading virtual objects in a virtual scene provided by an embodiment of the present application;

[0054] Figure 10 It is a schematic structural diagram of a server provided by an embodiment of the present application. Detailed implementation manners

[0055] To make the objectives, technical solutions, and advantages of the present application clearer, the following will further describe the embodiments of the present application in detail with reference to the accompanying drawings.

[0056] In the present application, terms such as "first" and "second" are used to distinguish identical or similar items with basically the same functions and effects. It should be understood that there is no logical or temporal dependency between "first", "second", and "nth", nor are the quantity and execution order limited.

[0057] The following introduces the nouns involved in the embodiments of the present application.

[0058] Virtual scene: It is a virtual scene displayed (or provided) when the application runs on the terminal. The virtual scene can be a simulation environment of the real world, a semi-simulated and semi-fictional virtual environment, or a purely fictional virtual environment. The virtual scene can be any one of a two-dimensional virtual scene, a 2.5D virtual scene, or a three-dimensional virtual scene. The embodiments of the present application do not limit the dimension of the virtual scene. For example, the virtual scene can include the sky, land, ocean, etc. The land can include environmental elements such as deserts and cities. Users can control virtual objects to move in the virtual scene.

[0059] Virtual object: It refers to an active object in the virtual scene. The active object can be a virtual character, a virtual animal, an anime character, etc. For example, the characters, animals, plants, oil drums, walls, stones, etc. displayed in the virtual scene. The virtual object can be a virtual image in the virtual scene used to represent the user. The virtual scene can include multiple virtual objects, and each virtual object has its own shape and volume in the virtual scene and occupies a part of the space in the virtual scene.

[0060] Optionally, the virtual object can be a user role controlled by operations on the client, or an artificial intelligence (AI) set in the virtual scene battle through training, or a non-player character (NPC) set in the virtual scene interaction. Optionally, the virtual object can be a virtual character competing in the virtual scene. Optionally, the number of virtual objects participating in the interaction in the virtual scene can be preset or dynamically determined according to the number of clients joining the interaction.

[0061] Massive (or Massively) Multiplayer Online Role-Playing Game (MMORPG): It is a type of online game. In all role-playing games, players have to play a virtual role and control many activities of the role.

[0062] In an MMPRPG, users can control virtual objects to run, jump, crawl, bend forward, etc. on land, or control virtual objects to swim, float, or dive in the ocean. Of course, users can also control virtual objects to move in the virtual scene by taking virtual vehicles. For example, the virtual vehicle can be a virtual horse, a virtual boat, a virtual carriage, etc. Here, only the above scenarios are used for illustration, and the embodiments of the present application do not make specific limitations in this regard. Users can also control virtual objects to interact with other virtual objects through interactive props in ways such as combat. For example, the interactive prop can be a throwing interactive prop such as a spear, a stone, a torch, etc., or a shooting interactive prop such as a bow and arrow, a slingshot, etc. The present application does not make specific limitations on the types of interactive props.

[0063] Seamless large world: Different from traditional virtual scenes in the virtual scene. The scope of traditional virtual scenes is small, and a continuous game space is made into multiple virtual scenes, and virtual scene switching requires loading virtual scenes. The seamless large world has a large scope, and a continuous game space is represented by a large virtual scene, and no virtual scene needs to be loaded when moving within the large virtual scene.

[0064] Dungeon: Also known as a game dungeon, a dungeon is a form of combat in large games where tasks can be completed and leveling can be done, and it can be used multiple times.

[0065] Figure 1 It is a schematic diagram of the implementation environment of a method for loading virtual objects in a virtual scene provided by an embodiment of the present application. Refer to Figure 1 In this implementation environment, a terminal 110 and a server 140 can be included.

[0066] The terminal 110 is connected to the server 140 through a wireless network or a wired network. Optionally, the terminal 110 is a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart watch, etc., but is not limited thereto. The terminal 110 installs and runs an application program that supports virtual scene display. Optionally, the application program is any one of MMPRPG, Role - Play Game (RPG), and Education Simulation (ES). The terminal 110 is the terminal used by the first user, and the first user uses the terminal 110 to operate the first virtual object located in the virtual scene for activities, and the activities include but are not limited to at least one of adjusting body posture, crawling, walking, running, riding, jumping, picking up, shooting, attacking, and throwing.

[0067] The server 140 is an independent physical server, or 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 communications, middleware services, domain name services, security services, content delivery network (CDN), and big data and artificial intelligence platforms. In some embodiments, the server 140 provides background services for the application programs running on the terminal 110.

[0068] Those skilled in the art can know that the number of the above-mentioned terminals 110 can be more or less. For example, the above-mentioned terminal is only one, or the above-mentioned terminals are dozens or hundreds, or a larger number. At this time, other terminals are also included in the above-mentioned implementation environment. The embodiments of the present application do not limit the number and device types of the terminals.

[0069] After introducing the implementation environment of the technical solution provided by the present application, the application scenarios of the technical solution provided by the embodiments of the present application will be introduced below. In the following description process, the terminal is also the terminal 110 in the above-mentioned implementation environment, and the server is also the server 140 in the above-mentioned implementation environment.

[0070] The technical solution provided by the embodiments of the present application can be applied to various games. For example, it can be applied to games such as MMPRPG, RPG, or ES.

[0071] Taking the application of the technical solution provided by the embodiments of the present application in MMORPG as an example. In MMORPG, players can control the target virtual object to move freely in the virtual scene, and the target virtual object is also the game character controlled by the player. Since the movable range of the virtual scene provided by MMORPG is often large, in order to save computing resources, during the process of the user playing the game through the terminal, for the virtual objects in the virtual scene that have not interacted with the target virtual object, the server will not pre-load these virtual objects in the virtual scene, but will dynamically load these virtual objects when the target virtual object meets certain conditions in the virtual scene. After adopting the technical solution provided by the embodiments of the present application, these virtual objects are the multiple virtual objects to be loaded. The server can divide the multiple virtual objects into multiple virtual object sets and create multiple loading tasks corresponding to the multiple virtual object sets respectively. The server calls multiple threads to execute the multiple loading tasks respectively to achieve the purpose of loading the multiple virtual objects into the virtual scene. For example, the multiple virtual objects include virtual houses, virtual grasslands, virtual stones, and virtual trees in the virtual scene. Then when the server loads the multiple virtual objects, it can adopt the technical solution provided by the embodiments of the present application to load the virtual objects such as the above-mentioned virtual houses, virtual grasslands, virtual stones, and virtual trees into the virtual scene.

[0072] It should be noted that the above description is given by taking the technical solution provided in the embodiments of this application applied to MMORPG as an example. When the technical solution provided in the embodiments of this application is applied to other games such as RPG or ES, the server applying the technical solution provided in the embodiments of this application belongs to the same inventive concept as the above description, and will not be elaborated here.

[0073] After introducing the implementation environment and application scenarios of the embodiments of this application, the technical solutions provided in the embodiments of this application will be described below. Refer to Figure 2 , taking the execution entity as the server as an example, the method includes:

[0074] 201. In response to a loading instruction for a virtual scene, the server determines a plurality of virtual object sets. The virtual scene includes a plurality of virtual objects to be loaded, and the virtual object set includes at least one of the virtual objects.

[0075] Among them, the virtual scene is a game scene, such as a game scene of MMORPG. The plurality of virtual objects are virtual objects to be loaded in the virtual scene. The loading instruction is used to instruct the server to load the plurality of virtual objects in the virtual scene. The virtual object set is a set composed of the virtual objects to be loaded. In the subsequent loading process, the server loads the virtual objects in the virtual scene in units of the virtual object set. In some embodiments, the server is also referred to as a game logic server (GameSvr), which is responsible for creating the virtual scene and the basic gameplay logic of the game.

[0076] 202. The server creates a plurality of loading tasks corresponding to the plurality of virtual object sets. The loading task is used to load the virtual objects in the virtual object set into the virtual scene.

[0077] Among them, the loading task is a task of loading virtual objects in the virtual scene. The virtual object set and the loading task are in one-to-one correspondence. Executing a loading task means loading the virtual objects in the virtual object set corresponding to the loading task into the virtual scene.

[0078] 203. The server calls a plurality of threads to execute the plurality of loading tasks respectively, and loads the plurality of virtual objects into the virtual scene.

[0079] Among them, the multiple threads are threads other than the main thread, which are used to execute loading tasks to load virtual objects into the virtual scene. The main thread is used to execute tasks other than loading virtual objects into the virtual scene, such as performing logical judgments in the game. The multiple threads and the main thread both belong to the threads under the process corresponding to the virtual scene. The process corresponding to the virtual scene runs on the server. Correspondingly, the multiple threads and the main thread also run on the server. In some embodiments, the thread is also referred to as a loading thread.

[0080] Through the technical solution provided by the embodiments of the present application, in response to a loading instruction for a virtual scene, the multiple virtual objects are divided into multiple virtual object sets, and subsequently, the virtual objects can be loaded into the virtual scene in units of virtual object sets. Create multiple loading tasks corresponding to the multiple virtual object sets, and the multiple threads respectively execute the multiple loading tasks, thereby optimizing the synchronous loading of virtual objects into asynchronous loading and improving the loading efficiency of virtual objects. At the same time, the main thread does not need to execute during the process of loading virtual objects into the virtual scene, reducing the situation of running jams.

[0081] The above steps 201-203 are a simple introduction to the technical solution provided by the embodiments of the present application. Below, through some examples, the technical solution provided by the embodiments of the present application will be described more clearly. Refer to Figure 3 , the method includes:

[0082] 301. In response to a loading instruction for a virtual scene, the server determines multiple virtual object sets. The virtual scene includes multiple virtual objects to be loaded, and a virtual object set includes at least one virtual object.

[0083] Among them, the loading instruction is used to instruct the server to load virtual objects in the virtual scene. In some embodiments, the loading instruction carries the identifiers of multiple virtual objects, and the server can determine the multiple virtual objects to be loaded based on the identifiers of the multiple virtual objects. The multiple virtual object sets are obtained by the server partitioning the multiple virtual objects, and each virtual object includes at least one virtual object to be loaded. In some embodiments, the virtual object is also referred to as a PhysX Actor, and the PhysX Actor includes types such as Rigid Body, Particle, Cloth, Character, and Vehicle. Usually, the server needs to load only the Rigid Body and Vehicle types. From another perspective, the PhysX Actor includes a Shape, and the Shape is composed of a Material and a Geometry. The Material indicates the surface friction and elastic coefficient of the physical body, and the Geometry indicates the spatial geometric shape of the physical body. The main types of Geometry are sphere, capsule, rectangle, plane, convex polygon face, triangle face, and height map. In some embodiments, the virtual object set is also referred to as an Actor list.

[0084] To more clearly illustrate step 301 above, the triggering methods of the loading instruction will be introduced below. In some embodiments, the triggering methods of the loading instruction include any of the following:

[0085] Method 1: The target virtual object moves to a target position in the virtual scene.

[0086] That is, in response to the target virtual object moving to a target position in the virtual scene, the server triggers the loading instruction. In this way, when the target virtual object moves to the target position in the virtual scene, the server can trigger the loading instruction.

[0087] Among them, the target virtual object is the virtual object controlled by the terminal, and the process of the target virtual object moving to the target position is also manipulated by the player through the terminal; the target position is a position preset by the technician in the virtual scene. In this case, the multiple virtual objects to be loaded are the virtual objects corresponding to the target position.

[0088] In some embodiments, the virtual scene includes a plurality of sub-regions, and different sub-regions correspond to different positions in the virtual scene. In this case, the target position is the junction position between two sub-regions in the virtual scene. For example, the virtual scene includes sub-region A and sub-region B, and the target position is the junction position between sub-region A and sub-region B. In response to the target virtual object moving to the target position, the server triggers the loading instruction, and the loading instruction is used to load the virtual objects in the sub-region that the target virtual object has not entered yet. When the target virtual object moves from sub-region A to sub-region B, the plurality of virtual objects to be loaded are the virtual objects in sub-region B; when the target virtual object moves from sub-region B to sub-region A, the plurality of virtual objects to be loaded are the virtual objects in sub-region A.

[0089] In some embodiments, the target position is associated with the position of the target virtual object in the virtual scene, that is, the target position changes as the position of the target virtual object in the virtual scene changes. During the movement of the target virtual object, the target position will change accordingly. In this case, since the player only focuses on the virtual objects around the target virtual object when controlling the movement of the target virtual object through the terminal, the server can load the virtual objects within the target range around the target virtual object in the virtual scene and does not load the virtual objects outside the target range. This can reduce the amount of computation and save computing resources. Among them, the size of the target range is set by technicians according to the actual situation. For example, it is set based on the computing power of the server, and the target range is set to be positively correlated with the computing power. For example, if the computing power of the server is weak, then the target range can be set to be small; if the computing power of the server is weak, then the target range can be set to be small. In some embodiments, the number of target positions is multiple, and the distance between the target position and the target virtual object is a target value. When the target virtual object moves to any target position, the server triggers the loading instruction based on the target position, and the loading instruction is used to instruct the server to load the virtual objects within the current target range corresponding to the target virtual object. In addition, when the target virtual object moves to any target position, the server re-determines the target position based on the current position of the target virtual object in the virtual scene.

[0090] In some embodiments, the target position is a virtual teleport point in the virtual scene, and the virtual teleport point is used to teleport the target virtual object to a specified position in the virtual scene. When the player wants to move the target virtual object to the specified position in the virtual scene, the target virtual object can be controlled to move to the corresponding virtual teleport point in the virtual scene. In this case, in response to the target virtual object moving to the virtual teleport point corresponding to the virtual task, the server triggers the loading instruction, and the loading instruction is used to load a plurality of virtual objects at the position corresponding to the virtual teleport point.

[0091] Method 2: The target virtual object performs a target virtual task in the virtual scene.

[0092] Among them, performing the target task includes performing the target virtual task and completing the target virtual task.

[0093] That is, in response to the target virtual object performing the target virtual task in the virtual scene, the server triggers the loading instruction. In this way, the server can trigger the loading instruction when the target virtual object completes the target virtual task in the virtual scene.

[0094] Among them, the target virtual task is a virtual task provided in the virtual scene. When the target virtual object completes the target virtual task, it can obtain corresponding virtual rewards. In some embodiments, the virtual rewards are virtual resources or virtual props in the virtual scene, etc. In this case, the plurality of virtual objects to be loaded are the virtual objects corresponding to the target virtual task. In some embodiments, the virtual objects corresponding to the target virtual task refer to the virtual objects that need to be loaded into the virtual scene after completing the target virtual task. For example, the target virtual task is to collect a certain number of virtual flowers in the virtual scene and plant the collected virtual flowers at the task position in the virtual scene. Then, when the target virtual object completes the target virtual task, the virtual objects corresponding to the target virtual task refer to the virtual flowers to be loaded at the task position. Correspondingly, the loading instruction is used to instruct the server to load a plurality of virtual flowers at the task position. In some embodiments, the virtual objects corresponding to the target virtual task refer to the virtual objects that need to be loaded into the virtual scene when performing the target virtual task. For example, the target virtual task is to collect a certain number of virtual flowers in the virtual scene and plant the collected virtual flowers at the task position in the virtual scene. Then, when the target virtual object receives the target virtual task, the virtual objects corresponding to the target virtual task refer to the virtual flower bed to be loaded into the virtual scene and the virtual flowers in the virtual flower bed. Correspondingly, the loading instruction is used to instruct the server to load the virtual flower bed and the virtual flowers in the virtual flower bed in the virtual scene.

[0095] Mode 3: The target virtual object enters the virtual scene.

[0096] That is, in response to the target virtual object entering the virtual scene, the server triggers the loading instruction. In this mode, the server can trigger the loading instruction when the target virtual object enters the virtual scene target.

[0097] In some embodiments, the game includes multiple virtual scenes that are independent of each other, and the virtual scene is one of the multiple virtual scenes. During the game process, the target virtual object can freely switch between the multiple virtual scenes. In some embodiments, the virtual scene is also referred to as a PhysXScene, and the PhysXScene usually corresponds to a dungeon in the game. The target virtual object entering different virtual scenes is equivalent to entering different dungeons.

[0098] After introducing the triggering methods of the loading instruction, the method for the server to determine multiple virtual object sets will be introduced below.

[0099] In a possible implementation, in response to the loading instruction for the virtual scene, the server determines the multiple virtual object sets based on a preset number of objects.

[0100] Among them, the preset number of objects is the number of virtual objects in a single virtual object set, and is also referred to as the batching number.

[0101] To illustrate the above implementation more clearly, the method for determining the preset number of objects will be described first.

[0102] In a possible implementation, the server obtains multiple candidate object numbers corresponding to the sample virtual scene, and the sample virtual scene includes multiple sample virtual objects to be loaded. For any candidate object number among the multiple candidate object numbers, the server divides the multiple sample virtual objects into multiple sample virtual object sets based on the candidate object number, and the number of sample virtual objects in each sample virtual object set is the candidate object number. The server determines the loading time consumed to load the multiple sample object sets through the multiple threads, and the loading time is the time consumed to load the sample virtual objects in the multiple sample virtual object sets into the sample virtual scene. The server determines the target candidate object number as the preset number of objects, and the target candidate object number is the candidate object number that meets the target condition among the multiple candidate object numbers.

[0103] Among them, the sample virtual scenario is the virtual scenario during the test process, and the number of candidate objects is also the number of sample virtual objects in the sample virtual object set. Multiple numbers of candidate objects indicate multiple partitioning methods. After partitioning the sample virtual objects using different partitioning methods, the number of sample virtual objects in the obtained sample object set is different. The loading time consumption refers to the time consumed to load all the multiple sample virtual objects into the sample virtual scenario using multiple threads.

[0104] In this implementation manner, the server can determine the target number of candidate objects by loading the sample virtual objects in the sample virtual scenario. The determined target number of candidate objects is also the most suitable number of objects. Using the target number of candidate objects as the preset number of objects can reduce the loading time consumption when loading virtual objects using the multiple threads.

[0105] For example, the server obtains multiple numbers of candidate objects corresponding to the sample virtual scenario, and the sample virtual scenario includes multiple sample virtual objects to be loaded. For any number of candidate objects among the multiple numbers of candidate objects, the server partitions the multiple sample virtual objects into multiple sample virtual object sets based on the number of candidate objects, and the number of the sample virtual object sets is the number of candidate objects. The server creates multiple loading tasks corresponding to the multiple sample virtual object sets, calls the multiple threads to execute the multiple loading tasks, and loads the sample virtual objects in the multiple sample virtual object sets into the sample virtual scenario. The server determines the loading time consumption corresponding to the number of candidate objects, and the loading time consumption is also the time consumed from when the server calls the multiple threads to start executing the multiple loading tasks to when the multiple loading tasks are completed. The server repeats the above steps to determine multiple loading time consumptions corresponding to the multiple numbers of candidate objects respectively. The server determines the number of candidate objects with the shortest loading time consumption among the multiple numbers of candidate objects as the target number of candidate objects, and the target number of candidate objects is the preset number of objects.

[0106] After explaining the method for determining the preset number of objects, the above implementation manner will be further described below.

[0107] For example, in response to a loading instruction for a virtual scenario, the server partitions the multiple virtual objects into multiple virtual object sets, and the number of the virtual object sets is the preset number of objects. That is, for the multiple virtual objects, the server partitions every preset number of virtual objects into a virtual object set, and so on, to obtain multiple virtual object sets.

[0108] In a possible implementation manner, in response to a loading instruction for a virtual scenario, the server determines the multiple virtual object sets based on a preset number of sets.

[0109] Among them, the preset number of sets is also the number of virtual object sets determined by the server.

[0110] To illustrate the above embodiments, the method for determining the preset number of sets is as follows:

[0111] In a possible implementation, the server obtains multiple candidate numbers of sets corresponding to a sample virtual scene, and the sample virtual scene includes multiple sample virtual objects to be loaded. For any candidate number of sets among the multiple candidate numbers of sets, the server divides the multiple sample virtual objects into multiple sample virtual object sets based on the candidate number of sets. The server determines the loading time consumed by the multiple threads, and the loading time is the time consumed to load the sample virtual objects in the multiple sample virtual object sets into the sample virtual scene. The server determines the target candidate number of sets as the preset number of sets, and the target candidate number of sets is the candidate number of sets that meets the target condition among the multiple candidate numbers of sets.

[0112] Among them, the sample virtual scene is a virtual scene during the testing process, the candidate number of sets is also the number of sample virtual object sets into which the sample virtual objects are divided, and the multiple candidate numbers of sets mean that there are multiple partitioning methods. After partitioning the sample virtual objects using different partitioning methods, the number of sample virtual objects in the obtained sample object sets is different. Of course, the number of sample virtual object sets is also different. The loading time refers to the time consumed to load all the multiple sample virtual objects into the sample virtual scene using multiple threads.

[0113] In this implementation, the server can determine the target candidate number of sets by loading sample virtual objects in the sample virtual scene. The determined target candidate number of sets is also the most suitable number of sets. Using the target candidate number of sets as the preset number of sets can reduce the loading time when loading virtual objects using the multiple threads.

[0114] For example, the server obtains the number of multiple candidate sets corresponding to the sample virtual scene, and the sample virtual scene includes multiple sample virtual objects to be loaded. For any candidate set number among the multiple candidate set numbers, the server divides the multiple sample virtual objects into multiple sample virtual object sets based on the candidate set number, and the number of the sample virtual object sets is the candidate set number. The server creates multiple loading tasks corresponding to the multiple sample virtual object sets, invokes the multiple threads to execute the multiple loading tasks, and loads the sample virtual objects in the multiple sample virtual object sets into the sample virtual scene. The server determines the loading time corresponding to the candidate set number, and the loading time is also the time consumed by the server to start invoking the multiple threads to execute the multiple loading tasks until the multiple loading tasks are completed. The server repeats the above steps to determine the multiple loading times corresponding to the multiple candidate set numbers respectively. The server determines the candidate set number with the shortest loading time among the multiple candidate set numbers as the target candidate set number, and the target candidate set number is the preset set number.

[0115] After the method for determining the preset set number is described, the above embodiments will be further described below.

[0116] For example, in response to a loading instruction for a virtual scene, the server divides the multiple virtual objects into multiple virtual object sets, and the number of the virtual object sets is the preset set number. In some embodiments, when the server divides the multiple virtual objects into multiple virtual object sets, an average division method is adopted, and the average division is to try to ensure that the number of virtual objects in the multiple virtual object sets is the same. Since the preset set number is determined in advance, the server can generate the preset number of empty sets, and fill the multiple virtual objects into the preset number of empty sets in sequence to obtain multiple virtual object sets. In some embodiments, the process of dividing multiple virtual objects into multiple virtual object sets is also referred to as batching the multiple virtual objects to obtain multiple virtual object sets.

[0117] In a possible implementation manner, in response to a loading instruction for a virtual scene, the server determines the multiple virtual object sets based on the number of the threads. It should be noted that this implementation manner is executed when the server has created the multiple threads in advance.

[0118] In this implementation manner, the server can determine the number of virtual object sets according to the number of threads, which helps to improve the efficiency of loading virtual objects by threads subsequently.

[0119] Among them, the multiple threads are loading threads running on the server. To illustrate the above embodiments more clearly, the thread model on the server will be introduced first below.

[0120] In some embodiments, a target process corresponding to a target application runs on the server. Under this target process, there are a main thread, a simulation thread, a loading thread, and a destruction thread. Among them, the target application is a game application, and the target process is also the process corresponding to the game application. The main thread refers to the main logic thread of the game server, which is used to process the gameplay logic in the game, such as judging the completion of virtual tasks in the game and judging the hit of virtual skills in the game, etc. The simulation thread is the simulation thread of the physical engine used by the game, which is used to perform simulation calculations on the virtual scene, that is, to perform simulation calculations on the virtual objects in the virtual scene, so that multiple virtual objects are correctly placed in the virtual scene. The loading thread is also the thread in the above embodiment, which is used to load virtual objects into the virtual scene. Through multiple loading threads, the synchronous loading of virtual objects can be optimized to asynchronous loading. The destruction thread is used to destroy the simulation thread or the loading thread. For example, see Figure 4 , a schematic diagram of the thread model on the server is provided. In Figure 4 , it includes a main thread 401, four simulation threads 402, four loading threads 403, and a destruction thread 404. It should be noted that Figure 4 The number of threads shown in is only taken as an example, and it can be set according to the actual situation during operation. The embodiments of the present application do not limit this.

[0121] After introducing the thread model on the server, the above embodiments will be further described below.

[0122] For example, the server determines the number of the virtual object sets as the target number, and the target number is N times the number of threads, where N is a positive integer. The server divides the multiple virtual objects into the multiple virtual object sets of the target number. In some embodiments, when the server divides the multiple virtual objects into multiple virtual object sets, an average division method is adopted, and the average division is to try to ensure that the number of virtual objects in the multiple virtual object sets is the same. Since the target number is determined in advance, the server can generate the target number of empty sets, and fill the multiple virtual objects into the target number of empty sets in turn to obtain multiple virtual object sets.

[0123] In a possible implementation manner, in response to a loading instruction for the virtual scene, the server determines the multiple virtual object sets based on the types of the multiple virtual objects.

[0124] Among them, virtual objects can be classified into different types according to different classification methods. For example, classified by function, virtual objects can be divided into five types: Rigid Body, Particle, Cloth, Character, and Vehicle. Classified by geometric shape, virtual objects can be divided into types such as spheres, cubes, and cuboids. Classified by display form, virtual objects can be divided into types such as characters, animals, buildings, obstacles, and decorations. The embodiments of the present application do not limit the types of virtual objects.

[0125] For example, the server divides virtual objects of the same type among the multiple virtual objects into the same virtual object set. In this case, the number of obtained virtual object sets is the same as the number of types of the multiple virtual objects.

[0126] In a possible implementation manner, in response to a loading instruction for a virtual scene, the server determines the multiple virtual object sets based on the storage space occupied by the multiple virtual objects.

[0127] Among them, the storage space occupied by a virtual object refers to the storage space occupied by the loading file corresponding to the virtual object on the server's memory.

[0128] In this implementation manner, since the storage space occupied by a virtual object is often positively correlated with the time consumed to load the virtual object, that is, the larger the storage space occupied by a virtual object, the longer the time consumed to load the virtual object; the smaller the storage space occupied by a virtual object, the shorter the time consumed to load the virtual object. By dividing virtual object sets based on the storage space occupied by virtual objects, the advantages of multi-threading can be maximally utilized in the subsequent process to improve the loading efficiency of virtual objects.

[0129] For example, the server divides multiple target virtual objects among the multiple virtual objects into one virtual object set, and the sum of the storage spaces occupied by the multiple target virtual objects is less than or equal to a target threshold.

[0130] Among them, the target threshold is set by technicians according to the actual situation, for example, determined based on the computing power and the number of threads of the server. The embodiments of the present application do not limit this.

[0131] For example, the server determines the occupied spaces of the multiple virtual objects, combines the multiple virtual objects with the target threshold as the upper limit, and obtains the multiple virtual object sets.

[0132] 302. The server creates multiple threads, and the multiple threads are used to execute the loading tasks of loading virtual objects into the virtual scene.

[0133] It should be noted that the above step 302 can be executed either after the above step 301 or before the above step 301. The embodiments of the present application do not make any limitations in this regard. In the embodiments of the present application, taking the execution of this step after step 301 as an example for illustration.

[0134] In a possible implementation manner, the server creates the multiple threads based on the configuration information of the server, where the configuration information is used to indicate the computing power of the server, and the number of threads is positively correlated with the computing power of the server.

[0135] In this implementation manner, the server can create multiple threads based on the computing power of the server, and the number of threads created in this way conforms to the computing power of the server, so that the computing power of the server can be maximally exerted during the process of loading virtual objects into the virtual scene, improving the efficiency of virtual object loading.

[0136] For example, the server obtains a configuration file and obtains the configuration information of the server based on the configuration file. The server determines the computing power of the server based on the configuration information. The server creates multiple threads based on the computing power, and the multiple threads are used to load virtual objects into the virtual scene, so they are also called loading threads.

[0137] In a possible implementation manner, the server creates the multiple threads based on the number of the virtual objects, and the number of threads is positively correlated with the number of the virtual objects.

[0138] In this implementation manner, the server can create multiple threads based on the number of virtual objects to be loaded, so that the number of threads created is adapted to the number of virtual objects, thereby improving the efficiency of loading virtual objects through threads.

[0139] For example, the server divides the number of the virtual objects by M to obtain the target number of threads, where M is a positive integer. The server creates the target number of threads. Among them, M is set by technicians according to the actual situation, and the embodiments of the present application do not make any limitations in this regard.

[0140] 303. The server creates multiple loading tasks corresponding to the multiple virtual object sets, where the loading tasks are used to load the virtual objects in the virtual object sets into the virtual scene.

[0141] Among them, the loading tasks are in one-to-one correspondence with the virtual object sets, that is, the number of loading tasks is the same as the number of virtual object sets. In some embodiments, the loading tasks include the identifiers of the virtual objects in the corresponding virtual object sets and the storage locations of the loading files.

[0142] In a possible implementation, the server creates multiple loading tasks corresponding to the multiple virtual object sets in a task queue. The task queue is used to store loading tasks. In some embodiments, the server can mark and adjust the status of the loading tasks stored in the task queue. The status includes completed and uncompleted. Completed means that the loading task has been acquired by a certain thread; uncompleted means that the loading task has not been acquired by a thread. In the process of subsequent threads acquiring loading tasks from the task queue, only the loading tasks with the status of uncompleted will be loaded. Alternatively, the server can arrange the order of the loading tasks in the task queue based on the status of the loading tasks. For example, when the server creates multiple loading tasks corresponding to the multiple virtual object sets in the task queue, the status of the multiple loading tasks is all uncompleted. When acquiring loading tasks from the task queue, the thread proceeds in the order from beginning to end. After any loading task in the task queue is acquired by a thread, the server marks the status of the loading task as completed and places the loading task at the end of the task queue. Since the thread acquires loading tasks from the task queue in the order from beginning to end, the loading tasks placed at the end will not be acquired preferentially.

[0143] For example, for any one of the multiple virtual object sets, the server obtains the identifiers of at least one virtual object included in the virtual object set and the storage location of the loading file of the at least one virtual object. The server creates the virtual object and the corresponding loading task based on the identifiers of the at least one virtual object and the storage location of the loading file. The loading task is used to obtain the loading file from the storage location and load the corresponding virtual object into the virtual scene based on the loading file. In some embodiments, the server can count the created loading tasks to obtain the number of unexecuted tasks. Each time a loading task is completed subsequently, the number of unexecuted tasks is decreased by one. When the number of unexecuted tasks is zero, it means that all loading tasks are completed. The number of unexecuted tasks is also referred to as batch counting.

[0144] The following will be through Figure 5 to further illustrate the above steps 301-303.

[0145] See Figure 5 , Acotr1 to Actor10 represent virtual objects to be loaded, that is, physical bodies to be loaded. Every 5 Actors are combined into a batch to form a loading task and handed over to the loading thread for processing. That is, every 5 virtual objects are divided into a virtual object set. The virtual object set is used as a loading task. This way of first dividing the virtual object set and then loading is also called batch loading. The advantage of batch loading compared to loading individual Actors by threads is that it greatly reduces the number of loading tasks and reduces the additional overhead caused by overly frequent thread scheduling and switching. In Figure 5Among them, Actor1 to Actor5 are divided into a set of virtual objects, and this set of virtual objects corresponds to the loading task LoadTask1. Actor6 to Actor10 are divided into a set of virtual objects, and this set of virtual objects corresponds to the loading task LoadTask2. Subsequently, the loading tasks LoadTask1 and LoadTask2 can be executed by the loading thread.

[0146] 304. The server calls multiple threads to execute the multiple loading tasks respectively, and loads the multiple virtual objects into the virtual scene.

[0147] In a possible implementation manner, the multiple threads respectively obtain the corresponding loading tasks from the task queue. The multiple threads respectively execute the loading tasks obtained from the task queue, and load the multiple virtual objects into the virtual scene.

[0148] For example, the multiple threads sequentially obtain the corresponding loading tasks from the task queue. After the loading task is obtained, the server can mark the loading task as completed in the task queue, and subsequently will not obtain the loading task repeatedly, avoiding the repeated execution of the loading task. The multiple threads execute the corresponding loading tasks, and load the set of virtual objects corresponding to the loading task into the virtual scene through the loading file corresponding to the loading task, that is, load at least one virtual object in the set of virtual objects into the virtual scene.

[0149] In some embodiments, when any loading task in the task queue is executed by the multiple threads, the main thread performs a dequeue operation on the loading task, where the execution by the multiple threads means being executed by any one of the multiple threads. For example, the server can check the status of the loading tasks in the task queue through the main thread. When the status of any loading task is completed, the loading task is released from the task queue, and the number of unexecuted tasks is reduced by one, where the status of completed is used to indicate that the corresponding loading task has been executed by the loading thread.

[0150] The following will be combined with Figure 6 to illustrate the above steps 301 - 304.

[0151] See Figure 6, in the main thread, after a virtual scene initiates a loading instruction to load a large number of virtual objects, the virtual objects to be loaded will be batched according to the set batching quantity, where the batching quantity is the number of virtual objects in the virtual object set. For example, if there are a total of L virtual objects and the batching quantity is O, then the batch count K after batching is K = L / O or K = L / O + 1, and this batch count is also the number of virtual object sets, where L, O, and K are all positive integers. The server submits K loading tasks to the task queue, and the batch count of this virtual scene is K. The loading thread takes out the loading tasks from the task queue and executes the loading tasks to load virtual objects into the virtual scene. After all the virtual objects in a batch are loaded, the status of the loading task will be modified to completed, where a batch of virtual objects refers to the virtual objects in a virtual object set. The main thread checks the completed tasks through Tick (timing event), decrements the batch count of the corresponding virtual scene by one, and releases the loading task. When the batch count is 0, it indicates that all the asynchronous loading tasks of this virtual scene have been completed.

[0152] All of the above optional technical solutions can be combined arbitrarily to form optional embodiments of the present application, which will not be elaborated one by one here.

[0153] In the embodiments of the present application, the number of virtual objects in the virtual object set is not the more the better. When the number is too large, it approaches single-threaded loading and cannot make full use of the multi-threaded characteristics; when the number is too small, there are too many loading tasks, and the thread scheduling and switching are frequent, affecting the loading performance. Among them, the number of virtual objects in the virtual object set is also called the batching quantity.

[0154] An experiment was conducted using the method of loading virtual objects into 10 virtual scenes. 30,000 physical entities were loaded simultaneously in each virtual scene, and the average loading completion duration of a single virtual scene was recorded. Figure 7 The experimental results were recorded. In Figure 7 , the vertical axis represents the average loading time in milliseconds, and the horizontal axis represents the performance when different batching quantities are selected. As can be seen from Figure 7 , when using the synchronous loading method before batching, the average loading time of a single virtual scene is the lowest, which is 386 ms, but this method will occupy the main thread time, and the time for 10 virtual scenes is 10 × 386 ms. When the batching quantity is 500, the average loading time is the lowest at 657 ms. When the batching quantities are 1000 and 2000, the average loading times rise to 670 ms and 758 ms.

[0155] In addition, an experiment was also conducted based on the waiting duration for loading virtual objects. Among them, the waiting duration represents the time required for a virtual scene to start loading until it is loaded completely, indicating the response speed of the virtual scene. As Figure 8As shown in the figure, for the synchronous loading scheme before batch merging, the waiting time for the first loaded scene is 386 ms, the second is 386×2 ms, and the tenth loaded scene is 386×10 ms. The average loading time is 1930 ms. For the case of batch-merged asynchronous loading, since multiple threads are used to share tasks, the average waiting time is greatly reduced, and the average waiting time is the average loading time for each scene. When the batch-merged quantity is 500, the average waiting time is at a minimum of 657 ms. When the batch-merged quantity increases to 1000 and 2000, the average waiting time increases to 670 ms and 758 ms respectively.

[0156] Based on the above experimental results, the embodiments of the present application introduce multi-threaded loading, convert synchronous operations into asynchronous processes, and improve the system's response time. The batch-merged task loading is introduced, and by selecting an appropriate batch-merged quantity, the average waiting time for loading a single virtual scene is greatly reduced.

[0157] Through the technical solution provided by the embodiments of the present application, in response to a loading instruction for a virtual scene, the multiple virtual objects are divided into multiple virtual object sets, and subsequently, the virtual objects can be loaded into the virtual scene in units of virtual object sets. Multiple loading tasks corresponding to the multiple virtual object sets are created, and the multiple loading tasks are respectively executed by multiple threads, thereby optimizing the synchronous loading of virtual objects into asynchronous loading and improving the loading efficiency of virtual objects. At the same time, during the process of loading virtual objects into the virtual scene, there is no need for the main thread to execute, reducing the situation of running jams.

[0158] In other words, the embodiments of the present application introduce a multi-threaded mechanism, merge multiple virtual objects into one loading task using an appropriate specification, and hand it over to the loading thread for loading and processing, changing the synchronous process to an asynchronous one, so that the main thread will not be blocked due to a large number of dynamically loaded virtual objects. At the same time, multi-threaded processing of batch-merged loading tasks can also maximize the loading performance.

[0159] Figure 9 It is a schematic structural diagram of a loading device for virtual objects in a virtual scene provided by the embodiments of the present application. Refer to Figure 9 The device includes: a set determination module 901, a task creation module 902, and a thread invocation module 903.

[0160] The set determination module 901 is configured to, in response to a loading instruction for a virtual scene including multiple virtual objects, determine multiple virtual object sets, where each virtual object set includes at least one of the virtual objects.

[0161] The task creation module 902 is configured to create multiple loading tasks corresponding to the multiple virtual object sets, where the loading tasks are used to load the virtual objects in the virtual object sets into the virtual scene.

[0162] The thread call module 903 is used to call multiple threads to execute the multiple loading tasks respectively, and load the multiple virtual objects into the virtual scene.

[0163] In a possible implementation manner, the set determination module 901 is used to perform any one of the following:

[0164] In response to a loading instruction for the virtual scene, determine the multiple virtual object sets based on a preset number of objects.

[0165] In response to a loading instruction for the virtual scene, determine the multiple virtual object sets based on a preset number of sets.

[0166] In response to a loading instruction for the virtual scene, determine the multiple virtual object sets based on the number of the threads.

[0167] In response to a loading instruction for the virtual scene, determine the multiple virtual object sets based on the types of the multiple virtual objects.

[0168] In response to a loading instruction for the virtual scene, determine the multiple virtual object sets based on the storage space occupied by the multiple virtual objects.

[0169] In a possible implementation manner, the triggering method of the loading instruction includes any one of the following:

[0170] The target virtual object moves to a target position in the virtual scene.

[0171] The target virtual object executes a target virtual task in the virtual scene.

[0172] The target virtual object enters the virtual scene.

[0173] In a possible implementation manner, the determination method of the preset number of sets includes:

[0174] Obtain multiple candidate set numbers corresponding to a sample virtual scene, where the sample virtual scene includes multiple sample virtual objects to be loaded.

[0175] For any one of the multiple candidate set numbers, based on the candidate set number, divide the multiple sample virtual objects into multiple sample virtual object sets.

[0176] Determine the loading time consumed by the multiple threads, where the loading time is the time consumed to load the sample virtual objects in the multiple sample virtual object sets into the sample virtual scene.

[0177] Determine the target candidate set number as the preset number of sets, where the target candidate set number is the candidate set number that meets the target conditions among the multiple candidate set numbers.

[0178] In a possible implementation, the set determination module 901 is configured to determine the number of the virtual object sets as a target number, where the target number is N times the number of threads, and N is a positive integer. The multiple virtual objects are divided into the target number of virtual object sets.

[0179] In a possible implementation, the set determination module 901 is configured to divide the virtual objects of the same type among the multiple virtual objects into the same virtual object set.

[0180] In a possible implementation, the set determination module 901 is configured to divide a plurality of target virtual objects among the multiple virtual objects into one virtual object set, where the sum of the storage spaces occupied by the plurality of target virtual objects is less than or equal to a target threshold.

[0181] In a possible implementation, the task creation module 902 is configured to create a plurality of loading tasks corresponding to the plurality of virtual object sets in a task queue.

[0182] The thread invocation module 903 is configured to enable the multiple threads to respectively obtain corresponding loading tasks from the task queue. The multiple threads respectively execute the loading tasks obtained from the task queue to load the multiple virtual objects into the virtual scene.

[0183] In a possible implementation, the apparatus further includes:

[0184] A dequeue module, configured to, when any one of the loading tasks in the task queue is executed by the multiple threads, enable the main thread to perform a dequeue operation on the loading task.

[0185] In a possible implementation, the apparatus is applied to a server, and the apparatus further includes:

[0186] A thread creation module, configured to create the multiple threads based on the configuration information of the server, where the configuration information is used to indicate the computing power of the server, and the number of threads is positively correlated with the computing power of the server.

[0187] In a possible implementation, the apparatus further includes:

[0188] A thread creation module, configured to create the multiple threads based on the number of the virtual objects, where the number of threads is positively correlated with the number of the virtual objects.

[0189] It should be noted that: when loading virtual objects in the virtual scene provided by the above embodiments, only the division of the above functional modules is used for illustration. In practical applications, the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the computer device is divided into different functional modules to complete all or part of the functions described above. In addition, the virtual object loading device in the virtual scene provided by the above embodiments and the virtual object loading method embodiments in the virtual scene belong to the same concept. The specific implementation process can be found in the method embodiments and will not be repeated here.

[0190] Through the technical solution provided by the embodiments of the present application, in response to a loading instruction for a virtual scene, a plurality of virtual objects are divided into a plurality of virtual object sets, and subsequently, the virtual objects can be loaded into the virtual scene in units of virtual object sets. Create a plurality of loading tasks corresponding to the plurality of virtual object sets, and the plurality of threads respectively execute the plurality of loading tasks, thereby optimizing the synchronous loading of virtual objects into asynchronous loading and improving the loading efficiency of virtual objects. At the same time, during the process of loading virtual objects into the virtual scene, there is no need for the main thread to execute, which reduces the situation of running jams.

[0191] The above computer device can be implemented as a server. The structure of the server will be introduced below:

[0192] Figure 10 It is a schematic structural diagram of a server provided by the embodiments of the present application. The server 1000 may vary greatly due to different configurations or performances, and may include one or more processors (Central Processing Units, CPUs) 1001 and one or more memories 1002. Among them, at least one computer program is stored in the one or more memories 1002, and the at least one computer program is loaded and executed by the one or more processors 1001 to implement the methods provided by the above various method embodiments. Of course, the server 1000 may also have components such as wired or wireless network interfaces, keyboards, and input / output interfaces for input / output. The server 1000 may also include other components for implementing device functions, which will not be elaborated here.

[0193] In an exemplary embodiment, a computer-readable storage medium is also provided, such as a memory including a computer program, and the computer program can be executed by a processor to complete the method for loading a virtual object in the virtual scene in the above embodiment. For example, the computer-readable storage medium can be a read-only memory (ROM), a random access memory (RAM), a compact disc read-only memory (CD-ROM), a magnetic tape, a floppy disk, and an optical data storage device, etc.

[0194] In an exemplary embodiment, a computer program product or a computer program is also provided. The computer program product or the computer program includes program code, and the program code is stored in a computer-readable storage medium. The processor of the computer device reads the program code from the computer-readable storage medium, and the processor executes the program code, so that the computer device executes the method for loading a virtual object in the virtual scene described above.

[0195] In some embodiments, the computer program involved in the embodiments of the present application can be deployed to be executed on one computer device, or on multiple computer devices located at one place. Or, it can be executed on multiple computer devices distributed at multiple places and interconnected through a communication network. The multiple computer devices distributed at multiple places and interconnected through a communication network can form a blockchain system.

[0196] Those of ordinary skill in the art can understand that all or part of the steps for implementing the above embodiments can be completed by hardware, or can be completed by a program instructing relevant hardware. The program can be stored in a computer-readable storage medium, and the storage medium mentioned above can be a read-only memory, a magnetic disk, an optical disc, etc.

[0197] The above are only optional embodiments of the present application, and are not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A method for loading virtual objects in a virtual scene, characterized in that, the method includes: Determining the loading time corresponding to each of multiple candidate quantities, where the loading time corresponding to a candidate quantity refers to the time taken to load the sample virtual objects in multiple sample virtual object sets into a sample virtual scene after dividing the multiple sample virtual objects into the multiple sample virtual object sets according to the candidate quantity; Determining a target candidate quantity among the multiple candidate quantities as a preset quantity, where the target candidate quantity is the candidate quantity whose corresponding loading time meets the target condition; In response to a loading instruction for a virtual scene, determining multiple virtual object sets based on the preset quantity, where the virtual scene includes multiple virtual objects to be loaded, and each virtual object set includes at least one of the virtual objects; Creating multiple loading tasks corresponding to the multiple virtual object sets, where the loading tasks are used to load the virtual objects in the virtual object sets into the virtual scene; Invoking the multiple threads to respectively execute the multiple loading tasks, and loading the multiple virtual objects into the virtual scene.

2. The method according to claim 1, characterized in that, the method further includes any one of the following: In response to a loading instruction for a virtual scene, determining the multiple virtual object sets based on the number of the threads; In response to a loading instruction for a virtual scene, determining the multiple virtual object sets based on the types of the multiple virtual objects; In response to a loading instruction for a virtual scene, determining the multiple virtual object sets based on the storage space occupied by the multiple virtual objects.

3. The method according to claim 1 or 2, characterized in that, the triggering manner of the loading instruction includes any one of the following: A target virtual object moves to a target position in the virtual scene; The target virtual object executes a target virtual task in the virtual scene; The target virtual object enters the virtual scene.

4. The method according to claim 1, characterized in that, the preset quantity refers to a preset set quantity; and determining the loading time corresponding to each of the multiple candidate quantities includes: Obtaining multiple candidate set quantities corresponding to the sample virtual scene, where the sample virtual scene includes multiple sample virtual objects to be loaded; For any one of the multiple candidate set quantities, based on the candidate set quantity, dividing the multiple sample virtual objects into multiple sample virtual object sets, and the number of the multiple sample virtual object sets is equal to the candidate set quantity; Determining the loading time through the multiple threads, where the loading time is the time taken to load the sample virtual objects in the multiple sample virtual object sets into the sample virtual scene; The determining the target candidate quantity among the multiple candidate quantities as the preset quantity includes: Determining a target candidate set quantity as the preset set quantity, where the target candidate set quantity is the candidate set quantity whose corresponding loading time meets the target condition.

5. The method according to claim 1, characterized in that, The preset quantity refers to the preset object quantity; determining the loading time taken corresponding to each of the multiple candidate quantities includes: Obtaining multiple candidate object quantities corresponding to the sample virtual scene, where the sample virtual scene includes multiple sample virtual objects to be loaded; For any one of the multiple candidate object quantities, based on the candidate object quantity, dividing the multiple sample virtual objects into multiple sample virtual object sets, and the number of sample virtual objects in each sample virtual object set is the candidate object quantity; Determining the loading time taken by the multiple threads, where the loading time taken is the time taken to load the sample virtual objects in the multiple sample virtual object sets into the sample virtual scene; Determining the target candidate quantity among the multiple candidate quantities as the preset quantity includes: Determining the target candidate object quantity as the preset object quantity, where the target candidate object quantity is the candidate object quantity for which the corresponding loading time taken meets the target condition.

6. The method according to claim 2, wherein, determining the multiple virtual object sets based on the number of the threads includes: Determining the number of the virtual object sets as the target number, where the target number is N times the number of the threads, and N is a positive integer; Dividing the multiple virtual objects into the multiple virtual object sets of the target number.

7. The method according to claim 2, wherein, determining the multiple virtual object sets based on the types of the multiple virtual objects includes: Dividing the virtual objects of the same type among the multiple virtual objects into the same virtual object set.

8. The method according to claim 2, wherein, determining the multiple virtual object sets based on the storage spaces occupied by the multiple virtual objects includes: Dividing multiple target virtual objects among the multiple virtual objects into one virtual object set, where the sum of the storage spaces occupied by the multiple target virtual objects is less than or equal to the target threshold.

9. The method according to claim 1, wherein, creating the multiple loading tasks corresponding to the multiple virtual object sets includes: Creating the multiple loading tasks corresponding to the multiple virtual object sets in the task queue; Invoking multiple threads to respectively execute the multiple loading tasks, and loading the multiple virtual objects into the virtual scene includes: Each of the multiple threads respectively obtains the corresponding loading task from the task queue; Each of the multiple threads respectively executes the loading task obtained from the task queue to load the multiple virtual objects into the virtual scene.

10. The method according to claim 9, wherein, the method further includes: When any loading task in the task queue is executed by the multiple threads, the main thread performs a dequeue operation on the loading task.

11. The method according to claim 1, wherein, the method is executed by a server, and before invoking the multiple threads to execute the multiple loading tasks and loading the multiple virtual objects into the virtual scene, the method further includes: Create the multiple threads based on the configuration information of the server, where the configuration information is used to indicate the computing power of the server, and the number of the threads is positively correlated with the computing power of the server.

12. The method according to claim 1, wherein, before invoking the multiple threads to execute the multiple loading tasks and loading the multiple virtual objects into the virtual scene, the method further includes: Create the multiple threads based on the number of the virtual objects, where the number of the threads is positively correlated with the number of the virtual objects.

13. A loading device for virtual objects in a virtual scene, wherein, the device includes: a set determination module, configured to determine the loading time corresponding to multiple candidate quantities, where the loading time corresponding to a candidate quantity refers to the time taken to load the sample virtual objects in multiple sample virtual object sets into a sample virtual scene through multiple threads after dividing the multiple sample virtual objects into the multiple sample virtual object sets according to the candidate quantity; the set determination module is further configured to determine the target candidate quantity among the multiple candidate quantities as a preset quantity, where the target candidate quantity is the candidate quantity whose corresponding loading time meets the target condition; the set determination module is further configured to, in response to a loading instruction for the virtual scene, determine multiple virtual object sets based on the preset quantity, where the virtual scene includes multiple virtual objects to be loaded, and each virtual object set includes at least one of the virtual objects; a task creation module, configured to create multiple loading tasks corresponding to the multiple virtual object sets, where the loading tasks are used to load the virtual objects in the virtual object sets into the virtual scene; a thread invocation module, configured to invoke the multiple threads to execute the multiple loading tasks respectively and load the multiple virtual objects into the virtual scene.

14. A computer device, wherein, the computer device includes one or more processors and one or more memories, and at least one computer program is stored in the one or more memories, and the computer program is loaded and executed by the one or more processors to implement the method for loading virtual objects in a virtual scene according to any one of claims 1 to 12.

15. A computer-readable storage medium, wherein, at least one computer program is stored in the computer-readable storage medium, and the computer program is loaded and executed by a processor to implement the method for loading virtual objects in a virtual scene according to any one of claims 1 to 12.

16. A computer program product, including a computer program, wherein, the computer program, when executed by a processor, implements the method for loading virtual objects in a virtual scene according to any one of claims 1 to 12.

Citation Information

Patent Citations

  • Task processing method and device, computer device and storage medium

    CN108829521A

  • File package reading method and device

    CN110333911A

  • Virtual attack prop display method and device, storage medium and electronic equipment

    CN111617473A