Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is DynamicBone?

2025-02-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article is to share with you about what DynamicBone is. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

DynamicBone is a simple physical simulation plug-in for tree-like flexible body based on the algorithm of simulating spring oscillator. Although it is based on the algorithm that simulates the motion of the spring oscillator, the distance between the nodes of the DynamicBone does not actually change. The relative motion between father and child nodes is closer to that of a simple pendulum in series than a spring.

Overall process diagram

The characteristics of the soft body simulated by DynamicBone are reflected in the elastic deformation of the object after motion. Therefore, its simulation occurs naturally after the motion of the object, and then simulates the elastic motion of each node according to the results of the motion of the object.

The overall flow of the DynamicBone obtained below is very simple. When the original movement of the object is completed, the elastic motion is simulated first according to the current results of the motion, and then the rotation of each node is modified according to the simulation results and the simulation results are synchronized to the actual nodes.

Among them, we call the original movement result of each node of the object in figure (2) as the ideal position, because although the elastic object will be deformed, it will eventually try to restore to its original shape. The result of the simulated motion is called the actual position. Because this is the result of the calculation, and will eventually be synchronized to the attached node.

Overall flow chart

In order to make it easier to distinguish, here we call the nodes of the DynamicBone as nodes, while the actual object nodes are subsidiary nodes.

The influence of the force is considered in the basket part, and the Welley integral method is used in the basket part, and the red frame part as a whole is the simulation part of the spring motion.

Preprocessing: additional global displacement

Before the spring motion simulation calculation begins, DynamicBone first multiplies the displacement of the current object by the inertia (Inert) parameter and then appends it to all nodes. This displacement will not participate in the subsequent motion simulation calculation process, and will directly change the actual position of the current frame and the previous frame, so this displacement will not be taken into account in the subsequent calculation. That is,

Spring motion simulation part 1: inertia motion-force motion

The first part of the spring motion simulation calculation is the inertial motion simulation, which is very easy to understand, that is, to keep the node moving at a speed, and the value of the speed is the difference of the actual position of the node in the simulation minus the damping (damping) value.

The second part of spring motion simulation is force motion simulation. In DynamicBone, the impression of two kinds of forces on node motion is considered, namely gravity (Gravity) and standing force (Force). The influence of these two forces on the motion process is different. It is easy to understand that the standing force is a force that acts unconditionally and is directly attached to the calculated results. The mechanism of gravity is special, gravity itself does not play a role, only the gravity component after the movement will affect the motion process. That is,

Spring motion simulation part 2: supplementary explanation of gravity calculation

Gravity calculation

In the initial state, gravity has no effect, but DynamicBone records the vector of gravity in the local coordinate system of the root node. In each calculation, DynamicBone calculates the projection of the changed local gravity vector in the direction of the initial gravity vector, and finally adds the initial gravity vector to the node minus the gravity of the projection vector. Because the vectors in the local coordinate system of the root node are recorded, only the rotation of the root node will cause gravity to work, while the rotation of the other nodes will not. And only when the local gravity projection is consistent with the global gravity direction, the global gravity subtracts the projection. If the direction is in the opposite direction (meaning that the root node is rotated by more than 180 degrees), global gravity will only work, without adding the projection length.

Spring motion simulation part 3: elastic motion-rigid motion

The third part of spring motion simulation is elastic motion simulation, which belongs to the autonomous motion of nodes, that is, it is not affected by force and speed, and the motion result will be regarded as speed (so it can be regarded as an internal force in essence). The process of elastic motion is very simple, which is to find out the difference between the current actual position and the ideal position of the node, and multiply the elastic (Elasticity) parameter to attach to the actual position. That is,

The fourth part of the spring motion simulation calculation is the rigid motion simulation, which also belongs to the joint autonomous motion. In order to explain the elastic motion, we must first introduce the ideal distance, that is, the distance between the ideal position of the parent and child nodes, that is, the original distance between the parent and child nodes. The Stiffness simulation first calculates the maximum distance of the node from the ideal position according to the rigidity (rigidity) parameters and the ideal distance, and limits the node to the distance. That is,

Spring motion simulation part 3: elastic motion-rigid motion

The third part of spring motion simulation is elastic motion simulation, which belongs to the autonomous motion of nodes, that is, it is not affected by force and speed, and the motion result will be regarded as speed (so it can be regarded as an internal force in essence). The process of elastic motion is very simple, which is to find out the difference between the current actual position and the ideal position of the node, and multiply the elastic (Elasticity) parameter to attach to the actual position. That is,

The fourth part of the spring motion simulation calculation is the rigid motion simulation, which also belongs to the joint autonomous motion. In order to explain the elastic motion, we must first introduce the ideal distance, that is, the distance between the ideal position of the parent and child nodes, that is, the original distance between the parent and child nodes. The Stiffness simulation first calculates the maximum distance of the node from the ideal position according to the rigidity (rigidity) parameters and the ideal distance, and limits the node to the distance. That is,

Collision detection and recovery 4

The collision detection of DynamicBone is very simple, which is to detect the collision between each node and each collision body one by one and recover according to the test results. DynamicBone offers two shapes of colliders, spherical and capsule shapes. The spherical collision detection is very simple. First, the distance between the node and the center of the sphere is calculated, and then the sum of the radius of the node and the radius of the collision body is obtained. If the distance is greater than the sum of radii (less than in Inside mode), the mobile node ensures that the distance is equal to the sum of radii.

The collision detection of the capsule is a little more complicated. First, the vector A between the two spherical centers of the capsule is obtained, then the vector B between the node center and one of the spherical centers is obtained, and then the projection of An on B is obtained. According to the projection result, the next step is judged, that is,

Collision detection and recovery

Then, when the projection direction is opposite to the vector A, the node is equivalent to collision detection and recovery with the sphere centered on the ball center A; if the direction projection direction is the same as the vector A but longer than the vector A, then the node is equivalent to collision detection and recovery with the sphere centered on ball center B.

If the direction projection direction is the same as that of vector An and shorter than vector A, the length of the projection vector of vector B in the direction perpendicular to vector An is taken. If the length is greater than the sum of radii, the moving node ensures that the distance is equal to the sum of radii.

Post-processing stage 5: maintain the distance between nodes

At the end of the simulation, DynamicBone has a simple post-processing to prevent stretching or compression between parent and child nodes and maintain the ideal distance between nodes. The step is simple: first find the difference vector of the actual distance of the current parent node, and then restore it to the ideal distance vector. That is,

Post-processing stage 6: correct node rotation and synchronous transformation

Before synchronizing the calculated node transformation to the subsidiary node, DynamicBone will also make a rotation correction according to the relative transformation between all levels of nodes. Each parent-child node will rotate to the same state as the initial value of the relative rotation of the child node as long as the parent node has only one child node.

Defect and optimization

Defect:

The main defect of DynamicBone is that it does not allow the distance between nodes to change, which leads to the fact that DynamicBone does not allow actual tension or compression, and the nodes of DynamicBone actually lack the nature of springs. Therefore, DynamicBone can not simulate objects that are prone to tensile deformation.

On the other hand, all the calculations of DynamicBone do not consider the time factor, so the performance of the same spring parameters will be very different under different update frequency parameters, which increases the difficulty of parameter adjustment.

Optimization:

The most commonly used LOD frequency reduction method or distant animation

C++ code, tested below compared with non-IL2CPP can be 2 times faster

Considering the computation of multiple DynamicBone objects in the same scene, the unified management of the computing process is combined.

Approximate calculation is carried out for the DynamicBone with similar position, such as ribbon, skirt and so on.

JobSystem and put it after BatchedIKPass

Transform in Unity only stores local-related information of Go, and various transformations are made when calculating Gloabl-related data, which is also the main reason for time-consuming.

Thank you for reading! This is the end of this article on "what is DynamicBone?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report