Method and device for realizing random and disordered stacking of articles in area
Through Poisson disk sampling and multi-layer grid management technology, random and disorderly stacking of item instances in the game is achieved, solving the problems of taking into account both visual effects and performance in the existing technology, and improving the rendering effect and performance of the game.
Patent Information
- Application Number
- CN202510277855.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-10
- Publication Date
- 2025-05-09
AI Technical Summary
The prior art is difficult to achieve both visual effects and performance when implementing random disordered stacking of item instances in the game, especially when the number of items is large, it may cause the item to disappear or the game to stutter.
The Poisson disk sampling algorithm is used to randomly generate sampling points in the target area and classify them to multi-layer grids. The activation state of item instances is managed according to the tree relationship between grid layers, thereby achieving random and disordered item stacking.
Through this method, the use of game objects and computing resource consumption can be greatly reduced while an infinite number of objects is stacked, the "hollow pyramid" effect can be achieved, the visual effect can be improved and the performance burden can be reduced.
Smart Images

Figure CN119951138A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method and apparatus, a computing device, and a computer-readable storage medium for realizing random and disorderly stacking of objects in an area. Background Art
[0002] In existing game applications, it is sometimes necessary to stack multiple item instances in a fixed-size area according to the number of items, such as a virtual goods store in a game. In order to achieve the desired display effect, these item instances usually need to be displayed repeatedly and in an unordered manner. Existing rendering solutions cannot achieve both visual and performance benefits. Especially when there are a large number of items to be displayed, performance considerations will cause items to disappear randomly and abruptly, resulting in poor visual effects. Considering visual effects will cause too many item instances on the screen, causing the game process to freeze and performance to be limited. Summary of the invention
[0003] In view of this, embodiments of the present application provide a method and apparatus, a computing device, and a computer-readable storage medium for realizing random and disorderly stacking of objects in an area, so as to solve the technical defects existing in the prior art.
[0004] According to a first aspect of an embodiment of the present application, a method for randomly and disorderly stacking objects in an area is provided, comprising:
[0005] Poisson disk sampling is used to randomly generate sampling points in the target area;
[0006] Classifying the sampling points into cells of the first layer grid and generating object instances;
[0007] Generate new sampling points again and classify them into the second layer of grids, where the second layer of grids completely overlaps with the first layer of grids;
[0008] Bind the tree relationship between the sampling points to the grid according to the upper and lower layer relationship of the grid;
[0009] The activation state of the item instance is processed according to the tree relationship between the grids, and then the item instance is rendered and displayed according to the activation state.
[0010] According to a second aspect of an embodiment of the present application, there is provided a device for randomly and disorderly stacking objects in an area, comprising:
[0011] A generating unit, used for randomly generating sampling points in a target area by using Poisson disk sampling;
[0012] A classification unit, used to classify the sampling points into cells of a first-layer grid and generate item instances; and to generate new sampling points and classify them into a second-layer grid, wherein the second-layer grid completely overlaps with the first-layer grid;
[0013] A binding unit, used to bind the tree relationship between the sampling points to the grid according to the upper and lower layer relationship of the grid;
[0014] The rendering unit is used to process the activation state of the item instance according to the tree relationship between the grids, and then render and display the item instance according to the activation state.
[0015] According to a third aspect of an embodiment of the present application, a computing device is provided, comprising a memory, a processor, and computer instructions stored in the memory and executable on the processor, wherein the processor implements the steps of the aforementioned method when executing the instructions.
[0016] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, which stores computer instructions, and when the instructions are executed by a processor, the steps of the aforementioned method are implemented.
[0017] In the embodiment of the present application, the Poisson disk sampling algorithm is used to calculate two layers of random sampling points as the grid layer template. When adding item instances, there is no need to perform a new sampling process. The grid layer template can be reused, and the activation / deactivation management of item instances is performed according to the tree relationship between the grid layers. Even in the case of an infinite number of objects stacked, the use of game objects is greatly reduced, and the memory and computing resource consumption are greatly reduced. Furthermore, by combining the tree relationship between the grid layers with the activation weight strategy, not only the random disorder of the item placement is achieved, but also the "hollow pyramid" effect of the stacked items is achieved, which also has a good visual effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 is a structural block diagram of a computing device provided in an embodiment of the present application;
[0019] Figure 2 It is a flow chart of a method for realizing random and disorderly stacking of objects in a region provided by an embodiment of the present application;
[0020] Figure 3 is a schematic diagram of calculating sampling points using a Poisson disk sampling algorithm provided in an embodiment of the present application;
[0021] Figure 4 is a schematic diagram of classifying sampling points into a first-layer grid provided in an embodiment of the present application;
[0022] Figure 5 is a schematic diagram of classifying sampling points into a second-layer grid provided in an embodiment of the present application;
[0023] Figure 6 It is a rendering schematic diagram of randomly and disorderly stacking multiple objects in a target area provided by an embodiment of the present application;
[0024] Figure 7 It is a schematic diagram of the structure of a device for realizing random and disorderly stacking of objects in an area provided by an embodiment of the present application. DETAILED DESCRIPTION
[0025] Many specific details are described in the following description to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present application, so the present application is not limited by the specific implementation disclosed below.
[0026] The terms used in one or more embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of the present application. The singular forms of "a", "said" and "the" used in one or more embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of the present application refers to and includes any or all possible combinations of one or more associated listed items.
[0027] It should be understood that, although the terms first, second, etc. may be used to describe various information in one or more embodiments of the present application, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of the present application, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "in response to determination".
[0028] In the present application, a method and apparatus, a computing device and a computer-readable storage medium for realizing random and disorderly stacking of objects in an area are provided, which are described in detail one by one in the following embodiments.
[0029] Figure 1 The structure block diagram of a computing device 100 according to an embodiment of the present application is shown. The components of the computing device 100 include but are not limited to a memory 110 and a processor 120. The processor 120 is connected to the memory 110 via a bus 130, and the database 150 is used to store data.
[0030] The computing device 100 also includes an access device 140 that enables the computing device 100 to communicate via one or more networks 160. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 140 may include one or more of any type of network interface (e.g., a network interface card (NIC)) whether wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a World Wide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.
[0031] In one embodiment of the present application, the above components of the computing device 100 and Figure 1 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Figure 1 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of the present application. Those skilled in the art may add or replace other components as needed.
[0032] The computing device 100 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or PC. The computing device 100 may also be a mobile or stationary server.
[0033] In the prior art, in some game applications, there are scenarios where multiple item instances are stacked in an area of fixed size. In these scenarios, for the display effect of the game, the item instances need to be displayed repeatedly and disorderly. In these scenarios, the number of item instances may become large. The prior art pushes the items into a queue, randomly selects sampling points in the area as placement positions, and the area size is used to limit the number of items. The items at the end of the queue and beyond the area limit are activated or deactivated. The disadvantage is that it cannot achieve both visual and performance. When the number of displayed items is large, performance considerations will cause the items to disappear randomly and stiffly, and the visual effect is not good; and considering the visual effect will cause too many items on the screen, causing the game process to freeze and performance to be limited. Other solutions must require the items to be regular, and limit the placement and rotation of the items. They completely lack random disorder and are not suitable for stacking scenarios that require random disorder.
[0034] Therefore, in the embodiment of the present application, in order to solve the above problem, a method for realizing random and disorderly stacking of objects in an area is proposed, see Figure 2 , including steps 202 to 206.
[0035] Step 202: randomly generate sampling points in the target area using Poisson disk sampling.
[0036] In this step, layer sampling points are randomly generated using Poisson disk sampling within the target area according to the size of the area.
[0037] Specifically, first calculate the side length cellSize of the grid cell based on the minimum distance radius between the sampling points
[0038] float cellSize=radius / Mathf.Sqrt(2);
[0039] The radius value needs to be determined according to specific applications and requirements.
[0040] Furthermore, the grid used for Poisson disk sampling is initialized. Based on the calculated cellSize, a two-dimensional array grid of appropriate size is created and initialized based on the given sampling area. This grid ensures that the entire sampling area is covered and the size of each cell is sufficient to manage the generation of sampling points.
[0041] int[,]grid=new int[Mathf.CeilToInt(sampleRegionSize.x / cellSize),Mathf.CeilToInt(sampleRegionSize.y / cellSize)];
[0042] Wherein, sampleRegionSize represents the size of the sampling area;
[0043] sampleRegionSize.x / cellSize: Divide the width of the sampling region by the cell side length to get the number of cells in the grid in the x direction.
[0044] sampleRegionSize.y / cellSize: Divide the length of the sampling region by the cell side length to get the number of cells in the y direction of the grid.
[0045] Mathf.CeilToInt(value): Calculates the integer value of value after rounding up. This ensures that the entire sampling area is covered even if the edge is not completely divisible.
[0046] Furthermore, the above parameters are used as the parameters of Poisson disk sampling to complete the generation of sampling points in the target area, such as Figure 3 As shown, this sampling point is used as the first layer sampling point in the target area.
[0047] Step 204: classify the sampling points into the first layer grid; generate new sampling points again and classify them into the second layer grid, the second layer grid completely overlaps with the first layer grid; bind the tree relationship between the sampling points to the grid according to the upper and lower layer relationship of the grid.
[0048] In the embodiment of the present application, a first grid of N*M is first generated, where N and M represent the number of columns (cols) and rows (rows) of the first grid, so as to classify the sampling points into grids of different quadrants of the first grid layer, such as Figure 4 shown.
[0049] Specifically, the grid is divided into four quadrants, and the quadrant in which the sampling point is located and the range of the processed grid are determined according to the coordinates of the sampling point, so that the sampling point is classified into the target grids in different quadrants of the first layer grid.
[0050] Among them, the quadrant in which the sampling point is located and the range of the processed grid are determined according to the coordinates of the sampling point, and the target grid for classifying the sampling point into the first layer of grids includes:
[0051] Step S302: traverse the sampling points, determine the coordinates of the sampling points, divide them into target quadrants and obtain the grid range of the target quadrant.
[0052] The division of different quadrants is based on the (x, y) coordinate value of the sampling point, and the grid range (startX, startY) to (stopX, stopY) in the quadrant is determined according to the quadrant position of the sampling point.
[0053] foreach(var itemin pos)
[0054] {
[0055] topNodeId++;
[0056] int startX=0,startY=0,stopX=(int)tempCol,stopY=(int)tempRow;
[0057] / / Determine the quadrant and the range of the processed grid based on the position of the point
[0058] if(item.x<0&&item.y>0)
[0059] {
[0060] / / Grid range of the first quadrant
[0061] startX = 0;
[0062] startY=0;
[0063] stopX=Mathf.CeilToInt(tempCol / 2f);
[0064] stopY=Mathf.CeilToInt(tempRow / 2f);
[0065] }
[0066] / / Second, third and fourth quadrant range division and grid range
[0067] }
[0068] For example, for a sampling point (x=-1.5, y=2.5) in a 4*4 grid, the grid range where the sampling point is located is the column index [0,1] and the row index [0,1].
[0069] Step S304: Check the grid cells within the grid range one by one to check whether the sampling point is in a certain grid cell. If so, classify the sampling point into the grid cell and create an item instance corresponding to the sampling point.
[0070] for(int y = startY; y <stopY;y++)
[0071] {
[0072] for(int x = startX; x <stopX;x++)
[0073] {
[0074] ... / / Determine the location of the sampling point based on the coordinates of the sampling point and the location of the grid unit within the grid range
[0075] var cellUnit = new CellUnit
[0076] {
[0077] Active=false,
[0078] Id=id,
[0079] Pos = posV, / / Use the coordinates of the sampling point as the coordinates of the item instance
[0080] Layer=layer, / / Number of grid template layers
[0081] Angle = GetRandomAngle(), / / Randomly generate the rotation angle of the item instance
[0082] };
[0083]
[0084] Further, generate new random sampling points again according to the method in step 202 and classify them into the second-layer grid, where the second-layer grid completely overlaps with the first-layer grid. As Figure 5 shown (in the figure, there is a dislocation for the sake of indicating the overlap, but actually these two grids completely overlap), and then bind the tree relationship between the sampling points to the grid according to the upper and lower layer relationship of the grid.
[0085] In the embodiment of the present application, establish a tree relationship between each cell of the lower-layer grid and the upper-layer grid unit to describe the capping relationship between possible item instances.
[0086] Specifically, establish an index for the cell itself and its adjacent cells in the same layer of the grid. Since the upper-layer grid and the lower-layer grid completely overlap, for each cell in the lower-layer grid, the index between the cells that overlap and are adjacent to it in space with the upper-layer grid is also established simultaneously, and only a corresponding layer offset needs to be performed on the basis of the index of this layer. For example, the index of the cell in this layer:
[0087] Index = j * col + i, / / Convert the two-dimensional coordinates of the cell in this layer into a one-dimensional index
[0088] LSetIndex = i - 1 < 0? -1 : j * col + i - 1, / / Index of the left adjacent cell in this layer
[0089] RSetIndex = i + 1 < col? j * col + i + 1 : -1, / / Index of the right adjacent cell in this layer
[0090] USetIndex = j - 1 < 0? -1 : (j - 1) * col + i, / / Index of the upper adjacent cell in this layer
[0091] DSetIndex = j + 1 < row? (j + 1) * col + i : -1 / / Index of the lower adjacent cell in this layer
[0092] Layer offset _layerOffset = rows * cols, that is, the total number of cells in each layer.
[0093] Further, use the above-mentioned first-layer grid and second-layer grid together as the grid layer template.
[0094] Step 206: Process the activation status of the item instance according to the tree relationship between the grids, and then render and display the item instance according to the activation status.
[0095] In the embodiment of the present application, the item instance in the lower grid is detected, and a judgment is made based on the tree relationship obtained in step 204 to determine whether there is an item instance in the overlapping position and / or adjacent position of the cell where the item instance in the lower grid is located in the upper grid, and then the item instance in the lower grid is activated or deactivated based on the judgment result.
[0096] In a feasible implementation, when it is necessary to add item instances in the target area, a new grid layer template instance is added to the layer stack according to the number of items added, and the items are stacked on the new grid layer. The rendering effect is as follows: Figure 6 As shown; and at the same time, the activation or deactivation status of the items is dynamically maintained according to the tree relationship and weight strategy between the grid layers to manage the number of item instances.
[0097] Specifically, an activation weight value is set for each item instance of the lower grid, and when there is no item instance at one of the overlapping positions or adjacent positions of the upper grid, a preset value is added to the activation weight value.
[0098] For example, when there is no item instance in the spatially overlapping cell of the upper grid, the activation weight value is increased by 2; when there is no item instance in the upper cell of the upper grid, the activation weight value is increased by 1; when there is no item instance in the upper cell of the upper grid, the activation weight value is increased by 1; when there is no item instance in the left cell of the upper grid, the activation weight value is increased by 1; when there is no item instance in the right cell of the upper grid, the activation weight value is increased by 1.
[0099] Preferably, when the lower grid has multiple upper grids, the activation weight value of the item instance in the lower grid is calculated according to the situation of each upper grid. For example, when setting the activation weight value for the item instance in the 4th grid layer, it is necessary to determine whether the item instance exists in the corresponding overlapping positions or adjacent positions of the 1st to 3rd grid layers.
[0100] Preferably, when setting the activation weight value for each item instance of the lower grid, the closer the grid layer where the item instance is located is to the top layer, the higher the value of the activation weight increase. For example, when there are 4 layers of grids, the first layer of grids is the top layer of grids, the activation weight of the item instance in the 2nd layer of grids is increased by 5, the activation weight of the item instance in the 3rd layer of grids is increased by 3, and the activation weight of the item instance in the 4th layer of grids is increased by 1.
[0101] Preferably, it is determined whether the item instance of the lower grid is located at the edge of the grid, and if so, a preset value is added to the activation weight value of the item instance.
[0102] Furthermore, the activation weight value of the lower grid item instance is compared with a preset threshold. If the activation weight value is greater than or equal to the preset threshold, the item instance is set to be activated; if the activation weight value is less than the preset threshold, the item instance is set to be inactivated, and then the item instance is rendered and displayed according to the activation state.
[0103] Preferably, in response to the use of the item instance, the used item instance is deactivated, and at the same time, the activation or deactivation state of the item is dynamically maintained according to the aforementioned tree relationship and weight strategy, so as to manage the number of item instances. Further, when the number of activated item instances decreases to a certain extent, the network layer template is popped out of the layer stack.
[0104] In an embodiment of the present application, when managing the number of item instances, an object pool is used to manage all item instances. No matter how many grid layer template instances are created, the created objects are reduced to no more than 30 activated and inactivated GameObjects.
[0105] In the above-mentioned embodiment of the present application, in order to generate multiple disordered stacked item instances, both the rendering process is simple and efficient and a good visual effect is ensured. When generating item instances, two grid layers are used as grid layer templates. Therefore, when adding item instances, there is no need to perform a new sampling process. The grid layer template can be reused, and the activation / deactivation management of item instances is performed according to the tree relationship between the grid layers. Even in the case of an infinite number of objects stacked, the use of game objects is greatly reduced, and the memory and computing resource consumption are greatly reduced. Furthermore, by combining the tree relationship between the grid layers with the activation weight strategy, not only the random disorder of the item placement is achieved, but also the "hollow pyramid" effect of the stacked items is achieved, which also has a good visual effect.
[0106] Corresponding to the above-mentioned method embodiment for realizing random and disorderly stacking of objects in a region, the present application also provides an embodiment of a device for realizing random and disorderly stacking of objects in a region, such as Figure 7 As shown, the device comprises:
[0107] A generating unit, used for randomly generating sampling points in a target area by using Poisson disk sampling;
[0108] A classification unit, used to classify the sampling points into cells of a first-layer grid and generate item instances; and to generate new sampling points and classify them into a second-layer grid, wherein the second-layer grid completely overlaps with the first-layer grid;
[0109] A binding unit, used to bind the tree relationship between the sampling points to the grid according to the upper and lower layer relationship of the grid;
[0110] The rendering unit is used to process the activation state of the item instance according to the tree relationship between the grids, and then render and display the item instance according to the activation state.
[0111] The above is a schematic scheme of a device for realizing random and disorderly stacking of objects in an area of this embodiment. It should be noted that the technical scheme of the device and the technical scheme of the method for realizing random and disorderly stacking of objects in an area belong to the same concept, and the details not described in detail in the technical scheme of the device can be referred to the description of the technical scheme of the method for realizing random and disorderly stacking of objects in an area.
[0112] In one embodiment of the present application, a computing device is also provided, including a memory, a processor, and computer instructions stored in the memory and executable on the processor, wherein when the processor executes the instructions, the steps of the method for randomly and disorderly stacking objects in an area are implemented.
[0113] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the above-mentioned method for realizing random and disorderly stacking of objects in an area belong to the same concept, and the details not described in detail in the technical scheme of the computing device can be referred to the description of the technical scheme of the above-mentioned method for realizing random and disorderly stacking of objects in an area.
[0114] An embodiment of the present application further provides a computer-readable storage medium storing computer instructions, which, when executed by a processor, implement the steps of the method for randomly and unorderedly stacking objects in an area as described above.
[0115] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the method for realizing random and disorderly stacking of objects in an area are of the same concept, and the details not described in detail in the technical scheme of the storage medium can be referred to the description of the technical scheme of the method for realizing random and disorderly stacking of objects in an area.
[0116] The above describes specific embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0117] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0118] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described action sequence, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0119] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0120] The preferred embodiments of the present application disclosed above are only used to help explain the present application. The optional embodiments do not describe all the details in detail, nor do they limit the invention to the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of the present application. The present application selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present application, so that those skilled in the art can understand and use the present application well. The present application is only limited by the claims and their full scope and equivalents.
Claims
1. A method for randomly stacking items in an area, characterized in that: include: Poisson disk sampling is used to randomly generate sampling points in the target area; Classifying the sampling points into cells of the first layer grid and generating object instances; Generate new sampling points again and classify them into the second layer of grids, where the second layer of grids completely overlaps with the first layer of grids; Bind the tree relationship between the sampling points to the grid according to the upper and lower layer relationship of the grid; The activation state of the item instance is processed according to the tree relationship between the grids, and then the item instance is rendered and displayed according to the activation state.
2. The method according to claim 1, wherein: Classifying the sampling points into cells of the first-layer grid and generating item instances further includes: The first grid layer is divided into four quadrants, the quadrant in which the sampling point is located and the range of the processed grid are determined according to the coordinates of the sampling point, and the sampling point is classified into target grids in different quadrants of the first grid layer.
3. The method according to claim 2, wherein: Classifying the sampling points into target grids in different quadrants of the first layer grid includes: Traversing the sampling points, determining the coordinates of the sampling points, dividing them into target quadrants and obtaining a grid range of the target quadrant; The grid cells within the grid range are checked one by one to check whether the sampling point is in a certain grid cell. If so, the sampling point is classified into the grid cell, and an object instance corresponding to the sampling point is created at the same time, and the rotation angle of the object instance is randomly generated.
4. The method according to claim 1, wherein: Binding the tree relationship between sampling points to the grid according to the upper and lower layer relationship of the grid includes: Indexes are created for cells in the lower grid and their adjacent cells; corresponding layer shifts are performed based on the indexes to obtain indices between cells of the upper grid that overlap with the cells of the lower grid in space and the adjacent cells.
5. The method according to claim 4, wherein: Processing the activation state of the item instance according to the tree relationship between the grids, and then rendering and displaying the item instance according to the activation state includes: The first layer of grid and the second layer of grid are used together as a grid layer template; when an object instance needs to be added to the target area, a new grid layer template instance is added; and the activation or deactivation state of the object is dynamically maintained according to the tree relationship and weight strategy between the grid layers.
6. The method according to claim 5, wherein: Dynamically maintaining the activation or deactivation status of items based on the tree relationship and weight strategy between grid layers includes: Setting an activation weight value for the item instance of the lower grid, and when there is no item instance in one of the overlapping positions or adjacent positions of the upper grid, increasing the activation weight value by a preset value; When a lower grid has multiple upper grids, the activation weight values of the item instances in the lower grid are calculated according to the situation of each upper grid.
7. The method according to claim 5, wherein: The weight strategy includes: Determine the order of the grid layers where the item instance is located. The closer to the top layer, the higher the value of the activation weight increase. Determine whether the item instance is at the edge of the grid. If so, increase the activation weight of the item instance by a preset value.
8. The method according to claim 5, wherein: The method also includes: comparing the activation weight value of the lower grid item instance with a preset threshold value, if the activation weight value is greater than or equal to the preset threshold value, setting the item instance to be activated, otherwise setting the item instance to be inactivated.
9. The method according to claim 5, wherein: The method further includes: In response to the use of the item instance, the used item instance is deactivated; when the activated item instance is reduced to a certain extent, the network layer template is popped up on the top of the layer stack.
10. The method according to claim 1, further comprising: An object pool is used to manage all item instances, dynamically maintaining the number of object instances within a certain range.
11. A device for achieving random and disorderly stacking of objects in an area, characterized in that: include: A generating unit, used for randomly generating sampling points in a target area by using Poisson disk sampling; A classification unit, used to classify the sampling points into cells of a first-layer grid and generate item instances; and to generate new sampling points and classify them into a second-layer grid, wherein the second-layer grid completely overlaps with the first-layer grid; A binding unit, used to bind the tree relationship between the sampling points to the grid according to the upper and lower layer relationship of the grid; The rendering unit is used to process the activation state of the item instance according to the tree relationship between the grids, and then render and display the item instance according to the activation state.
12. A computing device comprising a memory, a processor, and computer instructions stored in the memory and executable on the processor, characterized in that: When the processor executes the instructions, the steps of the method according to any one of claims 1 to 10 are implemented.
13. A computer-readable storage medium storing computer instructions, characterized in that: When the instruction is executed by a processor, the steps of the method described in any one of claims 1 to 10 are implemented.