Esempio n. 1
0
 /**
  * Atomically Sets the parent of this transform
  *
  * @param parent
  */
 @Threadsafe
 public void setParent(Transform parent) {
   int seq = lock.writeLock();
   try {
     this.parent.set(parent);
   } finally {
     lock.writeUnlock(seq);
   }
 }
Esempio n. 2
0
 /**
  * Gets a String representation of this transform
  *
  * @return the string
  */
 @Override
 @Threadsafe
 public String toString() {
   while (true) {
     int seq = lock.readLock();
     String s = getClass().getSimpleName() + "{" + position + ", " + rotation + ", " + scale + "}";
     if (lock.readUnlock(seq)) {
       return s;
     }
   }
 }
Esempio n. 3
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);
   }
 }
Esempio n. 4
0
 /**
  * Atomically gets the parent of this Transform
  *
  * @return the parent
  */
 @Threadsafe
 public Transform getParent() {
   while (true) {
     int seq = lock.readLock();
     Transform result = null;
     try {
       result = parent.get();
     } finally {
       if (lock.readUnlock(seq)) {
         return result;
       }
     }
   }
 }
Esempio n. 5
0
 /**
  * Creates a Transform that is a copy of this transform
  *
  * @return the snapshot
  */
 @Threadsafe
 public Transform copy() {
   Transform t = new Transform();
   while (true) {
     int seq = lock.readLock();
     t.setPosition(position);
     t.setRotation(rotation);
     t.setScale(scale);
     t.setParent(parent.get());
     if (lock.readUnlock(seq)) {
       return t;
     }
   }
 }
Esempio n. 6
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;
     }
   }
 }
Esempio n. 7
0
 /**
  * Creates a Transform that is a snapshot of the absolute position of this transform
  *
  * @return the snapshot
  */
 @Threadsafe
 public Transform getAbsolutePosition() {
   while (true) {
     int seq = lock.readLock();
     if (parent == null) {
       Transform r = copy();
       if (lock.readUnlock(seq)) {
         return r;
       }
     } else {
       Transform r = createSum(parent.get().getAbsolutePosition());
       if (lock.readUnlock(seq)) {
         return r;
       }
     }
   }
 }
Esempio n. 8
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);
   }
 }
Esempio n. 9
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);
   }
 }
Esempio n. 10
0
 /**
  * Unlocks the optimistic read lock
  *
  * @param sequence the sequence number returned by readLock()
  * @return true if the Transform hasn't changed
  */
 public boolean readUnlock(int sequence) {
   return lock.readUnlock(sequence);
 }
Esempio n. 11
0
 /**
  * Optimistically Read locks the Transform
  *
  * @return the sequence number
  */
 public int readLock() {
   return lock.readLock();
 }