Skip to content

Commit

Permalink
Merge pull request #22 from freesig/master
Browse files Browse the repository at this point in the history
snap fixes and video
  • Loading branch information
Joshua Batty authored Apr 24, 2018
2 parents 617ba51 + 5755fbf commit 41497cd
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 18 deletions.
12 changes: 5 additions & 7 deletions addons/ofxPiMapper/src/Gui/Widgets/ProjectionEditorWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void ProjectionEditorWidget::mouseDragged(ofMouseEventArgs & args){

// Pass args to joint mouse events
for(unsigned int i = 0; i < joints.size(); ++i){
if (joints[i]->isDragged()) {
if (joints[i]->isDragged() && !boundary::is_collided_joint(ofVec2f(args.x, args.y), joints[i], joints)) {
surfaceManager->getSelectedSurface()->setVertex(i,
boundary::bounded_position(args));
}
Expand All @@ -64,7 +64,7 @@ void ProjectionEditorWidget::mouseDragged(ofMouseEventArgs & args){
if(joints[i]->isDragged()){
for(int j = 0; j < allVertices.size(); j++){
float distance = mousePosition.distance(*allVertices[j]);
if(distance < fSnapDistance){
if(distance < fSnapDistance && !boundary::is_collided_joint(ofVec2f(args.x, args.y), joints[i], joints)){
joints[i]->position = *allVertices[j];
ofVec2f clickDistance = joints[i]->position - ofVec2f(args.x, args.y);
joints[i]->setClickDistance(clickDistance);
Expand Down Expand Up @@ -111,16 +111,14 @@ void ProjectionEditorWidget::touchMoved(map<int, ofTouchEventArgs> &active_joint
if (joints[i]->isDragged()) {
for (int j = 0; j < allVertices.size(); j++) {
float distance = touchPosition.distance(*allVertices[j]);
if (distance < fSnapDistance) {
if (distance < fSnapDistance && !boundary::is_collided_joint(joint_touch.second, joints[joint_touch.first], joints)) {
joints[i]->position = *allVertices[j];
ofVec2f clickDistance = joints[i]->position - ofVec2f(joint_touch.second.x, joint_touch.second.y);
joints[i]->setClickDistance(clickDistance);
if (joint_touch.first < joints.size() &&
joints[joint_touch.first]->isDragged()) {
if (!boundary::is_collided_joint(joint_touch.second, joints[joint_touch.first], joints)) {
surfaceManager->getSelectedSurface()->setVertex(i,
boundary::bounded_position(joints[i]->position));
}
surfaceManager->getSelectedSurface()->setVertex(i,
boundary::bounded_position(joints[i]->position));
}
break;
}
Expand Down
1 change: 0 additions & 1 deletion addons/ofxPiMapper/src/Surfaces/QuadSurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ void QuadSurface::setVertex(int index, ofVec2f p){
mesh.setVertex(index, p);

if (is_concave()) {
cout << "concave" << endl;
mesh.setVertex(index, p_s);
}
ofVec3f v = mesh.getVertex(index);
Expand Down
16 changes: 8 additions & 8 deletions bin/data/ofxpimapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,20 +149,20 @@
<surface type="1">
<vertices>
<vertex>
<x>845.000000000</x>
<y>411.000000000</y>
<x>745.000000000</x>
<y>471.000000000</y>
</vertex>
<vertex>
<x>1107.000000000</x>
<y>417.000000000</y>
<x>792.000000000</x>
<y>472.000000000</y>
</vertex>
<vertex>
<x>1049.000000000</x>
<y>521.000000000</y>
<x>699.000000000</x>
<y>635.000000000</y>
</vertex>
<vertex>
<x>815.000000000</x>
<y>521.000000000</y>
<x>465.000000000</x>
<y>635.000000000</y>
</vertex>
</vertices>
<texCoords>
Expand Down
4 changes: 2 additions & 2 deletions src/VisualLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ void VisualLayer::set_scene_shader(ofShader scene_shader){

//--------------------------------------------------------------
void VisualLayer::update(){

render_fbo.fbo.begin();
ofClear(0,0,0,0);
if (use_shader) {
Expand All @@ -60,8 +59,9 @@ void VisualLayer::update(){
scene_shader.end();
} else {
player.update();
player.draw(0, 0);
player.draw(0, 0, render_fbo.fbo.getWidth(), render_fbo.fbo.getHeight());
}

render_fbo.fbo.end();
}

Expand Down
15 changes: 15 additions & 0 deletions src/ofApp.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "ofApp.h"
#include "nodel/nodel_dep.hpp"
#include "video_controller.h"

#define STRINGIFY(A) #A

Expand Down Expand Up @@ -473,6 +474,20 @@ void ofApp::keyPressed(int key){
cout << "Touch mode on" << endl;
}
break;
case 'v':
{
auto loader = video_controller::load();
for (int i = 0; i < layers.size(); i++) {
auto l = layers[i];
l->toggle_shader();
if (!l->is_shader()) {
if (loader.has_next()) {
l->load_movie(loader.next());
}
}
}
}
break;
default:
break;
}
Expand Down

0 comments on commit 41497cd

Please sign in to comment.