I have some code that uses the OCD library. It works fine in processing versions 0103 through 0108, but breaks in 0109 and remains broken in later versions. I don't know if the bug is in Processing or OCD; perhaps it should be discussed here before filing a bug report?
I've simplified the code as much as possible to isolate the bug, and the code is attached below.
There's a basic setup() which creates a Camera; a draw() which simply puts a sphere in the center of the world, lit by a single light; and a mouseDragged() function that allows rotating and viewing the model. (This last function is unnecessary to reproduce the bug, but useful to explore its nature.)
In versions of processing after 0109, the light moves, somewhat chaotically, after every frame. The movement gets more stranger after moving the camera (by dragging iwht the mouse). Uncomment the framerate(4) line to get a better view of what's happening. Before version 0109, the light remains still, as expected.
Specifically, the light moves every time camera1.feed() is called. If this function is moved into mouseDragged(), for example, the light only moves unexpectedly when the mouse is dragged to move the camera.
The only relevant change I see in version 0109 is this one:
+ fixes contributed by willis morse to deal with memory wastefulness.
these should help speed up some types of OPENGL and P3D mode sketches,
thanks willis!
I wonder if a bug was introduced here, or if this fix (or some other) revealed a bug in the OCD code.
If it matters, I'm running Processing on a Mac OS X machine.
Here's the code:
Quote:
import damkjer.ocd.*;
Camera camera1;
void setup() {
size(640, 480, P3D);
stroke(50,50,50,50);
fill(200,200,200);
camera1 = new Camera(this, 20, 20, 20, 0, 0, 0);
//framerate(4);
}
void draw() {
camera1.feed();
background(255);
directionalLight(200, 0, 0, -1, 0, 0);
sphere(10);
}
void mouseDragged() {
if (mouseButton == LEFT) {
camera1.tumble(radians(mouseX - pmouseX), radians(mouseY - pmouseY));
}
else if (mouseButton == RIGHT) {
camera1.track(mouseX - pmouseX, mouseY - pmouseY);
}
else if (mouseButton == CENTER) {
camera1.dolly(mouseY - pmouseY);
}
}