void Midi2UdpThread::run() { QUdpSocket *udpSocket; udpSocket = new QUdpSocket(0); forever { if (abort) { delete udpSocket; return; } if (poll(pfd, npfd, 250) > 0) { // Get MIDI event snd_seq_event_input(seq_handle, &midi_event); long len = snd_midi_event_decode(eventparser, midimsg, MAX_MIDI_MESSAGE_LENGTH, midi_event); if( len < 0 ) { printf("midi2udp: Error decoding midi event!\n"); } else { printf("midi2udp: got midi event: "); for(int i=0; i<len; ++i) { printf("0x%x ", midimsg[i]); } printf("\n"); // Send it over UDP for(set<string>::iterator ip_it = ds_ips.begin(); ip_it != ds_ips.end(); ++ip_it) { QString to_((*ip_it).c_str()); printf("sending to %s\n", (*ip_it).c_str()); QHostAddress to(to_); udpSocket->writeDatagram((char*)midimsg, len, to, DS_PORT); } } snd_seq_free_event(midi_event); snd_midi_event_reset_decode(eventparser); } } }
std::pair<bool, float> PhysicEngine::sphereCast (float radius, btVector3& from, btVector3& to) { OurClosestConvexResultCallback callback(from, to); callback.m_collisionFilterMask = OEngine::Physic::CollisionType_World|OEngine::Physic::CollisionType_HeightMap; btSphereShape shape(radius); const btQuaternion btrot(0.0f, 0.0f, 0.0f); btTransform from_ (btrot, from); btTransform to_ (btrot, to); dynamicsWorld->convexSweepTest(&shape, from_, to_, callback); if (callback.hasHit()) return std::make_pair(true, callback.m_closestHitFraction); else return std::make_pair(false, 1); }