MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / process

Method process

Engine/source/platform/input/leapMotion/leapMotionDevice.cpp:242–331  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

240}
241
242bool LeapMotionDevice::process()
243{
244 if(!mEnabled)
245 return false;
246
247 if(!getActive())
248 return false;
249
250 //Con::printf("LeapMotionDevice::process()");
251
252 //Build the maximum hand axis angle to be passed into the LeapMotionDeviceData::setData()
253 F32 maxHandAxisRadius = mSin(mDegToRad(smMaximumHandAxisAngle));
254
255 // Get a frame of data
256 const Leap::Frame frame = mController->frame();
257
258 //const Leap::HandList hands = frame.hands();
259 //Con::printf("Frame: %lld Hands: %d Fingers: %d Tools: %d", (long long)frame.id(), hands.count(), frame.fingers().count(), frame.tools().count());
260
261 // Store the current data
262 LeapMotionDeviceData* currentBuffer = (mPrevData == mDataBuffer[0]) ? mDataBuffer[1] : mDataBuffer[0];
263 currentBuffer->setData(frame, mPrevData, smKeepHandIndexPersistent, smKeepPointableIndexPersistent, maxHandAxisRadius);
264 U32 diff = mPrevData->compare(currentBuffer);
265 U32 metaDiff = mPrevData->compareMeta(currentBuffer);
266
267 // Update the previous data pointers. We do this here in case someone calls our
268 // console functions during one of the input events below.
269 mPrevData = currentBuffer;
270
271 // Send out any meta data
272 if(metaDiff & LeapMotionDeviceData::METADIFF_FRAME_VALID_DATA)
273 {
274 // Frame valid change event
275 INPUTMGR->buildInputEvent(mDeviceType, DEFAULT_MOTION_UNIT, SI_BUTTON, LM_FRAMEVALIDDATA, currentBuffer->mHasTrackingData ? SI_MAKE : SI_BREAK, currentBuffer->mHasTrackingData ? 1.0f : 0.0f);
276 }
277
278 // Send out any valid data
279 if(currentBuffer->mDataSet && currentBuffer->mIsValid)
280 {
281 // Hands and their pointables
282 if(smGenerateIndividualEvents)
283 {
284 for(U32 i=0; i<LeapMotionConstants::MaxHands; ++i)
285 {
286 if(currentBuffer->mHandValid[i])
287 {
288 // Send out position
289 INPUTMGR->buildInputEvent(mDeviceType, DEFAULT_MOTION_UNIT, SI_POS, LM_HAND[i], SI_MOVE, currentBuffer->mHandPosPoint[i]);
290
291 // Send out rotation
292 INPUTMGR->buildInputEvent(mDeviceType, DEFAULT_MOTION_UNIT, SI_ROT, LM_HANDROT[i], SI_MOVE, currentBuffer->mHandRotQuat[i]);
293
294 // Pointables for hand
295 for(U32 j=0; j<LeapMotionConstants::MaxPointablesPerHand; ++j)
296 {
297 if(currentBuffer->mPointableValid[i][j])
298 {
299 // Send out position

Callers

nothing calls this directly

Calls 7

mSinFunction · 0.85
mDegToRadFunction · 0.85
buildInputEventMethod · 0.80
setDataMethod · 0.45
compareMethod · 0.45
compareMetaMethod · 0.45
generateNewFrameMethod · 0.45

Tested by

no test coverage detected