Method and system for synchronously editing node resources
Through the node resource synchronization editing method, differential algorithm and event monitoring mechanism are used to solve the problems of local modification difficulties and synchronization conflicts in the prefabricated piece system, efficient resource reuse and editing are achieved, and team collaboration efficiency and performance are improved.
Patent Information
- Application Number
- CN202510403984.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-01
- Publication Date
- 2025-07-08
AI Technical Summary
Existing prefabricated parts systems have difficulties in local modification and synchronization conflicts, and the performance overhead of synchronous updates for large-scale map scenarios is relatively high, especially in inefficient in team collaboration development.
The node resource synchronization editing method is adopted, by creating empty node resource files, adding objects and generating instances, and automatically synchronous updates are achieved using differential algorithms and event listening mechanisms, supporting flexible switching of local and global modifications, and using chunked loading to reduce performance overhead.
It realizes efficient resource reuse and editing, supports local modification and global adjustment, improves team collaboration efficiency, reduces maintenance costs, and reduces synchronization conflicts and performance overhead.
Smart Images

Figure CN120276727A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer communication technologies, and particularly to a method and system for synchronous editing of node resources. Background Art
[0002] Prefab systems are commonly found in game engines. The prefab system allows developers to create a reusable template (i.e., prefab) and instantiate multiple copies in the map scene. When the template of the prefab is modified, all instantiated copies are automatically updated synchronously.
[0003] The main disadvantages of the above method are as follows:
[0004] Difficulty in local modification: Prefab systems typically require all instances to be consistent with the template. If a local modification is needed for a certain instance (i.e., only modify this instance without affecting other instances), the operation becomes complex and may require breaking the prefab link or creating variants.
[0005] Synchronization conflicts: When multiple developers edit the same prefab simultaneously, synchronization conflicts may occur, especially in collaborative team development.
[0006] Performance overhead: For large-scale map scenes, the synchronous update of prefab instances may bring certain performance overhead, especially in the case of frequent modification of prefabs. Summary of the Invention
[0007] The purpose of the present invention is to provide a method and system for synchronous editing of node resources, which can achieve efficient resource reuse and editing.
[0008] The technical solution of the present invention:
[0009] A method for synchronous editing of node resources, the method includes the following steps,
[0010] Step 1: Create an empty node resource file, which will be used as a template;
[0011] Step 2: Add objects to the node resource file, and the objects are copied to the map scene during instantiation;
[0012] Step 3: Add the node resource file to the map scene to generate node instances;
[0013] Step 4: When the attributes of the node resource file are modified, all node instances generated based on this node resource file are automatically updated synchronously to maintain consistency with the template;
[0014] Step 5: When the attributes of a certain node instance are modified, it is determined whether the modification content needs to be synchronized back to the node resource file according to the user's selection.
[0015] Further, step 3 is further specifically as follows: When a node instance is instantiated, a unique ID is generated for each node instance to identify and distinguish different instances.
[0016] Further, in step 4, the automatic synchronization and update method is as follows:
[0017] Monitor the modification event of the node resource file: When the node resource file is saved, trigger the synchronization mechanism; the synchronization mechanism updates the attributes of the node instances one by one by traversing all the node instances associated with the node resource file in the map scene; then, by traversing all the attributes of the node resource file and the node instances, optimize the synchronization process, only update the changed attributes, and reduce the performance overhead.
[0018] Further, record the change amount through the difference array in the difference algorithm and perform interval update. Recording the change amount through the difference array is to determine which attributes have changed during the process of synchronizing attributes, and then update the changed attributes. The steps are as follows:
[0019] (1) Initialize the difference array;
[0020] Set an original array A with a length of n, initialize a difference array D with the same length as the original array A, and set all elements to 0 during initialization; the definition of the difference array D is as follows:
[0021] D[0] = A[0];
[0022] D[i] = A[i] - A[i - 1], where 1 <= i < n;
[0023] (2) Interval update operation;
[0024] Add a value delta to each element in the interval [l, r] of the original array A; record this change in the difference array D through the following steps:
[0025] Increase the influence of the start position:
[0026] D[l] = D[1] + delta;
[0027] This means that starting from position l, the elements of the original array A will increase by delta;
[0028] If r + 1 is within the range of the original array, reduce the influence after the end position. If r + 1 = n, there is no need to reduce the influence after the end position because there is no influence beyond the boundary of the original array; the operation to reduce the influence after the end position is:
[0029] D[r + 1] = D[r + 1] - delta;
[0030] This means that starting from position r + 1, the increased delta effect ends;
[0031] (3) Construct the updated original array;
[0032] Through the difference array D, reconstruct the updated original array A, and the specific steps are as follows:
[0033] Initialize an array A' as an all-zero array, or directly perform accumulation on the original array A, or reuse the initial value of A;
[0034] Traverse the difference array D and reconstruct the array A' by accumulating the prefix sum:
[0035] A'[0] = D[0];
[0036] A'[i] = A'[i - 1] + D[i], where 1 <= i < n,
[0037] In this way, A' is the updated original array.
[0038] Furthermore, for large-scale map scenarios, adopt a chunk loading method to avoid performance problems caused by synchronizing a large number of node instances at one time; chunk loading is to divide the large-scale map scenario into multiple small chunks for dynamic loading according to needs, reducing the burden of one-time loading.
[0039] Furthermore, step 5 is further specifically as follows: when the attribute of a certain node instance is modified, it is determined according to the user's choice whether the modified content needs to be synchronized back to the node resource file;
[0040] If it is selected to synchronize the modified content back to the node resource file, the node resource file will be updated, and all other node instances will also be synchronously updated; extract the modified content of the node instance and update it to the node resource file; after synchronization is completed, all other instances will be automatically updated to maintain consistency with the resource file;
[0041] When synchronizing back to the node resource file, it is determined according to the user's choice whether to overwrite the original attribute or merge the modified content.
[0042] Furthermore, two-way synchronization between the node resource file and the node instance is achieved through an event listening mechanism and a callback mechanism;
[0043] (1) Event listening mechanism: (a) Set up an event: trigger an event when the node resource file or the node instance changes;
[0044] (b) Define the monitoring type: define the types of events that need to be listened to;
[0045] (c) Monitoring changes in node resource files:
[0046] File monitoring: Use a file monitoring mechanism to monitor changes in node resource files; by reading the file, determine whether the file content has changed;
[0047] Event triggering: When the file changes, trigger the corresponding event and use the changed information as a parameter of the event;
[0048] (d) Monitoring changes in node instances:
[0049] Instance observation: When the attributes or status of a node instance change, trigger the corresponding event;
[0050] Event triggering: When the position, size, or color attributes of a node instance change, trigger a node attribute update event;
[0051] (2) Callback mechanism: (a) Register callback: Register a callback function for the event. The callback function will be called when the event is triggered and is used to handle synchronous logic;
[0052] (b) Implement callback:
[0053] Synchronization from node resource file to node instance: When the node resource file changes, the callback function is responsible for loading new data from the node resource file and updating the corresponding node instance;
[0054] Synchronization from node instance to node resource file: When the node instance changes, the callback function is responsible for writing the changes back to the node resource file; manage the changes by directly modifying the node resource file.
[0055] A system for synchronous editing of node resources, the system includes a creation module, an addition module, a generation module, a synchronization module, and a selection module;
[0056] Creation module: Create an empty node resource file, which will be used as a template;
[0057] Addition module: Add objects to the node resource file. The objects are copied to the map scene when instantiated;
[0058] Generation module: Add the node resource file to the map scene to generate node instances;
[0059] Synchronization module: When the attributes of the node resource file are modified, all node instances generated based on this node resource file will be automatically synchronized and updated to maintain consistency with the template;
[0060] Selection module: When the attributes of a certain node instance are modified, determine whether to synchronize the modified content back to the node resource file according to the user's selection.
[0061] Further, the generation module is further specifically: when a node instance is instantiated, a unique ID is generated for each node instance to identify and distinguish different instances.
[0062] Further, in the synchronization module, the automatic synchronization update method is as follows:
[0063] Monitor the modification event of the node resource file: when the node resource file is saved, trigger the synchronization mechanism; the synchronization mechanism updates the attributes of the node instances one by one by traversing all the node instances associated with the node resource file in the map scene; then, by traversing all the attributes of the node resource file and the node instances, optimize the synchronization process, only update the changed attributes, and reduce the performance overhead.
[0064] Further, the change amount is recorded by the difference array in the difference algorithm and interval update is performed. Recording the change amount by the difference array is to determine which attributes have changed during the synchronization of attributes, and then update the changed attributes. The steps are as follows:
[0065] (1) Initialize the difference array;
[0066] Set a original array A with length n, initialize a difference array D with the same length as the original array A, and set all elements to 0 during initialization; the definition of the difference array D is as follows:
[0067] D[0] = A[0];
[0068] D[i] = A[i] - A[i - 1], where 1 <= i < n;
[0069] (2) Interval update operation;
[0070] Add a value delta to each element in the interval [l, r] of the original array A; record this change in the difference array D through the following steps:
[0071] Increase the influence of the start position:
[0072] D[l] = D[1] + delta;
[0073] This means that starting from position l, the elements of the original array A will increase by delta;
[0074] If r + 1 is within the range of the original array, reduce the influence after the end position. If r + 1 = n, there is no need to reduce the influence after the end position because there is no influence beyond the boundary of the original array. The operation to reduce the influence after the end position is:
[0075] D[r + 1] = D[r + 1] - delta;
[0076] This indicates that starting from position r + 1, the increased delta effect ends;
[0077] (3) Construct the updated original array;
[0078] Using the difference array D, reconstruct the updated original array A. The specific steps are as follows:
[0079] Initialize an array A' as an all-zero array, or directly perform accumulation on the original array A, or reuse the initial value of A;
[0080] Traverse the difference array D and reconstruct the array A' by accumulating the prefix sum:
[0081] A'[0] = D[0];
[0082] A'[i] = A'[i - 1] + D[i], where 1 <= i < n,
[0083] In this way, A' is the updated original array.
[0084] Furthermore, for large-scale map scenarios, adopt a chunk loading method to avoid performance issues caused by synchronizing a large number of node instances at once; chunk loading is to divide the large-scale map scenario into multiple small chunks for dynamic loading as needed, reducing the burden of one-time loading.
[0085] Furthermore, the selection module is further specifically: when the attribute of a certain node instance is modified, according to the user's selection, whether to synchronize the modification content back to the node resource file;
[0086] If it is selected to synchronize the modification content back to the node resource file, the node resource file will be updated, and all other node instances will also be synchronously updated; extract the modification content of the node instance and update it to the node resource file; after synchronization is completed, all other instances will be automatically updated to maintain consistency with the resource file;
[0087] When synchronizing back to the node resource file, according to the user's selection, whether to overwrite the original attribute or merge the modification content.
[0088] Furthermore, two-way synchronization between the node resource file and the node instance is achieved through an event listening mechanism and a callback mechanism;
[0089] (1) Event listening mechanism: (a) Set up an event: Trigger an event when the node resource file or the node instance changes;
[0090] (b) Define the monitoring type: Define the types of events that need to be listened to;
[0091] (c) Monitoring changes in node resource files:
[0092] File monitoring: Use a file monitoring mechanism to monitor changes in node resource files; by reading the file, determine whether the file content has changed;
[0093] Event triggering: When the file changes, trigger the corresponding event and use the changed information as a parameter of the event;
[0094] (d) Monitoring changes in node instances:
[0095] Instance observation: When the attributes or status of a node instance change, trigger the corresponding event;
[0096] Event triggering: When the position, size, or color attributes of a node instance change, trigger a node attribute update event;
[0097] (2) Callback mechanism: (a) Registering a callback: Register a callback function for the event. The callback function will be called when the event is triggered and is used to handle synchronous logic;
[0098] (b) Implementing the callback:
[0099] Synchronization from node resource files to node instances: When the node resource file changes, the callback function is responsible for loading new data from the node resource file and updating the corresponding node instance;
[0100] Synchronization from node instances to node resource files: When the node instance changes, the callback function is responsible for writing the changes back to the node resource file; manage the changes by directly modifying the node resource file.
[0101] Advantages of the present invention:
[0102] The present invention provides a method and system for synchronous editing of node resources, which can achieve efficient resource reuse and editing.
[0103] Efficient resource reuse: Through node resource files, developers can easily create and manage a large number of similar node instances, significantly improving the resource reuse rate.
[0104] Automatic synchronous update: The two-way synchronization mechanism between node resource files and node instances ensures that any modification can be automatically applied to all relevant instances, reducing manual operations.
[0105] Flexible editing: Supports flexible switching between local modifications and global modifications. It is possible to perform customized editing on a single instance or make unified adjustments to all instances.
[0106] Improving team collaboration efficiency: Through the centralized management of node resource files, team members can more conveniently share and synchronize resources, reducing conflicts and duplicate work.
[0107] Reduce maintenance costs: When large-scale modification of resources is required, only the node resource file needs to be modified, without modifying each instance one by one, greatly reducing the maintenance cost.
[0108] Through this method of synchronous editing of node resources, developers can more efficiently manage and edit resources in complex scenarios, improving development efficiency and project quality. Brief Description of the Drawings
[0109] Figure 1 is a schematic flow chart of the method of the present invention.
[0110] Figure 2 is a block diagram of the system principle of the present invention. Detailed Embodiments
[0111] The present invention will be further described below with reference to the accompanying drawings.
[0112] As Figure 1 shown, the present invention provides a method for synchronous editing of node resources, and the method includes the following steps:
[0113] Step 1: Create an empty node resource file, which will be used as a template;
[0114] Step 2: Add objects to the node resource file, and the objects are copied to the map scene during instantiation;
[0115] Step 3: Add the node resource file to the map scene to generate node instances;
[0116] Step 4: When the attributes of the node resource file are modified, all node instances generated based on the node resource file will be automatically synchronized and updated to maintain consistency with the template;
[0117] Step 5: When the attributes of a certain node instance are modified, it is determined according to the user's choice whether the modified content needs to be synchronized back to the node resource file.
[0118] The specific implementation of Step 3 is as follows: When a node instance is instantiated, a unique ID is generated for each node instance to identify and distinguish different instances.
[0119] In Step 4, the method of automatic synchronization and update is as follows:
[0120] Monitor the modification events of the node resource file: When the node resource file is saved, trigger the synchronization mechanism; the synchronization mechanism traverses all node instances associated with the node resource file in the map scene, and updates the attributes of the node instances one by one; then, by traversing all the attributes of the node resource file and the node instances, optimize the synchronization process, only update the attributes that have changed, and reduce the performance overhead.
[0121] Record the change amount through the difference array in the difference algorithm and perform interval updates. Recording the change amount through the difference array is to determine which attributes have changed during the property synchronization process, and then update the attributes that have changed. The steps are as follows:
[0122] (1) Initialize the difference array;
[0123] Set an original array A with a length of n, initialize a difference array D with the same length as the original array A, and set all elements to 0 during initialization; the definition of the difference array D is as follows:
[0124] D[0] = A[0];
[0125] D[i] = A[i] - A[i - 1], where 1 <= i < n;
[0126] (2) Interval update operation;
[0127] Add a value delta to each element in the interval [l, r] of the original array A; record this change in the difference array D through the following steps:
[0128] Increase the influence of the start position:
[0129] D[l] = D[1] + delta;
[0130] This means that starting from position l, the elements of the original array A will increase by delta;
[0131] If r + 1 is within the range of the original array, reduce the influence after the end position. If r + 1 = n, there is no need to reduce the influence after the end position because there is no influence beyond the boundary of the original array; the operation to reduce the influence after the end position is:
[0132] D[r + 1] = D[r + 1] - delta;
[0133] This means that starting from position r + 1, the increased delta influence ends;
[0134] (3) Construct the updated original array;
[0135] Reconstruct the updated original array A through the difference array D. The specific steps are as follows:
[0136] Initialize an array A' as an all-zero array, or directly accumulate on the original array A, or reuse the initial value of A;
[0137] Traverse the difference array D and reconstruct the array A' by accumulating the prefix sum:
[0138] A'[0] = D[0];
[0139] A'[i] = A'[i - 1] + D[i], where 1 <= i < n,
[0140] In this way, A' is the updated original array.
[0141] For large-scale map scenarios, adopt the method of chunk loading to avoid performance problems caused by synchronizing a large number of node instances at one time; chunk loading is to divide the large-scale map scenario into multiple small chunks for dynamic loading according to needs, reducing the burden of one-time loading.
[0142] The step 5 is further specifically: when the attribute of a certain node instance is modified, according to the user's choice, whether to synchronize the modified content back to the node resource file;
[0143] If the user chooses to synchronize the modified content back to the node resource file, the node resource file will be updated, and all other node instances will also be synchronously updated; extract the modified content of the node instance and update it to the node resource file; after the synchronization is completed, all other instances will be automatically updated to maintain consistency with the resource file;
[0144] When synchronizing back to the node resource file, according to the user's choice, whether to overwrite the original attribute or merge the modified content.
[0145] Two-way synchronization between the node resource file and the node instance is achieved through the event listening mechanism and the callback mechanism;
[0146] (1) Event listening mechanism: (a) Set up an event: Trigger an event when the node resource file or the node instance changes;
[0147] (b) Define the monitoring type: Define the types of events that need to be listened to;
[0148] (c) Listen for changes in the node resource file:
[0149] File monitoring: Use the file monitoring mechanism to listen for changes in the node resource file; by reading the file, determine whether the file content has changed;
[0150] Event triggering: When the file changes, trigger the corresponding event and use the changed information as the parameter of the event;
[0151] (d) Monitor changes in node instances:
[0152] Instance observation: When the properties or status of a node instance change, corresponding events are triggered;
[0153] Event triggering: When the position, size, or color properties of a node instance change, a node property update event is triggered;
[0154] (2) Callback mechanism: (a) Register a callback: Register a callback function for an event. The callback function will be called when the event is triggered and is used to handle synchronous logic;
[0155] (b) Implement the callback:
[0156] Synchronization of node resource files to node instances: When the node resource file changes, the callback function is responsible for loading new data from the node resource file and updating the corresponding node instance;
[0157] Synchronization of node instances to node resource files: When a node instance changes, the callback function is responsible for writing the changes back to the node resource file; manage changes by directly modifying the node resource file.
[0158] The following further illustrates the present invention with a specific embodiment:
[0159] A method for synchronous editing of node resources,
[0160] Step 1: Create an empty node resource file
[0161] The node resource file is essentially a data structure that stores basic information about the node (such as name, type, properties, etc.).
[0162] The file can contain metadata, such as version number, creation time, author, etc., which is convenient for subsequent management and tracking. Create an empty node resource file in the editor, and this file will be used as a template. The node resource file can contain information such as basic properties, components, and child nodes.
[0163] Step 2: Add objects to the node resources
[0164] Add the required objects (such as models, materials, scripts, etc.) to the node resource file. These objects will become part of the node resources and will be copied to the scene when instantiated. Each object is stored as an independent data block in the node resource file, containing its properties (such as position, rotation, scale) and associated resources (such as model file path, material file path).
[0165] Parent-child relationships can be established between objects to form a hierarchical structure. For example, the trunk of a tree is the parent node, and the branches and leaves are the child nodes.
[0166] Step 3: Add node resources to the map scene to generate node instances
[0167] Drag the node resource file into the map scene to generate a node instance. This instance is a copy of the node resource and is initially exactly the same as the node resource file. The node instance exists as an independent object in the scene, but its properties are associated with the node resource file. When instantiating, a unique ID is generated for each node instance to identify and distinguish different instances. For example, for a node instance Node, when adding, an ID is added after each instance, and the generated node instances are Node1, Node2 to NodeN.
[0168] Step 4: Modify the properties of the node resource and synchronize the node instances
[0169] When the properties of the node resource file are modified (such as adjusting position, rotation, scaling, etc.), all node instances based on this resource will be automatically synchronized and updated to maintain consistency with the template. Listen for the modification events of the node resource file. When the file is saved, trigger the synchronization mechanism. The synchronization mechanism traverses all instances associated with this resource in the scene and updates their properties one by one. By traversing all the properties of the node resource and the instances, optimize the synchronization process, only update the properties that have changed, and reduce the performance overhead. The differential algorithm is mainly used when traversing the properties. The differential algorithm is an algorithm technology for efficiently handling problems of dynamic arrays or sequences. It achieves fast interval updates and query operations on the original array by maintaining a difference array. The core idea of the differential algorithm is to use the difference array to record the change amount instead of directly operating on the original array, thereby reducing the time complexity of the interval update operation from linear to constant level.
[0170] The core of the differential algorithm lies in efficiently handling the interval update operation of the original array by maintaining a difference array. The difference array records the differences between adjacent elements of the original array, and the update of the original array is indirectly achieved through operations on the difference array. The following is the detailed process, explaining how to record the change amount through the difference array and perform interval updates:
[0171] 1. Initialize the difference array
[0172] Suppose we have an original array A with length n. We need to initialize a difference array D with the same length n, and all elements are set to 0 initially. The definition of the difference array D is as follows:
[0173] D[0] = A[0] (or it can be set to 0, which can be adjusted according to needs in specific implementation)
[0174] D[i] = A[i] - A[i - 1], for 1 <= i < n
[0175] However, in practical applications, to simplify operations, D is usually initialized as an array of all zeros, and then effective difference information is constructed through update operations.
[0176] 2. Interval update operation
[0177] Suppose we want to add a value delta to each element in the interval [l, r] of the original array A. We can record this change in the difference array D through the following steps:
[0178] Increase the influence of the start position:
[0179] D[l] += delta
[0180] This means that starting from position l, the elements of the original array will increase by delta.
[0181] Reduce the influence after the end position (if r + 1 is within the array range):
[0182] D[r + 1] -= delta (if r + 1 == n, this step can be omitted because there is no influence beyond the array boundary)
[0183] This means that starting from position r + 1, the increased delta influence ends.
[0184] 3. Construct the updated original array
[0185] Through the difference array D, we can reconstruct the updated original array A. The specific steps are as follows:
[0186] Initialize an array A' (or directly accumulate on the original array A) as an array of all zeros, or reuse the initial value of A.
[0187] Traverse the difference array D and reconstruct the original array by accumulating the prefix sum:
[0188] A'[0] = D[0]
[0189] For 1 <= i < n, A'[i] = A'[i - 1] + D[i]
[0190] In this way, A' is the updated original array.
[0191] Example
[0192] Suppose the original array A = [1, 2, 3, 4, 5], and we want to add 2 to each element in the interval [1, 3].
[0193] Initialize the difference array:
[0194] D = [0, 0, 0, 0, 0]
[0195] Perform range update operation:
[0196] D[1]+=2 => D=[0,2,0,0,0]
[0197] D[4]-=2 => D=[0,2,0,0,-2]
[0198] Rebuild the original array:
[0199] A'[0]=D[0]=0+1=1 (assuming the initial value of A is used for accumulation)
[0200] A'[1]=A'[0]+D[1]=1+2=3
[0201] A'[2]=A'[1]+D[2]=3+0=3+(original 2+0=3 accumulation effect)=5 (actual subsequent accumulation of 3)
[0202] A'[3]=A'[2]+D[3]=5+0=5+(original 3+0+0 cumulative here=5)=7 (continuing the effect)
[0203] A'[4]=A'[3]+D[4]=7-2=5
[0204] Finally, the updated array A'=[1,3,5,7,5] is obtained.
[0205] For large-scale scenarios, a chunk loading strategy can be adopted to avoid performance issues caused by synchronizing a large number of instances at once. Chunk loading mainly divides the large-scale map into multiple small chunks for dynamic loading as needed, reducing the burden of one-time loading. For example, in a game map, the map can be divided into multiple small chunks of a fixed size (such as 200x200 pixels), and the node instances of the currently required small chunks can be dynamically loaded according to the player's position or the user's operations.
[0206] Step 5: Modify the node instance and synchronize the node resource file
[0207] When the attributes of a certain node instance are modified, you can choose to synchronize the modified content back to the node resource file. In this way, the node resource file will be updated, and all other instances will also be synchronized and updated. The system will extract the modified content of the instance and update it to the node resource file. When synchronizing back to the resource file, you can choose to overwrite the original attributes or merge the modified content.
[0208] After synchronization is completed, all other instances will be automatically updated to maintain consistency with the resource file.
[0209] There are mainly the following two situations:
[0210] 1. Two-way synchronization mechanism:
[0211] Bidirectional synchronization between the node resource file and the node instance is achieved through the event listening and callback mechanisms. When the resource file is modified, a "resource update event" is triggered to notify all instances to update their properties. When an instance is modified, an "instance modification event" is triggered, and the option exists to synchronize the modified content back to the resource file.
[0212] Event Listening Mechanism
[0213] 1. Establish an event system: Trigger events when changes occur in the node resource file or node instance.
[0214] 2. Define monitoring types: Define the types of events to be listened for, such as adding a node instance, deleting a node instance, modifying the properties of a node instance, etc.
[0215] 3. Listen for changes in the node resource file
[0216] File monitoring: Use a file monitoring mechanism (by reading the file and determining whether the file content has changed) to listen for changes in the node resource file.
[0217] Event triggering: When the file changes, trigger the corresponding event and use the changed information (such as the changed node ID, properties, etc.) as parameters of the event.
[0218] 4. Listen for changes in the node instance
[0219] Instance observation: When the properties or status of a node instance change, trigger the corresponding event.
[0220] Event triggering: For example, when properties such as the position, size, color, etc. of a node instance change, trigger a node property update event.
[0221] Callback Mechanism
[0222] 1. Register callbacks: Register callback functions for events (a callback function is a function that is passed through a function pointer or similar mechanism and is called when a specific condition or event occurs). These functions will be called when the event is triggered and are used to handle the synchronization logic.
[0223] 2. Implement callbacks:
[0224] Synchronization from resource to instance: When the node resource file changes, the callback function is responsible for loading new data from the file and updating the corresponding node instance.
[0225] Synchronization from instance to resource: When the node instance changes, the callback function is responsible for writing the changes back to the node resource file. Manage the changes by directly modifying the file.
[0226] 2. Switch between local modification and global modification:
[0227] Each node instance can be locally modified independently of the resource file. The content of the local modification will not affect other instances.
[0228] If it is necessary to apply the local modification to all instances, the modified content can be updated to the resource file through the synchronization mechanism.
[0229] Specific application scenarios:
[0230] Scenario description: Building management in an open-world game
[0231] Suppose we are developing an open-world game that contains a large number of buildings. These buildings have the same structure (such as walls, windows, doors, etc.), but their positions, rotations, and decorations in the scene are different. To efficiently manage these buildings, we can use the method of synchronous editing of node resources.
[0232] Expansion of specific implementation steps:
[0233] 1. Create a building node resource file:
[0234] Create a node resource file named "Building_Resource" in the editor.
[0235] This file contains the basic structure of the building, such as walls, floors, roofs, etc. Each part is an independent object with its own properties (such as materials, dimensions, etc.).
[0236] 2. Add building objects:
[0237] Add wall models, window models, door models, etc. to "Building_Resource". Set default properties for each object. For example, the material of the wall is brick and the material of the window is glass. Establish the hierarchical relationship between the objects. For example, the wall is the parent node and the window and door are the child nodes.
[0238] 3. Generate building node instances:
[0239] Drag "Building_Resource" into the game scene to generate multiple building instances. The position, rotation, and scale of each instance can be adjusted according to the scene requirements. For example, place one building instance at the foot of a mountain and another at the center of the city.
[0240] 4. Modify the properties of the building node resources:
[0241] Suppose we need to change the wall material of all buildings from masonry to wood. We only need to modify the material property of the wall in "Building_Resource". After saving, all building instances in the scene will be automatically synchronized and updated. If we need to add a new decoration (such as a flag) to all buildings, we only need to add the flag model in the resource file and set its default position and material.
[0242] 5. Modify the building node instance and synchronize it back to the resource file:
[0243] Suppose we need to add a chimney to a specific building instance. We can add the chimney model to this instance and adjust its position and size. If we want to add the chimney to all building instances, we can choose to synchronize the modification back to "Building_Resource". In this way, all other building instances will also automatically add the chimney model. If we only need to keep the chimney for the current instance, we can choose not to synchronize it back to the resource file, thus achieving local modification.
[0244] Specific operation examples in the scene:
[0245] Operation 1: Select a building instance in the scene and adjust the position and size of its windows.
[0246] Operation 2: Add a balcony model to another building instance.
[0247] Operation 3: Synchronize the modification of the balcony model back to "Building_Resource" so that all building instances automatically add balconies.
[0248] Operation 4: Modify the material of the balcony in the resource file, and the material of all instances' balconies will be automatically updated.
[0249] The present invention also provides a system for synchronously editing node resources, which includes a creation module, an addition module, a generation module, a synchronization module, and a selection module;
[0250] Creation module: Create an empty node resource file, which will be used as a template;
[0251] Addition module: Add objects to the node resource file, and the objects are copied to the map scene during instantiation;
[0252] Generation module: Add the node resource file to the map scene to generate node instances;
[0253] Synchronization module: When the attributes of the node resource file are modified, all node instances generated based on this node resource file will be automatically synchronized and updated to maintain consistency with the template;
[0254] Selection module: When the attributes of a node instance are modified, it is determined whether to synchronize the modified content back to the node resource file according to the user's selection.
[0255] The generation module is further specifically: When a node instance is instantiated, a unique ID is generated for each node instance to identify and distinguish different instances.
[0256] In the synchronization module, the automatic synchronization and update method is as follows:
[0257] Monitor the modification event of the node resource file: When the node resource file is saved, the synchronization mechanism is triggered; the synchronization mechanism updates the attributes of node instances one by one by traversing all node instances associated with the node resource file in the map scene; then, by traversing all attributes of the node resource file and node instances, the synchronization process is optimized to only update the attributes that have changed, reducing performance overhead.
[0258] Record the change amount through the difference array in the difference algorithm and perform interval update. Recording the change amount through the difference array is to determine which attributes have changed during the synchronization of attributes, and then update the changed attributes. The steps are as follows:
[0259] (1) Initialize the difference array;
[0260] Set an original array A with length n, initialize a difference array D with the same length as the original array A, and set all elements to 0 during initialization; the definition of the difference array D is as follows:
[0261] D[0] = A[0];
[0262] D[i] = A[i] - A[i - 1], where 1 <= i < n;
[0263] (2) Interval update operation;
[0264] Add a value delta to each element in the interval [l, r] of the original array A; record this change in the difference array D through the following steps:
[0265] Increase the influence of the start position:
[0266] D[l] = D[1] + delta;
[0267] This means that starting from position l, the elements of the original array A will increase by delta;
[0268] If r + 1 is within the range of the original array, reduce the influence after the end position. If r + 1 = n, there is no need to reduce the influence after the end position because there is no influence beyond the boundary of the original array. The operation to reduce the influence after the end position is:
[0269] D[r + 1] = D[r + 1] - delta;
[0270] This means that starting from position r + 1, the added delta effect ends;
[0271] (3) Construct the updated original array;
[0272] Using the difference array D, reconstruct the updated original array A, and the specific steps are as follows:
[0273] Initialize an array A' as an all-zero array, or directly perform accumulation on the original array A, or reuse the initial value of A;
[0274] Traverse the difference array D and reconstruct the array A' by accumulating the prefix sum:
[0275] A'[0] = D[0];
[0276] A'[i] = A'[i - 1] + D[i], where 1 <= i < n,
[0277] In this way, A' is the updated original array.
[0278] For large-scale map scenarios, adopt a chunk loading method to avoid performance issues caused by synchronizing a large number of node instances at once; chunk loading is to divide the large-scale map scenario into multiple small chunks for dynamic loading as needed, reducing the burden of one-time loading.
[0279] The selection module is further specifically: when the attribute of a certain node instance is modified, according to the user's selection, whether to synchronize the modification content back to the node resource file;
[0280] If it is selected to synchronize the modification content back to the node resource file, the node resource file will be updated, and all other node instances will also be synchronously updated; extract the modification content of the node instance and update it to the node resource file; after synchronization is completed, all other instances will be automatically updated to maintain consistency with the resource file;
[0281] When synchronizing back to the node resource file, according to the user's selection, whether to overwrite the original attribute or merge the modification content.
[0282] Two-way synchronization between the node resource file and the node instance is achieved through the event listening mechanism and the callback mechanism;
[0283] (1) Event listening mechanism: (a) Set up an event: Trigger an event when the node resource file or the node instance changes;
[0284] (b) Define the monitoring type: Define the types of events that need to be listened to;
[0285] (c) Monitoring changes in node resource files:
[0286] File monitoring: Use a file monitoring mechanism to monitor changes in node resource files; by reading the file, determine whether the file content has changed;
[0287] Event triggering: When the file changes, trigger the corresponding event and use the changed information as a parameter of the event;
[0288] (d) Monitoring changes in node instances:
[0289] Instance observation: When the attributes or status of a node instance change, trigger the corresponding event;
[0290] Event triggering: When the location, size, or color attributes of a node instance change, trigger a node attribute update event;
[0291] (2) Callback mechanism: (a) Registering a callback: Register a callback function for the event. The callback function will be called when the event is triggered and is used to handle synchronous logic;
[0292] (b) Implementing the callback:
[0293] Synchronization from node resource files to node instances: When the node resource file changes, the callback function is responsible for loading new data from the node resource file and updating the corresponding node instance;
[0294] Synchronization from node instances to node resource files: When the node instance changes, the callback function is responsible for writing the changes back to the node resource file; manage the changes by directly modifying the node resource file.
[0295] In summary, the present invention can achieve efficient resource reuse and editing.
[0296] The above are only the preferred embodiments of the present invention and should not be construed as limitations on this application. Any equivalent changes and modifications made within the scope of the patent application of the present invention shall fall within the scope covered by the present invention.
Claims
1. A method for synchronous editing of node resources, characterized in that, The method includes the following steps: Step 1: Create an empty node resource file, which will be used as a template. Step 2: Add objects to the node resource file, and the objects are copied to the map scene when instantiated. Step 3: Add the node resource file to the map scene to generate node instances. Step 4: When the properties of the node resource file are modified, all node instances generated based on this node resource file will be automatically synchronized and updated to maintain consistency with the template. Step 5: When the properties of a certain node instance are modified, it is determined according to the user's choice whether to synchronize the modified content back to the node resource file.
2. The method for synchronously editing node resources according to claim 1, wherein The specific content of step 3 is further as follows: When a node instance is instantiated, a unique ID is generated for each node instance to identify and distinguish different instances.
3. A method for synchronous editing of node resources according to claim 1, characterized in that, In step 4, the automatic synchronization and update method is as follows: Listen for modification events of the node resource file: When the node resource file is saved, trigger the synchronization mechanism; the synchronization mechanism traverses all node instances associated with this node resource file in the map scene and updates the properties of the node instances one by one; then, by traversing all properties of the node resource file and node instances, optimize the synchronization process, only update the properties that have changed, and reduce performance overhead.
4. A method for synchronously editing node resources according to claim 3, characterized in that, Record the change amount through the difference array in the difference algorithm and perform interval update. Recording the change amount through the difference array is to determine which properties have changed during the process of synchronizing properties, and then update the properties that have changed. The steps are as follows: (1) Initialize the difference array; Set an original array A with length n, initialize a difference array D with the same length as the original array A, and set all elements to 0 during initialization; the definition of the difference array D is as follows: D[0] = A[0]; D[i] = A[i] - A[i - 1], where 1 <= i < n; (2) Interval update operation; Add a value delta to each element in the interval [l, r] of the original array A. Record this change in the difference array D through the following steps: Increase the influence of the start position: D[l] = D[1] + delta; This means that starting from position l, the elements of the original array A will increase by delta; If r + 1 is within the range of the original array, reduce the influence after the end position. If r + 1 = n, there is no need to reduce the influence after the end position because there is no influence beyond the boundary of the original array. The operation to reduce the influence after the end position is: D[r + 1] = D[r + 1] - delta; This means that starting from position r + 1, the increased delta influence ends; (3) Construct the updated original array; Reconstruct the updated original array A through the difference array D. The specific steps are as follows: Initialize an array A' as an all-zero array, or directly perform accumulation on the original array A, or reuse the initial value of A; Traverse the difference array D and reconstruct the array A' by accumulating the prefix sum: A'[0] = D[0]; A'[i] = A'[i - 1] + D[i], where 1 <= i < n, In this way, A' is the updated original array.
5. The method for synchronously editing node resources according to claim 3, wherein For large-scale map scenarios, a chunk-loading method is adopted to avoid performance issues caused by synchronizing a large number of node instances at once; chunk-loading divides the large-scale map scenario into multiple small chunks for dynamic loading as needed, reducing the burden of one-time loading.
6. A method for synchronously editing node resources according to claim 1, characterized in that, Step 5 is further specified as follows: when the attributes of a certain node instance are modified, it is determined whether the modified content needs to be synchronized back to the node resource file according to the user's selection; If it is selected to synchronize the modified content back to the node resource file, the node resource file will be updated, and all other node instances will also be updated synchronously; the modified content of the node instance is extracted and updated to the node resource file; After synchronization is completed, all other instances will be automatically updated to maintain consistency with the resource file; When synchronizing back to the node resource file, it is determined whether to overwrite the original attributes or merge the modified content according to the user's selection.
7. A method for synchronous editing of node resources according to claim 6, characterized in that, Bidirectional synchronization between the node resource file and the node instance is achieved through an event listening mechanism and a callback mechanism; (1) Event listening mechanism: (a) Establish an event: An event is triggered when the node resource file or the node instance changes; (b) Define the monitoring type: Define the types of events that need to be listened to; (c) Listen for changes in the node resource file: File monitoring: Use a file monitoring mechanism to listen for changes in the node resource file; by reading the file, it is determined whether the file content has changed; Event triggering: When the file changes, the corresponding event is triggered, and the changed information is used as a parameter of the event; (d) Listen for changes in the node instance: Instance observation: When the attributes or status of the node instance change, the corresponding event is triggered; Event triggering: When the position, size, or color attributes of the node instance change, a node attribute update event is triggered; (2) Callback mechanism: (a) Register a callback: Register a callback function for the event. The callback function will be called when the event is triggered and is used to handle the synchronization logic; (b) Implement the callback: Synchronization from the node resource file to the node instance: When the node resource file changes, the callback function is responsible for loading new data from the node resource file and updating the corresponding node instance; Synchronization from the node instance to the node resource file: When the node instance changes, the callback function is responsible for writing the changes back to the node resource file; the changes are managed by directly modifying the node resource file.
8. A system for synchronous editing of node resources, characterized in that, The system includes a creation module, an addition module, a generation module, a synchronization module, and a selection module; Creation module: Create an empty node resource file, which will be used as a template; Addition module: Add objects to the node resource file, and the objects are copied to the map scenario when instantiated; Generation module: Add the node resource file to the map scenario to generate node instances; Synchronization module: When the attributes of the node resource file are modified, all node instances generated based on this node resource file will be automatically updated synchronously to maintain consistency with the template; Selection module: When the attributes of a certain node instance are modified, it is determined whether the modified content needs to be synchronized back to the node resource file according to the user's selection.
9. A system for synchronous editing of node resources according to claim 8, characterized in that, The generation module is further specifically as follows: When a node instance is instantiated, a unique ID is generated for each node instance to identify and distinguish different instances.
10. A system for synchronous editing of node resources according to claim 8, characterized in that, In the synchronization module, the automatic synchronization and update method is as follows: Monitor the modification event of the node resource file: When the node resource file is saved, trigger the synchronization mechanism; The synchronization mechanism updates the attributes of node instances one by one by traversing all node instances associated with the node resource file in the map scene; Then, by traversing all attributes of the node resource file and node instances, optimize the synchronization process, only update the attributes that have changed, and reduce the performance overhead.
11. A system for synchronous editing of node resources according to claim 10, characterized in that, Record the change amount through the difference array in the difference algorithm and perform interval update. Recording the change amount through the difference array is to determine which attributes have changed during the synchronization of attributes, and then update the attributes that have changed. The steps are as follows: (1) Initialize the difference array; Set an original array A with a length of n, initialize a difference array D with the same length as the original array A, and set all elements to 0 during initialization; The definition of the difference array D is as follows: D[0] = A[0]; D[i] = A[i] - A[i - 1], where 1 <= i < n; (2) Interval update operation; Add a value delta to each element in the interval [l, r] of the original array A; Record this change in the difference array D through the following steps: Increase the influence of the start position: D[l] = D[1] + delta; This means that starting from position l, the elements of the original array A will increase by delta; If r + 1 is within the range of the original array, reduce the influence after the end position. If r + 1 = n, there is no need to reduce the influence after the end position because there is no influence beyond the boundary of the original array; The operation to reduce the influence after the end position is: D[r + 1] = D[r + 1] - delta; This means that starting from position r + 1, the increased delta influence ends; (3) Construct the updated original array; Rebuild the updated original array A through the difference array D. The specific steps are as follows: Initialize an array A' as an all-zero array, or directly perform accumulation on the original array A, or reuse the initial value of A; Traverse the difference array D and rebuild the array A' by accumulating the prefix sum: A'[0] = D[0]; A'[i] = A'[i - 1] + D[i], where 1 <= i < n, In this way, A' is the updated original array.
12. A system for synchronously editing node resources according to claim 10, characterized in that, For large-scale map scenes, adopt the method of block loading to avoid performance problems caused by synchronizing a large number of node instances at one time; Block loading is to divide the large-scale map scene into multiple small blocks for dynamic loading according to needs, reducing the burden of one-time loading.
13. A system for synchronous editing of node resources according to claim 8, characterized in that, The selection module is further specifically as follows: When the attributes of a certain node instance are modified, determine whether to synchronize the modified content back to the node resource file according to the user's selection; If it is selected to synchronize the modified content back to the node resource file, the node resource file will be updated, and all other node instances will also be synchronously updated; Extract the modified content of the node instance and update it to the node resource file. After synchronization is completed, all other instances will be automatically updated to maintain consistency with the resource file; When synchronizing back to the node resource file, it is determined whether to overwrite the original attributes or merge the modified content according to the user's selection.
14. A system for synchronous editing of node resources according to claim 13, characterized in that, Two-way synchronization between the node resource file and the node instance is achieved through the event listening mechanism and the callback mechanism; (1) Event listening mechanism: (a) Establish events: Events are triggered when changes occur to the node resource file or the node instance; (b) Define monitoring types: Define the types of events that need to be listened for; (c) Listen for changes to the node resource file: File monitoring: Use the file monitoring mechanism to listen for changes to the node resource file; By reading the file, determine whether the file content has changed; Event triggering: When the file changes, trigger the corresponding event and use the changed information as a parameter of the event; (d) Listen for changes to the node instance: Instance observation: When changes occur to the attributes or status of the node instance, trigger the corresponding event; Event triggering: When changes occur to the position, size, or color attributes of the node instance, trigger the node attribute update event; (2) Callback mechanism: (a) Register callbacks: Register callback functions for events. The callback functions will be called when the events are triggered and are used to handle the synchronization logic; (b) Implement callbacks: Synchronization from the node resource file to the node instance: When changes occur to the node resource file, the callback function is responsible for loading new data from the node resource file and updating the corresponding node instance; Synchronization from the node instance to the node resource file: When changes occur to the node instance, the callback function is responsible for writing the changes back to the node resource file; Manage the changes by directly modifying the node resource file.