Пример #1
0
 /**
  * Atomically sets this point to the given components
  *
  * @param point
  */
 @Threadsafe
 public void set(Point p, Quaternion r, Vector3 s) {
   int seq = lock.writeLock();
   try {
     position.directSet(p);
     rotation.directSet(r);
     scale.directSet(s);
   } finally {
     lock.writeUnlock(seq);
   }
 }
Пример #2
0
 /**
  * Creates a Transform that is the sum of this transform and the given transform
  *
  * @param t the transform
  * @return the new transform
  */
 @Threadsafe
 public Transform createSum(Transform t) {
   Transform r = new Transform();
   while (true) {
     int seq = lock.readLock();
     r.setPosition(position.add(t.getPosition()));
     r.setRotation(rotation.multiply(t.getRotation()));
     r.setScale(scale.add(t.getScale()));
     r.setParent(parent.get());
     if (lock.readUnlock(seq)) {
       return r;
     }
   }
 }
Пример #3
0
 /**
  * Atomically sets the value of this transform to the value of another transform
  *
  * @param transform the other transform
  */
 @Threadsafe
 public void set(Transform transform) {
   if (lock == transform.getLock()) {
     throw new IllegalArgumentException(
         "Attemping to set a transform to another transform with the same lock");
   }
   int seq = lock.writeLock();
   try {
     while (true) {
       int seq2 = transform.getLock().readLock();
       position.directSet(transform.getPosition());
       rotation.directSet(transform.getRotation());
       scale.directSet(transform.getScale());
       if (transform.getLock().readUnlock(seq2)) {
         return;
       }
     }
   } finally {
     lock.writeUnlock(seq);
   }
 }
Пример #4
0
 /**
  * Atomically sets the value of this transform.
  *
  * @param world the world
  * @param px the x coordinate of the position
  * @param py the y coordinate of the position
  * @param pz the z coordinate of the position
  * @param rx the x coordinate of the quaternion
  * @param ry the y coordinate of the quaternion
  * @param rz the z coordinate of the quaternion
  * @param rw the w coordinate of the quaternion
  * @param sx the x coordinate of the scale
  * @param sy the y coordinate of the scale
  * @param sz the z coordinate of the scale
  */
 @Threadsafe
 public void set(
     World world,
     float px,
     float py,
     float pz,
     float rx,
     float ry,
     float rz,
     float rw,
     float sx,
     float sy,
     float sz) {
   int seq = lock.writeLock();
   try {
     position.directSet(world, px, py, pz);
     rotation.directSet(rx, ry, rz, rw);
     scale.directSet(sx, sy, sz);
   } finally {
     lock.writeUnlock(seq);
   }
 }