Posts: 14
Threads: 9
Joined: Dec 2020
Reputation:
0
Hi!
I use actor.ResetParticles(); to reset rope to the former position.
When i use this is the actor data (like particles position) will be updated in the same time? or it will take a while?
If it need some times when can i use the new position data?
Posts: 6,322
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
28-12-2020, 03:48 PM
(This post was last modified: 28-12-2020, 03:48 PM by josemendez.)
(28-12-2020, 09:45 AM)FZMv587 Wrote: Hi!
I use actor.ResetParticles(); to reset rope to the former position.
When i use this is the actor data (like particles position) will be updated in the same time? or it will take a while?
If it need some times when can i use the new position data?
Most particle data will be updated immediately. If you take a look at the ResetParticle() source code, you'll see that solver.positions and solver.velocities are immediately written to:
Quote:public void ResetParticles()
{
if (isLoaded)
{
Matrix4x4 l2sTransform = actorLocalToSolverMatrix;
Quaternion l2sRotation = l2sTransform.rotation;
for (int i = 0; i < particleCount; ++i)
{
int solverIndex = solverIndices[i];
solver.positions[solverIndex] = l2sTransform.MultiplyPoint3x4(sourceBlueprint.positions[i]);
solver.velocities[solverIndex] = l2sTransform.MultiplyVector(sourceBlueprint.velocities[i]);
if (usesOrientedParticles)
{
solver.orientations[solverIndex] = l2sRotation * sourceBlueprint.orientations[i];
solver.angularVelocities[solverIndex] = l2sTransform.MultiplyVector(sourceBlueprint.angularVelocities[i]);
}
}
}
}
Some data however, such as solver.renderablePositions, will only be updated at the end of the next simulation step (FixedUpdate, LateUpdate, or whenever the solver is being updated, determined by what ObiUpdater component you're using).
cheers,
Posts: 14
Threads: 9
Joined: Dec 2020
Reputation:
0
(28-12-2020, 03:48 PM)josemendez Wrote: Most particle data will be updated immediately. If you take a look at the ResetParticle() source code, you'll see that solver.positions and solver.velocities are immediately written to:
Some data however, such as solver.renderablePositions, will only be updated at the end of the next simulation step (FixedUpdate, LateUpdate, or whenever the solver is being updated, determined by what ObiUpdater component you're using).
cheers, Thank you,bro
This is a big help!
Posts: 14
Threads: 9
Joined: Dec 2020
Reputation:
0
(28-12-2020, 03:48 PM)josemendez Wrote: Most particle data will be updated immediately. If you take a look at the ResetParticle() source code, you'll see that solver.positions and solver.velocities are immediately written to:
Some data however, such as solver.renderablePositions, will only be updated at the end of the next simulation step (FixedUpdate, LateUpdate, or whenever the solver is being updated, determined by what ObiUpdater component you're using).
cheers, Hi,it‘s me.
I got trouble again.
I made a rope and it's particles in "position1",then i move it to "position2", i need use "position1" to compare with "position2" and get a result.
But because of particles update system is not update immediately, "position2" data is not available yet, so is there any method can do this thing?
Wait for your answer.
Posts: 6,322
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
(29-12-2020, 08:28 AM)FZMv587 Wrote: Hi,it‘s me.
I got trouble again.
I made a rope and it's particles in "position1",then i move it to "position2", i need use "position1" to compare with "position2" and get a result.
But because of particles update system is not update immediately, "position2" data is not available yet, so is there any method can do this thing?
Wait for your answer.
Particle positions are updated immediately. See above.
I don’t quite understand your use case. Could you post the code you’re using?
Posts: 14
Threads: 9
Joined: Dec 2020
Reputation:
0
(29-12-2020, 09:36 AM)josemendez Wrote: Particle positions are updated immediately. See above.
I don’t quite understand your use case. Could you post the code you’re using?
Thank for you response.
Of course, no problem,there is my part code.
I use this code to get particles position,those particles can simulate "control point" position.
I have two ropes so i put them in a List.
index and position is global.
Code: void get_index()
{
for(int i = 0; i < numofballs.GetLength(0); i++)
{
for(int j = 0; j < numofballs[i]; j++)
{
index[i][j] = actor[i].solverIndices[rope[i].blueprint.groups[j].particleIndices[0]];
}
}
}
void get_position_now()
{
for(int i = 0; i < numofballs.GetLength(0); i++)
{
for(int j = 0; j < numofballs[i]; j++)
{
position_now[i][j,0] = actor[i].GetParticlePosition(index[i][j]).x;
position_now[i][j,1] = actor[i].GetParticlePosition(index[i][j]).y;
position_now[i][j,2] = actor[i].GetParticlePosition(index[i][j]).z;
}
}
}
And this is my move code.
action is a int variable come from other file.
I use ObiParticleAttachment to connect target paricle to rope position,so i can move target particle position when i move rope position.
controlling_ball is a array variable i use to save target particle umber.
Code: before_position = get_position_now();
int action = Convert.ToInt32(strArray[1]);
if(action == 0)
{
Vector3 to_new_position = new Vector3(0.0f, 0.0f, -position[controlling_ball[0]][controlling_ball[1],3]);
rope[controlling_ball[0]].gameObject.transform.Translate(to_new_position, Space.World);
}
if(action == 1)
{
Vector3 to_new_position = new Vector3(0.0f, 0.0f, position[controlling_ball[0]][controlling_ball[1],3]);
rope[controlling_ball[0]].gameObject.transform.Translate(to_new_position, Space.World);
}
if(action == 2)
{
Vector3 to_new_position = new Vector3(-position[controlling_ball[0]][controlling_ball[1],3], 0.0f, 0.0f);
rope[controlling_ball[0]].gameObject.transform.Translate(to_new_position, Space.World);
}
if(action == 3)
{
Vector3 to_new_position = new Vector3(position[controlling_ball[0]][controlling_ball[1],3], 0.0f, 0.0f);
rope[controlling_ball[0]].gameObject.transform.Translate(to_new_position, Space.World);
}
if(action == 4)
{
if(rope[controlling_ball[0]].gameObject.transform.position.y > position[controlling_ball[0]][controlling_ball[1],3])
{
Vector3 to_new_position = new Vector3(0.0f, -position[controlling_ball[0]][controlling_ball[1],3], 0.0f);
rope[controlling_ball[0]].gameObject.transform.Translate(to_new_position, Space.World);
}
}
if(action == 5)
{
Vector3 to_new_position = new Vector3(0.0f, position[controlling_ball[0]][controlling_ball[1],3], 0.0f);
rope[controlling_ball[0]].gameObject.transform.Translate(to_new_position, Space.World);
}
after_position = get_position_now()
You see, i want before_position and after_position, is this possible?
Wait for your answer
|