Hi guys,
I am having a rather confusing moment here, but the problem is more complex then the title… sorry I could not think of a better one for this topic.
As a side note, I am developing some custom classes inside visual studio using c#, then I reference the .dll file in to a c# component for testing functionality .
The problem I am having right now is with my Vec3 struct and my SharpParticle class. The SharpParticle’s constructor takes a Vec3 position, a Vec3 velocity… and so on.
The problem I am having is that When Vec3 is a struct and is used for the constructor of the SharpParticle object, the particle wont update its position successfully. But If I change Vec3 to be a class the particle will change its position successfully. The strange thing that I don’t understand is that I have done this operation many times in the past using RhinoCommon types. A classic example can be a flocking behaviour were an object of type Agent also takes a Point3d position, Vector3d velocity… etc… and the agents positions are updated successfully in the RhinoCommon world.
Any clues would be very helpful. Let me know If the source code of Vec3 and SharpParticle is needed.
You can see my code here:
using SharpMatter.SharpGeometry;
using SharpMatter.SharpPhysics;
using SharpMatter.SharpForces;
public class Script_Instance : GH_ScriptInstance
{
private void RunScript(bool run, bool reset, ref object A, ref object B)
{
if(run)
{
// particle.Update();
a += new Vec3(0.01, 0.04, 0);
Component.ExpireSolution(true);
}
if(reset)
{
// particle.Acceleration = Vec3.Zero;
// particle.Position = Vec3.Zero;
vecTest = Vec3.Zero;
}
//A = (Point3d) particle.Position; //Particle's position does not update when Vec3 is a struct, but it does when Vec3 is a class
A = (Point3d) vecTest ; // Vec3 position updates fine when Vec3 is a struct or a class
}
// <Custom additional code>
SharpParticle particle = new SharpParticle(Vec3.Zero, Vec3.Zero, new Vec3(0.01, 0.04, 0), 0.03, 0.03, 10, 100);
Vec3 vecTest = Vec3.Zero;
// </Custom additional code>
}