CN114840809A - Fixed point number-based accurate physical system synchronization method - Google Patents

Fixed point number-based accurate physical system synchronization method Download PDF

Info

Publication number
CN114840809A
CN114840809A CN202210569832.XA CN202210569832A CN114840809A CN 114840809 A CN114840809 A CN 114840809A CN 202210569832 A CN202210569832 A CN 202210569832A CN 114840809 A CN114840809 A CN 114840809A
Authority
CN
China
Prior art keywords
physical
bits
fixed
physical system
synchronization
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210569832.XA
Other languages
Chinese (zh)
Inventor
余田
李佳黎
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Changyu Spacetime Network Technology Co ltd
Original Assignee
Shenzhen Changyu Spacetime Network Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Changyu Spacetime Network Technology Co ltd filed Critical Shenzhen Changyu Spacetime Network Technology Co ltd
Priority to CN202210569832.XA priority Critical patent/CN114840809A/en
Publication of CN114840809A publication Critical patent/CN114840809A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F17/00Digital computing or data processing equipment or methods, specially adapted for specific functions
    • G06F17/10Complex mathematical operations
    • G06F17/15Correlation function computation including computation of convolution operations
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F17/00Digital computing or data processing equipment or methods, specially adapted for specific functions
    • G06F17/10Complex mathematical operations
    • G06F17/16Matrix or vector computation, e.g. matrix-matrix or matrix-vector multiplication, matrix factorization

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Computational Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Mathematical Analysis (AREA)
  • Mathematical Optimization (AREA)
  • Pure & Applied Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Algebra (AREA)
  • Databases & Information Systems (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Computing Systems (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The invention discloses a precise physical system synchronization method based on fixed point number. The physical system synchronization method provided by the invention can solve the problems of floating point number precision of physical simulation and network physical synchronization, ensures that physical simulation results on different equipment terminals are consistent, and greatly reduces the calculation burden and synchronization burden of a server. Meanwhile, the simplified synchronization process obviously improves the user experience. Taking the inventor's self-research game actually using the technology as an example, the recovery synchronization time after use is reduced from 30 seconds to 10 seconds, and the problem of flicker caused by physical asynchronism in the playing process of the user is completely solved. The technology has very high expansibility, and the processing scheme for the floating point precision problem can be not only applied to a physical system, but also used for solving any problems caused by floating point calculation precision and floating point errors of different equipment.

Description

Fixed point number-based accurate physical system synchronization method
Technical Field
The invention relates to the technical field of game production engine software and development systems, in particular to a precise physical system synchronization method based on fixed points.
Background
Because of the internal principle of computer digital operation, hardware units such as a computer memory, a cpu register and the like are limited, can only represent binary digits with limited digits, and cannot strictly convert the binary digits and decimal digits, the problem of inaccurate floating point number exists, and a small error exists when numerical values with more calculated digits and higher precision are generated. Usually it is negligible, but in situations where large amounts of computation are required, or where the requirements for synchronization are high, error problems can arise.
On the other hand, hardware of different machine terminals also has different implementation manners for data calculation, which causes the same calculation, and results obtained after different CPUs calculate have slight differences, which is another error source for network synchronization.
For the two common network asynchronizations caused by the floating point number accuracy problem, a plurality of items are synchronously confirmed at regular intervals, and if the error reaches a certain degree, synchronous recovery is carried out according to the data of a certain party. Or the computation is performed on a unified server and then the data is synchronized according to the server.
However, the above methods still have limitations, and firstly, the situation of synchronization recovery affects the user experience to different degrees, and according to different situations, problems of picture blockage, position flash, operation delay and the like may occur during synchronization. On the other hand, not all modules are suitable for being placed on a server to realize calculation, and for some modules with higher calculation complexity or for some modules with higher real-time requirements, such as physical systems, for example, some modules in the first-person shooter play method, if the modules are placed on the server to calculate, a larger load of the server is generated, and the real-time performance cannot be well met.
Accordingly, the prior art is deficient and needs improvement.
Disclosure of Invention
The invention aims to overcome the defects of the prior art, provides a fixed point number-based accurate physical system synchronization method, solves the problems of floating point precision and different machine physical asynchronism in the physical simulation and synchronization of the conventional online game, and solves the problems of reduced user experience and overhigh server performance consumption caused by the commonly used synchronization recovery technology to ensure synchronization.
The technical scheme of the invention is as follows: the precise physical system synchronization method based on fixed point number is provided, and comprises the following steps:
step 1: replacing and expressing all fixed point or floating point numbers by 64-bit binary fixed point numbers;
step 2: repackaging the related constructors, including long integer, and string;
and step 3: rewriting a bottom layer calculation function in a fixed point number mode to realize a digital calculation library;
and 4, step 4: through the rewritten bottom layer calculation function, the physical engine system is realized, including the simulation of the speed, the quality and the force of the foundation, and the polygonal collider and the trigger are realized by using an AABB bounding box method preprocessing method and a GJK algorithm;
and 5: based on the physical engine, all physical calculations are placed at the client, and the network synchronization process is simplified.
Further, the specific steps of step 1 are: all fixed or floating point numbers are expressed using a 64-bit fixed point number with 1 st as the sign bit, 2 nd to 48 th as the integer bit, and 49 th to 64 th as the decimal bits.
Further, the constructor encapsulated in step 2 is as follows:
constructor (long _ raw): directly storing;
constructor (int _ raw): shifting a ray to the left by 16 bits and storing;
constructor (string _ raw): the character string is divided by first determining whether there is a symbol, and then taking the integer digit and the decimal digit respectively.
Further, the step 3 rewrites the specific implementation of the underlying computation function as follows:
total length totalBits ═ 64 bits;
fractional part length decimalBits 16 bits;
integer + sign length intBits 48 bits;
the decimal mask f _ mask >48 ═ 11111111;
the decimal range f _ range +1 is 100000000;
and (3) addition: the storage structures are directly added;
and (3) subtraction: direct subtraction of storage structures;
multiplication: multiplying the storage structure by a decimal place which is shifted to the right by 0.5;
division: the dividend storage structure is left shifted to reserve a small number of bits, which are divided by the divisor.
By adopting the scheme, the physical system synchronization method provided by the invention can solve the problems of floating point number precision of physical simulation and network physical synchronization, ensures that physical simulation results on different equipment terminals are consistent, and greatly reduces the calculation burden and synchronization burden of the server. Meanwhile, the simplified synchronization process obviously improves the user experience. Taking the inventor's self-research game actually using the technology as an example, the recovery synchronization time after use is reduced from 30 seconds to 10 seconds, and the problem of flicker caused by physical asynchronism in the playing process of the user is completely solved. The technology has very high expansibility, and the processing scheme for the floating point precision problem can be not only applied to a physical system, but also used for solving any problems caused by floating point calculation precision and floating point errors of different equipment.
Drawings
Fig. 1 is a schematic diagram of a fixed-point finding fixdcial storage structure.
Fig. 2 is a code diagram of an addition calculation function.
FIG. 3 is a code diagram of a subtraction calculation function.
Fig. 4 is a code diagram of a multiplication function.
FIG. 5 is a code diagram of a division calculation function.
FIG. 6 is a code diagram of a fixed-point matrix.
FIG. 7 is a code diagram of the open square root of the Newton's iterative algorithm.
FIG. 8 is a diagram of vector relationship of vector dot product.
FIG. 9 is a code diagram of vector dot product.
FIG. 10 is a diagram of vector relationships for vector cross-multiplication.
FIG. 11 is a code diagram of vector cross multiplication.
Fig. 12 is a code diagram of a matrix x vector.
FIG. 13 is a code diagram of other matrix functions.
Fig. 14 is a schematic diagram of a figure structure in which an AABB frame surrounds a circle.
Fig. 15 is a code diagram of an AABB frame enclosing a circle.
Fig. 16 is a schematic diagram of a rectangular structure in which the AABB frame surrounds a circle.
Fig. 17 is a code diagram of an AABB frame enclosing rectangle.
FIG. 18 is a GJK collision detection Minkowski difference graph.
Detailed Description
The invention is described in detail below with reference to the figures and the specific embodiments.
The invention provides a precise physical system synchronization method based on fixed point number, which comprises the following steps:
step 1: referring to FIG. 1, instead of expressing all fixed or floating point numbers, a 64-bit binary fixed point number is shown. The method comprises the following specific steps: all fixed or floating point numbers are expressed using a 64-bit fixed point number with 1 st as the sign bit, 2 nd to 48 th as the integer bit, and 49 th to 64 th as the decimal bits.
Step 2: repackaging related constructors including long integer (long), int, and string (string). The encapsulated constructor is as follows:
constructor (long _ raw): directly storing;
constructor (int _ raw): shifting a ray to the left by 16 bits and storing;
constructor (string _ raw): the character string is divided by first determining whether there is a symbol, and then taking the integer digit and the decimal digit respectively.
And step 3: and rewriting the bottom layer calculation function in a fixed point number mode to realize a digital calculation library. Further, the underlying calculation function is rewritten in a fixed point number mode, and the most basic addition, subtraction, multiplication and division is included, the complex matrix transformation is included, and the vector calculation function is included. Therefore, all numerical values are guaranteed to be calculated, the calculation is carried out by using the standard fixed point number, and the calculation error is prevented from being generated. Meanwhile, for the calculation of fixed point numbers, the calculation results on different devices are consistent, so that device errors are prevented. The concrete implementation is as follows:
total length totalBits ═ 64 bits;
fractional part length decimalBits 16 bits;
integer + sign length intBits 48 bits;
the decimal mask f _ mask >48 ═ 11111111;
the decimal range f _ range +1 is 100000000;
and (3) addition: referring to FIG. 2, the storage structures are directly added;
and (3) subtraction: referring to FIG. 3, the storage structures are subtracted directly;
multiplication: referring to FIG. 4, the multiplication of the storage structure plus 0.5 shifts the more decimal place to the right;
division: referring to FIG. 5, the dividend storage structure is left shifted to reserve a small number of bits, divided by the divisor.
Matrix calculation and other mathematical calculation libraries:
fixed-point two-dimensional vector: the two-dimensional vector FixVector (x, y) is implemented with fixed-point numbers.
Fixed-point matrix 2 × 2: referring to fig. 6, it is implemented with two fixed-point two-dimensional vectors;
the square root is shown in FIG. 7, and is calculated using the Newton's iterative algorithm;
vector dot product: referring to fig. 8 and 9, the specific steps are as follows:
s1. if dot is greater than 0, the angle between the vectors a and b is-90 to 90 degrees, the vectors a and b point to the same direction;
s2, if dot is 0, the included angle between the vectors a and b is 90 ° or 270 °, and the vectors a and b are perpendicular to each other;
s3. if dot is less than 0, the angle between vectors a and b is 90-270 deg., and vectors a and b point in opposite directions;
s4. if a is the unit vector, dot represents the mapping length of the vector b in the a direction.
Vector cross multiplication: referring to fig. 10 and 11, the specific steps are as follows:
s1.a×b=|a||b|·sinθ;
s2. if cross > 0: taking the angle ab as 0-180 degrees;
s3. if cross is 0: angle ab is 0-180 °;
s4. if cross < 0: the angle ab is 180 DEG;
s5. if a is a unit vector, cross indicates the mapping length of b in the direction perpendicular to a;
referring to fig. 12, matrix × vector: if the matrix is a rotation matrix, the vector will transform the matrix into another coordinate system.
Referring to fig. 13, as well as other matrix functions, such as matrix multiplication, inverse matrix of a, rotation angle multiplication, rotation angle (q is inverse) multiplication, rotation by q angle of v (vector/coordinate point), inverse rotation by q angle of v (vector/coordinate point), transformation of v (vector/coordinate point) to T coordinate, inverse transformation of v (vector/coordinate point) to T coordinate system, or inverse transformation.
The calculation requirement of the physical engine system is realized by establishing a mathematical calculation library such as matrix calculation.
And 4, step 4: the physical system including the simulation of speed, mass and force of the foundation is realized by using the repackaging bottom layer computing method, and further, all convex polygonal colliders and triggers such as circles, rectangles and the like are realized by using an AABB bounding box method preprocessing method and a GJK (Gilbert-Johnson-Keerthi) algorithm. The method comprises the following specific steps:
AABB frame: and enclosing the graph for calculating the AABB extent border. Referring to fig. 14-17, it is commonly used to calculate the extent bounding box that encloses a circular image with an AABB box and to calculate the extent bounding box that encloses a rectangular image with an AABB box.
And (3) GJK collision detection: any shape of convex surface is supported.
The principle is as follows: whether the two patterns are in contact and collision is judged by calculating Minkowski difference patterns of the two patterns and judging whether the Minkowski difference patterns contain the original point.
As shown in figure 18 of the drawings,
rectangles (0,0), (0,1), (2,1), (2,0), triangles (0,2), (-1,0), (1,0),
rectangle vertex-triangle vertex ═ 2, -1, (1,1), (3,1), (2, -2), (1,0), (3,0), (0, -1), (1, -1), (0, -2), ((-1, 0), and the transferred pattern passes through the origin and the two patterns touch.
And 5: based on the physical engine, all physical calculations are placed at the client, and the network synchronization process is simplified. Based on the physical engine realized by the self, the network synchronization process is greatly simplified. Firstly, all physical calculations can be placed at the client, and the current physical calculation results of different terminals are completely consistent, so that the burden of the server is greatly reduced. Further, the server need only synchronize a small amount of critical information, such as blood volume, number of rounds, etc. And for abnormal conditions such as disconnection reconnection, network signal difference and the like, when synchronous recovery is carried out, only simulation is carried out on the client side, the calculation result is ensured to be consistent, and the battle can be recovered by quickly carrying out the same process simulation after key operation information is stored.
In conclusion, the physical system synchronization method provided by the invention can solve the problems of floating point number precision of physical simulation and network physical synchronization, ensures that physical simulation results on different equipment terminals are consistent, and greatly reduces the calculation burden and synchronization burden of the server. Meanwhile, the simplified synchronization process obviously improves the user experience. Taking the inventor's self-research game actually using the technology as an example, the recovery synchronization time after use is reduced from 30 seconds to 10 seconds, and the problem of flicker caused by physical asynchronism in the playing process of the user is completely solved.
Furthermore, the technology has very high expansibility, the processing scheme for the floating point precision problem can be not only applied to a physical system, but also used for solving any problems caused by the floating point calculation precision and floating point errors of different devices.
The present invention is not limited to the above preferred embodiments, and any modifications, equivalent substitutions and improvements made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (4)

1. A precise physical system synchronization method based on fixed point number is characterized by comprising the following steps:
step 1: replacing and expressing all fixed point or floating point numbers by 64-bit binary fixed point numbers;
step 2: repackaging the related constructors, including long integer, and string;
and step 3: rewriting a bottom layer calculation function in a fixed point number mode to realize a digital calculation library;
and 4, step 4: through the rewritten bottom layer calculation function, the physical engine system is realized, including the simulation of the speed, the quality and the force of the foundation, and the polygonal collider and the trigger are realized by using an AABB bounding box method preprocessing method and a GJK algorithm;
and 5: based on the physical engine, all physical calculations are placed at the client, and the network synchronization process is simplified.
2. The fixed-point-number-based precise physical system synchronization method according to claim 1, wherein the specific steps of the step 1 are as follows: all fixed or floating point numbers are expressed using a 64-bit fixed point number with bit 1 as the sign bit, bits 2-48 as the integer bit, and bits 49-64 as the decimal bit.
3. The fixed-point-number-based precise physical system synchronization method according to claim 1, wherein the constructor encapsulated in the step 2 is as follows:
constructor (long _ raw): directly storing;
constructor (int _ raw): shifting a ray to the left by 16 bits and storing;
constructor (string _ raw): the character string is divided by first determining whether there is a symbol, and then taking the integer digit and the decimal digit respectively.
4. The fixed-point-number-based accurate physical system synchronization method according to claim 1, wherein the step 3 rewrites the specific implementation of the underlying computation function as follows:
total length totalBits ═ 64 bits;
fractional part length decimalBits 16 bits;
integer + sign length intBits 48 bits;
the decimal mask f _ mask >48 ═ 11111111;
the decimal range f _ range +1 is 100000000;
and (3) addition: the storage structures are directly added;
and (3) subtraction: direct subtraction of storage structures;
multiplication: multiplying the storage structure by a decimal place which is shifted to the right by 0.5;
division: the dividend storage structure is left shifted to reserve a small number of bits, which are divided by the divisor.
CN202210569832.XA 2022-05-24 2022-05-24 Fixed point number-based accurate physical system synchronization method Pending CN114840809A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210569832.XA CN114840809A (en) 2022-05-24 2022-05-24 Fixed point number-based accurate physical system synchronization method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210569832.XA CN114840809A (en) 2022-05-24 2022-05-24 Fixed point number-based accurate physical system synchronization method

Publications (1)

Publication Number Publication Date
CN114840809A true CN114840809A (en) 2022-08-02

Family

ID=82572819

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210569832.XA Pending CN114840809A (en) 2022-05-24 2022-05-24 Fixed point number-based accurate physical system synchronization method

Country Status (1)

Country Link
CN (1) CN114840809A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109992459A (en) * 2019-03-29 2019-07-09 苏州中晟宏芯信息科技有限公司 Data transfer device, device, equipment and storage medium
CN111542826A (en) * 2017-12-29 2020-08-14 斯佩罗设备公司 Digital architecture supporting analog coprocessors
US20200302330A1 (en) * 2019-03-18 2020-09-24 Microsoft Technology Licensing, Llc Outlier quantization for training and inference
CN111744177A (en) * 2020-07-28 2020-10-09 腾讯科技(深圳)有限公司 Game data processing method and device, storage medium and electronic equipment

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111542826A (en) * 2017-12-29 2020-08-14 斯佩罗设备公司 Digital architecture supporting analog coprocessors
US20200302330A1 (en) * 2019-03-18 2020-09-24 Microsoft Technology Licensing, Llc Outlier quantization for training and inference
CN109992459A (en) * 2019-03-29 2019-07-09 苏州中晟宏芯信息科技有限公司 Data transfer device, device, equipment and storage medium
CN111744177A (en) * 2020-07-28 2020-10-09 腾讯科技(深圳)有限公司 Game data processing method and device, storage medium and electronic equipment

Similar Documents

Publication Publication Date Title
US11842438B2 (en) Method and terminal device for determining occluded area of virtual object
US8090756B2 (en) Method and apparatus for generating trigonometric results
CN112162723A (en) Quantum addition operation method and device, electronic device and storage medium
CN110263294B (en) Method and device for determining loss function value and electronic equipment
US20230254145A1 (en) System and method to improve efficiency in multiplicationladder-based cryptographic operations
US5957996A (en) Digital data comparator and microprocessor
CN116028013A (en) Optimization method, device, divider and medium for FPGA division operation
CN116700663A (en) Floating point number processing method and device
CN114840809A (en) Fixed point number-based accurate physical system synchronization method
CN111610959A (en) Two-dimensional, multi-dimensional and data processing method
CN111768331A (en) Optimization method and device
WO2023124362A1 (en) Floating point number processing method and apparatus, electronic device and storage medium
CN114119661A (en) Target tracking processor, target tracking method and device
CN116700664A (en) Method and device for determining square root of floating point number
US8275821B2 (en) Area efficient transcendental estimate algorithm
Altamimi et al. Novel seed generation and quadrature-based square rooting algorithms
CN116700665B (en) Method and device for determining floating point number square root reciprocal
CN115374188B (en) Resource state query method and device, electronic equipment and storage medium
Gladshtein Algorithmic synthesis of a combinational adder of decimal digits encoded by the Johnson-Mobius code
US20230376276A1 (en) Quantum division operation method and apparatus with precision
JP7290177B2 (en) Secure computing device, secure computing method, and program
Sudiro et al. Mean and variance statistic for image processing on FPGA
CN116301648A (en) Data processing device, method, electronic device, and storage medium
JP2002049931A (en) Method for generating image
Gayatri et al. Synthesizable Implementation of 2N/N Binary Division

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20220802

RJ01 Rejection of invention patent application after publication