Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #4 from novogrammer/experimental

Fix BufferOverrun
  • Loading branch information...
commit 431467c94ed3fad261c712e9b8ccd76fb0346ab4 2 parents e3449f3 + 637bab3
gameoverhack gameoverhack authored
Showing with 9 additions and 7 deletions.
  1. +6 −4 src/ofxUserGenerator.cpp
  2. +3 −3 src/ofxUserGenerator.h
10 src/ofxUserGenerator.cpp
View
@@ -134,7 +134,8 @@ bool ofxUserGenerator::setup( ofxOpenNIContext* pContext) {
useMaskPixels = false;
// setup mask pixels array TODO: clean this up on closing or dtor
- for (int user = 0; user < MAX_NUMBER_USERS; user++) {
+ //including 0 as all users
+ for (int user = 0; user <= MAX_NUMBER_USERS; user++) {
maskPixels[user] = new unsigned char[width * height];
}
@@ -142,7 +143,8 @@ bool ofxUserGenerator::setup( ofxOpenNIContext* pContext) {
useCloudPoints = false;
// setup cloud points array TODO: clean this up on closing or dtor
- for (int user = 0; user < MAX_NUMBER_USERS; user++) {
+ //including 0 as all users
+ for (int user = 0; user <= MAX_NUMBER_USERS; user++) {
cloudPoints[user] = new ofPoint[width * height];
cloudColors[user] = new ofColor[width * height];
}
@@ -413,13 +415,13 @@ void ofxUserGenerator::updateCloudPoints() {
ofPoint ofxUserGenerator::getWorldCoordinateAt(int x, int y, int userID) {
- return cloudPoints[userID][y * height + x];
+ return cloudPoints[userID][y * width + x];
}
ofColor ofxUserGenerator::getWorldColorAt(int x, int y, int userID) {
- return cloudColors[userID][y * height + x];
+ return cloudColors[userID][y * width + x];
}
6 src/ofxUserGenerator.h
View
@@ -65,9 +65,9 @@ class ofxUserGenerator {
// vars for cloud point and masking
XnUInt16 width, height;
- unsigned char * maskPixels[MAX_NUMBER_USERS];
- ofPoint * cloudPoints[MAX_NUMBER_USERS];
- ofColor * cloudColors[MAX_NUMBER_USERS];
+ unsigned char * maskPixels[MAX_NUMBER_USERS+1];//including 0 as all users
+ ofPoint * cloudPoints[MAX_NUMBER_USERS+1];//including 0 as all users
+ ofColor * cloudColors[MAX_NUMBER_USERS+1];//including 0 as all users
bool useMaskPixels, useCloudPoints;
float smoothing_factor;
Please sign in to comment.
Something went wrong with that request. Please try again.