Skip to content

Commit c21d6c1

Browse files
authored
Merge branch 'master' into hs8
2 parents 38dbef0 + 07590eb commit c21d6c1

File tree

114 files changed

+909
-787
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+909
-787
lines changed

.github/workflows/build-msys2.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,14 @@ jobs:
4141
- uses: msys2/setup-msys2@v2
4242
with:
4343
cache: true
44+
release: true
4445
update: false
4546
msystem: ${{matrix.msystem}}
46-
pacboy: assimp:p cairo:p curl:p freeglut:p FreeImage:p gcc:p gdb:p glew:p glfw:p glm:p harfbuzz:p libsndfile:p libusb:p libxml2:p mpg123:p nlohmann-json:p ntldd-git:p openal:p opencv:p pkgconf:p pugixml:p rtaudio:p uriparser:p utf8cpp:p zlib:p poco:p
47+
pacboy: gcc:p assimp:p cairo:p curl:p freeglut:p FreeImage:p glew:p glfw:p glm:p libsndfile:p libusb:p libxml2:p mpg123:p nlohmann-json:p openal:p opencv:p pugixml:p rtaudio:p uriparser:p utf8cpp:p
48+
install: >-
49+
unzip
50+
make
51+
# gcc:p gdb:p zlib:p poco:p pkgconf:p harfbuzz:p ntldd-git:p
4752
# boost:p tools:p
4853
# install: >-
4954
# unzip
@@ -60,3 +65,4 @@ jobs:
6065
- name: Run tests
6166
run: ./scripts/ci/msys2/run_tests.sh
6267

68+

addons/ofxAccelerometer/src/ofxAccelerometer.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ class ofxAccelerometerHandler {
140140
if(!orientDirty) return;
141141
orientDirty = false;
142142

143-
orientation.x = atan2(accelOrientation.y, -accelOrientation.z) * RAD_TO_DEG;
144-
orientation.y = atan2(accelOrientation.x, -accelOrientation.z) * RAD_TO_DEG;
143+
orientation.x = glm::degrees( atan2(accelOrientation.y, -accelOrientation.z) );
144+
orientation.y = glm::degrees( atan2(accelOrientation.x, -accelOrientation.z) );
145145
orientation.z = 0;
146146
}
147147

addons/ofxAssimpModelLoader/src/ofxAssimpAnimation.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void ofxAssimpAnimation::update() {
5656
position = 1.0;
5757
stop();
5858
} else if(position > 1.0 && loopType == OF_LOOP_NORMAL) {
59-
position = fmod(position, 1.0f);
59+
position = std::fmod(position, 1.0f);
6060
} else if(position > 1.0 && loopType == OF_LOOP_PALINDROME) {
6161
speedFactor *= -1;
6262
} else if(position < 0.0 && loopType == OF_LOOP_PALINDROME) {

addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ void ofxAssimpModelLoader::calculateDimensions(){
219219
normalizedScale = scene_max.x-scene_min.x;
220220
normalizedScale = std::max(double(scene_max.y - scene_min.y), normalizedScale);
221221
normalizedScale = std::max(double(scene_max.z - scene_min.z), normalizedScale);
222-
if (fabs(normalizedScale) < std::numeric_limits<float>::epsilon()){
222+
if (std::abs(normalizedScale) < std::numeric_limits<float>::epsilon()){
223223
ofLogWarning("ofxAssimpModelLoader") << "Error calculating normalized scale of scene" << std::endl;
224224
normalizedScale = 1.0;
225225
} else {
@@ -749,6 +749,12 @@ void ofxAssimpModelLoader::setPositionForAllAnimations(float position) {
749749
}
750750
}
751751

752+
void ofxAssimpModelLoader::setSpeedForAllAnimations(float speed) {
753+
for (auto & a : animations) {
754+
a.setSpeed(speed);
755+
}
756+
}
757+
752758
// DEPRECATED.
753759
void ofxAssimpModelLoader::setAnimation(int animationIndex) {
754760
if(!hasAnimations()) {

addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.h

+2
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ class ofxAssimpModelLoader{
7676
void setPausedForAllAnimations(bool pause);
7777
void setLoopStateForAllAnimations(ofLoopType state);
7878
void setPositionForAllAnimations(float position);
79+
void setSpeedForAllAnimations(float speed);
80+
7981
[[deprecated("Use ofxAssimpAnimation")]]
8082
void setAnimation(int animationIndex);
8183
[[deprecated("Use ofxAssimpAnimation")]]

addons/ofxGui/src/ofxColorPicker.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ PolCord getPolarCoordinate(const glm::vec2 & p, float radius){
2323

2424
float px = p.x - radius; // point x from center.
2525
float py = p.y - radius; // point x from center.
26-
float pl = sqrt(px * px + py * py); // point length from center.
27-
float pa = atan2(px, py); // point angle around center.
26+
float pl = std::sqrt(px * px + py * py); // point length from center.
27+
float pa = std::atan2(px, py); // point angle around center.
2828

29-
pa *= RAD_TO_DEG;
29+
pa = glm::degrees(pa);
3030
pa -= 90;
3131
pl /= radius;
3232

@@ -39,8 +39,8 @@ PolCord getPolarCoordinate(const glm::vec2 & p, float radius){
3939

4040
glm::vec2 getPoint(float a, float r){
4141
glm::vec2 p;
42-
p.x = r * cos(-a * DEG_TO_RAD);
43-
p.y = r * sin(-a * DEG_TO_RAD);
42+
p.x = r * std::cos(glm::radians(-a));
43+
p.y = r * std::sin(glm::radians(-a));
4444

4545
return p;
4646
}
@@ -248,9 +248,9 @@ ofMesh ofxColorPicker_<ColorType>::getColorWheel() {
248248

249249
int j = i % COLOR_WHEEL_RES;
250250
float p = j / (float)COLOR_WHEEL_RES;
251-
float a = p * TWO_PI;
251+
float a = p * glm::two_pi<float>();
252252

253-
ofFloatColor c0 = getCircularColor<float>(a * RAD_TO_DEG, 1.0, colorScale);
253+
ofFloatColor c0 = getCircularColor<float>(glm::degrees(a), 1.0, colorScale);
254254
meshColorWheel.addColor(ofFloatColor::white);
255255
meshColorWheel.addColor(c0);
256256
meshColorWheel.addColor(c0);

addons/ofxKinect/src/ofxKinect.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ void ofxKinect::update() {
384384
if( videoPixels.getHeight() == videoPixelsIntra.getHeight() ){
385385
std::swap(videoPixels,videoPixelsIntra);
386386
}else{
387-
int minimumSize = MIN(videoPixels.size(), videoPixelsIntra.size());
387+
int minimumSize = std::min(videoPixels.size(), videoPixelsIntra.size());
388388
memcpy(videoPixels.getData(), videoPixelsIntra.getData(), minimumSize);
389389
}
390390
bNeedsUpdateVideo = false;

addons/ofxOpenCv/src/ofxCvImage.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -620,8 +620,8 @@ void ofxCvImage::transform( float angle, float centerX, float centerY,
620620
return;
621621
}
622622

623-
float sina = sin(angle * DEG_TO_RAD);
624-
float cosa = cos(angle * DEG_TO_RAD);
623+
float sina = std::sin(glm::radians(angle));
624+
float cosa = std::cos(glm::radians(angle));
625625
CvMat* transmat = cvCreateMat( 2,3, CV_32F );
626626
cvmSet( transmat, 0,0, scaleX*cosa );
627627
cvmSet( transmat, 0,1, scaleY*sina );

addons/ofxSvg/src/ofxSvg.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ void ofxSvg::fixSvgString(std::string & xmlstring) {
9898
for (ofXml & element : strokeWidthElements) {
9999
//cout << element.toString() << endl;
100100
float strokewidth = element.getAttribute("stroke-width").getFloatValue();
101-
strokewidth = MAX(1, round(strokewidth));
101+
strokewidth = std::fmax(1.0, std::round(strokewidth));
102102
element.getAttribute("stroke-width").set(strokewidth);
103103
}
104104
}

addons/ofxiOS/src/core/ofxiOSGLKViewController.mm

+3-3
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,11 @@ - (float)rotationForOrientation:(UIInterfaceOrientation)interfaceOrientation {
195195
if (interfaceOrientation == UIInterfaceOrientationPortrait) {
196196
return 0; // 0 degrees.
197197
} else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
198-
return M_PI * 0.5; // 90 degrees.
198+
return glm::half_pi<float>(); // 90 degrees.
199199
} else if (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
200-
return M_PI; // 180 degrees.
200+
return glm::pi<float>(); // 180 degrees.
201201
} else if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
202-
return M_PI * 1.5; // 270 degrees.
202+
return glm::pi<float>() + glm::half_pi<float>(); // 270 degrees.
203203
} else {
204204
return 0;
205205
}

addons/ofxiOS/src/core/ofxiOSViewController.mm

+3-3
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,11 @@ - (float)rotationForOrientation:(UIInterfaceOrientation)interfaceOrientation {
127127
if (interfaceOrientation == UIInterfaceOrientationPortrait) {
128128
return 0; // 0 degrees.
129129
} else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
130-
return M_PI * 0.5; // 90 degrees.
130+
return glm::half_pi<float>(); // 90 degrees.
131131
} else if (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
132-
return M_PI; // 180 degrees.
132+
return glm::pi<float>(); // 180 degrees.
133133
} else if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
134-
return M_PI * 1.5; // 270 degrees.
134+
return glm::pi<float>() + glm::half_pi<float>(); // 270 degrees.
135135
} else {
136136
return 0;
137137
}

addons/ofxiOS/src/utils/ofxiOSImagePicker.mm

+11-11
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,11 @@ - (instancetype) initWithPicker:(canLoadPixels *) _picker
198198
*/
199199
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
200200
if(orientation == UIInterfaceOrientationLandscapeLeft) {
201-
_imagePicker.view.transform = CGAffineTransformMakeRotation(-PI*0.5);
201+
_imagePicker.view.transform = CGAffineTransformMakeRotation(-glm::half_pi<float>());
202202
} else if(orientation == UIInterfaceOrientationLandscapeRight) {
203-
_imagePicker.view.transform = CGAffineTransformMakeRotation(PI*0.5);
203+
_imagePicker.view.transform = CGAffineTransformMakeRotation(glm::half_pi<float>());
204204
} else if(orientation == UIInterfaceOrientationPortraitUpsideDown) {
205-
_imagePicker.view.transform = CGAffineTransformMakeRotation(PI);
205+
_imagePicker.view.transform = CGAffineTransformMakeRotation(glm::pi<float>());
206206
}
207207
}
208208

@@ -330,11 +330,11 @@ - (BOOL) showCameraOverlayWithCustomView:(UIView *)overlayView {
330330
overlay.center = CGPointMake(screenSize.width * 0.5, screenSize.height * 0.5);
331331
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
332332
if(orientation == UIInterfaceOrientationLandscapeLeft) {
333-
overlay.transform = CGAffineTransformMakeRotation(-PI * 0.5);
333+
overlay.transform = CGAffineTransformMakeRotation(-glm::half_pi<float>());
334334
} else if(orientation == UIInterfaceOrientationLandscapeRight) {
335-
overlay.transform = CGAffineTransformMakeRotation(PI * 0.5);
335+
overlay.transform = CGAffineTransformMakeRotation(glm::half_pi<float>());
336336
} else if(orientation == UIInterfaceOrientationPortraitUpsideDown) {
337-
overlay.transform = CGAffineTransformMakeRotation(PI);
337+
overlay.transform = CGAffineTransformMakeRotation(glm::pi<float>());
338338
}
339339
}
340340

@@ -458,7 +458,7 @@ - (UIImage *)scaleAndRotateImage:(UIImage *)image {
458458
break;
459459
case UIImageOrientationDown:
460460
transform = CGAffineTransformMakeTranslation(imageSize.width, imageSize.height);
461-
transform = CGAffineTransformRotate(transform, M_PI);
461+
transform = CGAffineTransformRotate(transform, glm::pi<float>());
462462
break;
463463
case UIImageOrientationDownMirrored:
464464
transform = CGAffineTransformMakeTranslation(0.0, imageSize.height);
@@ -470,28 +470,28 @@ - (UIImage *)scaleAndRotateImage:(UIImage *)image {
470470
bounds.size.width = boundHeight;
471471
transform = CGAffineTransformMakeTranslation(imageSize.height, imageSize.width);
472472
transform = CGAffineTransformScale(transform, -1.0, 1.0);
473-
transform = CGAffineTransformRotate(transform, 3.0 * M_PI / 2.0);
473+
transform = CGAffineTransformRotate(transform, glm::pi<float>() + glm::half_pi<float>());
474474
break;
475475
case UIImageOrientationLeft:
476476
boundHeight = bounds.size.height;
477477
bounds.size.height = bounds.size.width;
478478
bounds.size.width = boundHeight;
479479
transform = CGAffineTransformMakeTranslation(0.0, imageSize.width);
480-
transform = CGAffineTransformRotate(transform, 3.0 * M_PI / 2.0);
480+
transform = CGAffineTransformRotate(transform, glm::pi<float>() + glm::half_pi<float>());
481481
break;
482482
case UIImageOrientationRightMirrored:
483483
boundHeight = bounds.size.height;
484484
bounds.size.height = bounds.size.width;
485485
bounds.size.width = boundHeight;
486486
transform = CGAffineTransformMakeScale(-1.0, 1.0);
487-
transform = CGAffineTransformRotate(transform, M_PI / 2.0);
487+
transform = CGAffineTransformRotate(transform, glm::half_pi<float>());
488488
break;
489489
case UIImageOrientationRight:
490490
boundHeight = bounds.size.height;
491491
bounds.size.height = bounds.size.width;
492492
bounds.size.width = boundHeight;
493493
transform = CGAffineTransformMakeTranslation(imageSize.height, 0.0);
494-
transform = CGAffineTransformRotate(transform, M_PI / 2.0);
494+
transform = CGAffineTransformRotate(transform, glm::half_pi<float>());
495495
break;
496496
default:
497497
[NSException raise:NSInternalInconsistencyException format:@"Invalid image orientation"];

addons/ofxiOS/src/utils/ofxiOSKeyboard.mm

+3-3
Original file line numberDiff line numberDiff line change
@@ -370,23 +370,23 @@ - (void) setFrame: (CGRect) rect
370370
switch (ofGetOrientation())
371371
{
372372
case OF_ORIENTATION_90_LEFT:
373-
_textField.transform = CGAffineTransformMakeRotation(M_PI_2);
373+
_textField.transform = CGAffineTransformMakeRotation(glm::half_pi<float>());
374374
x = rect.origin.y-rect.size.height;
375375
y = s.height-rect.size.width-rect.origin.x;
376376
w = rect.size.height;
377377
h = rect.size.width;
378378
break;
379379

380380
case OF_ORIENTATION_90_RIGHT:
381-
_textField.transform = CGAffineTransformMakeRotation(-M_PI_2);
381+
_textField.transform = CGAffineTransformMakeRotation(-glm::half_pi<float>());
382382
x = s.width-rect.origin.y;
383383
y = rect.origin.x;
384384
w = rect.size.height;
385385
h = rect.size.width;
386386
break;
387387

388388
case OF_ORIENTATION_180:
389-
_textField.transform = CGAffineTransformMakeRotation(M_PI);
389+
_textField.transform = CGAffineTransformMakeRotation(glm::pi<float>());
390390
x = rect.origin.x;
391391
y = rect.origin.y-rect.size.height;
392392
w = rect.size.width;

addons/ofxiOS/src/video/AVFoundationVideoGrabber.mm

+2-2
Original file line numberDiff line numberDiff line change
@@ -456,13 +456,13 @@ - (void)eraseGrabberPtr {
456456

457457
if(ofGetOrientation() == OF_ORIENTATION_DEFAULT) {
458458
transform = CGAffineTransformMakeTranslation(0.0, height);
459-
transform = CGAffineTransformRotate(transform, 3.0 * M_PI / 2.0);
459+
transform = CGAffineTransformRotate(transform, glm::half_pi<float>() + glm::pi<float>());
460460

461461
CGContextConcatCTM(spriteContext, transform);
462462
CGContextDrawImage(spriteContext, CGRectMake(0.0, 0.0, (CGFloat)height, (CGFloat)width), ref);
463463
} else if(ofGetOrientation() == OF_ORIENTATION_180) {
464464
transform = CGAffineTransformMakeTranslation(width, 0.0);
465-
transform = CGAffineTransformRotate(transform, M_PI / 2.0);
465+
transform = CGAffineTransformRotate(transform, glm::half_pi<float>());
466466

467467
CGContextConcatCTM(spriteContext, transform);
468468
CGContextDrawImage(spriteContext, CGRectMake(0.0, 0.0, (CGFloat)height, (CGFloat)width), ref);

examples/3d/3DPrimitivesExample/src/ofApp.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ void ofApp::draw() {
342342
ofPushMatrix();
343343
if (bottomCap.getNumNormals() > 0) {
344344
ofTranslate(bottomCap.getNormal(0) * cone.getHeight()*.5);
345-
ofRotateDeg(sin(ofGetElapsedTimef() * 5) * RAD_TO_DEG, 1, 0, 0);
345+
ofRotateDeg( glm::degrees( sin(ofGetElapsedTimef() * 5) ), 1, 0, 0);
346346
bottomCap.draw();
347347
}
348348
ofPopMatrix();

examples/android/androidAudioExample/src/ofApp.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void ofApp::touchMoved(int x, int y, int id){
8888
float height = (float)ofGetHeight();
8989
float heightPct = ((height-y) / height);
9090
targetFrequency = 2000.0f * heightPct;
91-
phaseAdderTarget = (targetFrequency / (float) sampleRate) * TWO_PI;
91+
phaseAdderTarget = (targetFrequency / (float) sampleRate) * glm::two_pi<float>();
9292
}
9393

9494
//--------------------------------------------------------------
@@ -153,9 +153,9 @@ void ofApp::audioOut(ofSoundBuffer & buffer){
153153
float rightScale = pan;
154154

155155
// sin (n) seems to have trouble when n is very large, so we
156-
// keep phase in the range of 0-TWO_PI like this:
157-
while (phase > TWO_PI){
158-
phase -= TWO_PI;
156+
// keep phase in the range of 0-glm::two_pi<float>() like this:
157+
while (phase > glm::two_pi<float>()){
158+
phase -= glm::two_pi<float>();
159159
}
160160

161161
if ( bNoise == true){

examples/android/androidPolygonExample/src/ofApp.cpp

+15-15
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ void ofApp::draw(){
102102
float yPct = (float)(mouseY) / (float)(ofGetHeight());
103103
int nTips = 5 + xPct * 60;
104104
int nStarPts = nTips * 2;
105-
float angleChangePerPt = TWO_PI / (float)nStarPts;
105+
float angleChangePerPt = glm::two_pi<float>() / (float)nStarPts;
106106
float innerRadius = 0 + yPct*80;
107107
float outerRadius = 80;
108108
float origx = 525;
@@ -114,13 +114,13 @@ void ofApp::draw(){
114114
for (int i = 0; i < nStarPts; i++){
115115
if (i % 2 == 0) {
116116
// inside point:
117-
float x = origx + innerRadius * cos(angle);
118-
float y = origy + innerRadius * sin(angle);
117+
float x = origx + innerRadius * std::cos(angle);
118+
float y = origy + innerRadius * std::sin(angle);
119119
ofVertex(x,y);
120120
} else {
121121
// outside point
122-
float x = origx + outerRadius * cos(angle);
123-
float y = origy + outerRadius * sin(angle);
122+
float x = origx + outerRadius * std::cos(angle);
123+
float y = origy + outerRadius * std::sin(angle);
124124
ofVertex(x,y);
125125
}
126126
angle += angleChangePerPt;
@@ -155,13 +155,13 @@ void ofApp::draw(){
155155
ofFill();
156156
ofSetPolyMode(OF_POLY_WINDING_ODD);
157157
ofBeginShape();
158-
float angleStep = TWO_PI/(100.0f + sin(ofGetElapsedTimef()/5.0f) * 60);
158+
float angleStep = glm::two_pi<float>()/(100.0f + std::sin(ofGetElapsedTimef()/5.0f) * 60);
159159
float radiusAdder = 0.5f;
160160
float radius = 0;
161161
for (int i = 0; i < 200; i++){
162162
float anglef = (i) * angleStep;
163-
float x = radius * cos(anglef);
164-
float y = radius * sin(anglef);
163+
float x = radius * std::cos(anglef);
164+
float y = radius * std::sin(anglef);
165165
ofVertex(x,y);
166166
radius += radiusAdder;
167167
}
@@ -325,9 +325,9 @@ void ofApp::draw(){
325325
ofNextContour(true);
326326

327327
for (int i = 0; i < 20; i++){
328-
float anglef = ((float)i / 19.0f) * TWO_PI;
329-
float x = 340 + 30 * cos(anglef);
330-
float y = 550 + 30 * sin(anglef);
328+
float anglef = ((float)i / 19.0f) * glm::two_pi<float>();
329+
float x = 340 + 30 * std::cos(anglef);
330+
float y = 550 + 30 * std::sin(anglef);
331331
ofVertex(x,y);
332332
radius += radiusAdder;
333333
}
@@ -347,9 +347,9 @@ void ofApp::draw(){
347347
ofNextContour(true);
348348

349349
for (int i = 0; i < 20; i++){
350-
float anglef = ((float)i / 19.0f) * TWO_PI;
351-
float x = 340 + 30 * cos(anglef);
352-
float y = 550 + 30 * sin(anglef);
350+
float anglef = ((float)i / 19.0f) * glm::two_pi<float>();
351+
float x = 340 + 30 * std::cos(anglef);
352+
float y = 550 + 30 * std::sin(anglef);
353353
ofVertex(x,y);
354354
radius += radiusAdder;
355355
}
@@ -365,7 +365,7 @@ void ofApp::draw(){
365365
ofNextContour(true);
366366

367367
for (int i = 0; i < 20; i++){
368-
float anglef = ((float)i / 19.0f) * TWO_PI;
368+
float anglef = ((float)i / 19.0f) * glm::two_pi<float>();
369369
float x = 340 + 30 * cos(anglef);
370370
float y = 550 + 30 * sin(anglef);
371371
ofVertex(x,y);

0 commit comments

Comments
 (0)