summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-10-03 11:46:14 +0200
committerStanislaw Halik <sthalik@misaki.pl>2015-10-03 11:46:14 +0200
commit8de96cff462fb55788058b09c3d0186eab04a6ca (patch)
tree2276a59e7a071da4a8dd8dc4731e2a350a6605c4
parent5fa0eaa28ea3bf01b5bfc0a71b5ee901163bddbd (diff)
parent32e67f4ea87461624e74390b25f41aede618d5f0 (diff)
Merge branch 'unstable' into trackhat-ui
* unstable: ft: add locking back ft: change nonsensical frame step ft: don't alloc "int i" as bss ft: reformat cmake: simplify pose-widget: use bilinear filtering declutter clientfiles/
-rw-r--r--clientfiles/very-important-source-code/make-csv.pl (renamed from clientfiles/make-csv.pl)0
-rw-r--r--clientfiles/very-important-source-code/npclient.c58
-rw-r--r--ftnoir_protocol_ft/ftnoir_protocol_ft.cpp4
-rw-r--r--pose-widget/glwidget.cpp52
4 files changed, 78 insertions, 36 deletions
diff --git a/clientfiles/make-csv.pl b/clientfiles/very-important-source-code/make-csv.pl
index ee60364e..ee60364e 100644
--- a/clientfiles/make-csv.pl
+++ b/clientfiles/very-important-source-code/make-csv.pl
diff --git a/clientfiles/very-important-source-code/npclient.c b/clientfiles/very-important-source-code/npclient.c
index d5b78aff..3878f809 100644
--- a/clientfiles/very-important-source-code/npclient.c
+++ b/clientfiles/very-important-source-code/npclient.c
@@ -46,7 +46,7 @@ static double r = 0, p = 0, y = 0, tx = 0, ty = 0, tz = 0;
#define NP_DECLSPEC __declspec(dllexport)
#define NP_EXPORT(t) t NP_DECLSPEC __stdcall
-#define NP_AXIS_MAX 16383
+#define NP_AXIS_MAX 16383
static BOOL FTCreateMapping(void);
static void FTDestroyMapping(void);
@@ -109,7 +109,7 @@ BOOL DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
return TRUE;
}
/******************************************************************
- * NPPriv_ClientNotify (NPCLIENT.1)
+ * NPPriv_ClientNotify (NPCLIENT.1)
*/
NP_EXPORT(int) NPPriv_ClientNotify(void)
@@ -119,7 +119,7 @@ NP_EXPORT(int) NPPriv_ClientNotify(void)
return 0;
}
/******************************************************************
- * NPPriv_GetLastError (NPCLIENT.2)
+ * NPPriv_GetLastError (NPCLIENT.2)
*/
NP_EXPORT(int) NPPriv_GetLastError(void)
@@ -129,7 +129,7 @@ NP_EXPORT(int) NPPriv_GetLastError(void)
return 0;
}
/******************************************************************
- * NPPriv_SetData (NPCLIENT.3)
+ * NPPriv_SetData (NPCLIENT.3)
*/
NP_EXPORT(int) NPPriv_SetData(void)
@@ -139,7 +139,7 @@ NP_EXPORT(int) NPPriv_SetData(void)
return 0;
}
/******************************************************************
- * NPPriv_SetLastError (NPCLIENT.4)
+ * NPPriv_SetLastError (NPCLIENT.4)
*/
NP_EXPORT(int) NPPriv_SetLastError(void)
@@ -149,7 +149,7 @@ NP_EXPORT(int) NPPriv_SetLastError(void)
return 0;
}
/******************************************************************
- * NPPriv_SetParameter (NPCLIENT.5)
+ * NPPriv_SetParameter (NPCLIENT.5)
*/
NP_EXPORT(int) NPPriv_SetParameter(void)
@@ -159,7 +159,7 @@ NP_EXPORT(int) NPPriv_SetParameter(void)
return 0;
}
/******************************************************************
- * NPPriv_SetSignature (NPCLIENT.6)
+ * NPPriv_SetSignature (NPCLIENT.6)
*/
NP_EXPORT(int) NPPriv_SetSignature(void)
@@ -169,7 +169,7 @@ NP_EXPORT(int) NPPriv_SetSignature(void)
return 0;
}
/******************************************************************
- * NPPriv_SetVersion (NPCLIENT.7)
+ * NPPriv_SetVersion (NPCLIENT.7)
*/
NP_EXPORT(int) NPPriv_SetVersion(void)
@@ -263,12 +263,13 @@ static __inline void enhance(unsigned char buf[], unsigned int size,
}
/******************************************************************
- * NP_GetData (NPCLIENT.8)
+ * NP_GetData (NPCLIENT.8)
*/
NP_EXPORT(int) NP_GetData(tir_data_t * data)
{
- static int frameno = 0, i;
+ static int frameno = 0;
+ int i;
#if DEBUG
int recv = 0;
#endif
@@ -301,10 +302,11 @@ NP_EXPORT(int) NP_GetData(tir_data_t * data)
dbg_report("NP_GetData: Table = %02d %02d %02d %02d %02d %02d %02d %02d\n", table[0],table[1],table[2],table[3],table[4],table[5], table[6], table[7]);
bEncryptionChecked = pMemData->GameId2 == pMemData->GameId;
}
+
ReleaseMutex(hFTMutex);
}
- data->frame = frameno += 10;
+ data->frame = frameno += 1;
data->status = 0;
data->cksum = 0;
@@ -316,7 +318,7 @@ NP_EXPORT(int) NP_GetData(tir_data_t * data)
data->ty = scale2AnalogLimits (ty, -500.0, 500.0);
data->tz = scale2AnalogLimits (tz, -500.0, 500.0);
- for(i = 0; i < 9; ++i){
+ for(i = 0; i < 9; ++i) {
data->padding[i] = 0.0;
}
@@ -325,13 +327,15 @@ NP_EXPORT(int) NP_GetData(tir_data_t * data)
#endif
data->cksum = cksum((unsigned char*)data, sizeof(tir_data_t));
- if(bEncryption){
+
+ if(bEncryption) {
enhance((unsigned char*)data, sizeof(tir_data_t), table, sizeof(table));
}
+
return 0;
}
/******************************************************************
- * NP_GetParameter (NPCLIENT.9)
+ * NP_GetParameter (NPCLIENT.9)
*/
NP_EXPORT(int) NP_GetParameter(int arg0, int arg1)
@@ -341,7 +345,7 @@ NP_EXPORT(int) NP_GetParameter(int arg0, int arg1)
}
/******************************************************************
- * NP_GetSignature (NPCLIENT.10)
+ * NP_GetSignature (NPCLIENT.10)
*
*
*/
@@ -442,7 +446,7 @@ NP_EXPORT(int) NP_QueryVersion(unsigned short * version)
return 0;
}
/******************************************************************
- * NP_ReCenter (NPCLIENT.12)
+ * NP_ReCenter (NPCLIENT.12)
*/
NP_EXPORT(int) NP_ReCenter(void)
@@ -452,7 +456,7 @@ NP_EXPORT(int) NP_ReCenter(void)
}
/******************************************************************
- * NP_RegisterProgramProfileID (NPCLIENT.13)
+ * NP_RegisterProgramProfileID (NPCLIENT.13)
*/
NP_EXPORT(int) NP_RegisterProgramProfileID(unsigned short id)
@@ -463,7 +467,7 @@ NP_EXPORT(int) NP_RegisterProgramProfileID(unsigned short id)
return 0;
}
/******************************************************************
- * NP_RegisterWindowHandle (NPCLIENT.14)
+ * NP_RegisterWindowHandle (NPCLIENT.14)
*/
NP_EXPORT(int) NP_RegisterWindowHandle(HWND hwnd)
@@ -472,7 +476,7 @@ NP_EXPORT(int) NP_RegisterWindowHandle(HWND hwnd)
return (int) 0;
}
/******************************************************************
- * NP_RequestData (NPCLIENT.15)
+ * NP_RequestData (NPCLIENT.15)
*/
NP_EXPORT(int) NP_RequestData(unsigned short req)
@@ -481,7 +485,7 @@ NP_EXPORT(int) NP_RequestData(unsigned short req)
return (int) 0;
}
/******************************************************************
- * NP_SetParameter (NPCLIENT.16)
+ * NP_SetParameter (NPCLIENT.16)
*/
NP_EXPORT(int) NP_SetParameter(int arg0, int arg1)
@@ -490,7 +494,7 @@ NP_EXPORT(int) NP_SetParameter(int arg0, int arg1)
return (int) 0;
}
/******************************************************************
- * NP_StartCursor (NPCLIENT.17)
+ * NP_StartCursor (NPCLIENT.17)
*/
NP_EXPORT(int) NP_StartCursor(void)
@@ -499,7 +503,7 @@ NP_EXPORT(int) NP_StartCursor(void)
return (int) 0;
}
/******************************************************************
- * NP_StartDataTransmission (NPCLIENT.18)
+ * NP_StartDataTransmission (NPCLIENT.18)
*/
NP_EXPORT(int) NP_StartDataTransmission(void)
@@ -509,7 +513,7 @@ NP_EXPORT(int) NP_StartDataTransmission(void)
return (int) 0;
}
/******************************************************************
- * NP_StopCursor (NPCLIENT.19)
+ * NP_StopCursor (NPCLIENT.19)
*/
NP_EXPORT(int) NP_StopCursor(void)
@@ -518,7 +522,7 @@ NP_EXPORT(int) NP_StopCursor(void)
return (int) 0;
}
/******************************************************************
- * NP_StopDataTransmission (NPCLIENT.20)
+ * NP_StopDataTransmission (NPCLIENT.20)
*/
NP_EXPORT(int) NP_StopDataTransmission(void)
@@ -526,7 +530,7 @@ NP_EXPORT(int) NP_StopDataTransmission(void)
return (int) 0;
}
/******************************************************************
- * NP_UnregisterWindowHandle (NPCLIENT.21)
+ * NP_UnregisterWindowHandle (NPCLIENT.21)
*/
NP_EXPORT(int) NP_UnregisterWindowHandle(void)
@@ -538,9 +542,9 @@ NP_EXPORT(int) NP_UnregisterWindowHandle(void)
static BOOL FTCreateMapping(void)
{
BOOL bMappingExists = FALSE;
- if ( pMemData != NULL ) {
+
+ if (pMemData)
return TRUE;
- }
dbg_report("FTCreateMapping request (pMemData == NULL).\n");
diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp
index b38b0730..97caaefc 100644
--- a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp
+++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp
@@ -65,6 +65,8 @@ void FTNoIR_Protocol::pose(const double* headpose) {
FTHeap* ft = pMemData;
FTData* data = &ft->data;
+
+ shm.lock();
data->RawX = 0;
data->RawY = 0;
@@ -107,6 +109,8 @@ void FTNoIR_Protocol::pose(const double* headpose) {
}
data->DataID += 1;
+
+ shm.unlock();
}
void FTNoIR_Protocol::start_tirviews() {
diff --git a/pose-widget/glwidget.cpp b/pose-widget/glwidget.cpp
index 2cb858d7..749817b2 100644
--- a/pose-widget/glwidget.cpp
+++ b/pose-widget/glwidget.cpp
@@ -11,6 +11,7 @@
#include <QPainter>
#include <QPaintEvent>
+//#include <QDebug>
GLWidget::GLWidget(QWidget *parent) : QWidget(parent)
{
@@ -159,20 +160,53 @@ void GLWidget::project_quad_texture() {
// we have symmetry so only one lookup is needed -sh 20150831
if (triangles[i].barycentric_coords(pos, uv))
{
- const int px = origs[i][0].x()
+ const float fx = origs[i][0].x()
+ uv.x() * (origs[i][2].x() - origs[i][0].x())
+ uv.y() * (origs[i][1].x() - origs[i][0].x());
- const int py = origs[i][0].y()
+ const float fy = origs[i][0].y()
+ uv.x() * (origs[i][2].y() - origs[i][0].y())
+ uv.y() * (origs[i][1].y() - origs[i][0].y());
-
- const unsigned char r = orig[py * orig_pitch + px * orig_depth + 2];
- const unsigned char g = orig[py * orig_pitch + px * orig_depth + 1];
- const unsigned char b = orig[py * orig_pitch + px * orig_depth + 0];
- dest[y * dest_pitch + x * dest_depth + 0] = r;
- dest[y * dest_pitch + x * dest_depth + 1] = g;
- dest[y * dest_pitch + x * dest_depth + 2] = b;
+ const int px_ = std::max<int>(0, fx - .5f);
+ const int py_ = std::max<int>(0, fy - .5f);
+ const int px = fx;
+ const int py = fy;
+ const float ax_ = fabs(fx - px);
+ const float ay_ = fabs(fy - py);
+ const float ax = 1.f - ax_;
+ const float ay = 1.f - ay_;
+
+ // 0, 0 -- ax, ay
+ const int orig_pos = py * orig_pitch + px * orig_depth;
+ const unsigned char r = orig[orig_pos + 2];
+ const unsigned char g = orig[orig_pos + 1];
+ const unsigned char b = orig[orig_pos + 0];
+
+ // 1, 1 -- ax_, ay_
+ const int orig_pos_ = py_ * orig_pitch + px_ * orig_depth;
+ const unsigned char r_ = orig[orig_pos_ + 2];
+ const unsigned char g_ = orig[orig_pos_ + 1];
+ const unsigned char b_ = orig[orig_pos_ + 0];
+
+ // 1, 0 -- ax_, ay
+ const int orig_pos__ = py * orig_pitch + px_ * orig_depth;
+ const unsigned char r__ = orig[orig_pos__ + 2];
+ const unsigned char g__ = orig[orig_pos__ + 1];
+ const unsigned char b__ = orig[orig_pos__ + 0];
+
+ // 0, 1 -- ax, ay_
+ const int orig_pos___ = py_ * orig_pitch + px * orig_depth;
+ const unsigned char r___ = orig[orig_pos___ + 2];
+ const unsigned char g___ = orig[orig_pos___ + 1];
+ const unsigned char b___ = orig[orig_pos___ + 0];
+
+ const int pos = y * dest_pitch + x * dest_depth;
+
+ //qDebug() << "pos" << fx << fy << "uv" << ax << ay;
+
+ dest[pos + 0] = (r * ax + r__ * ax_) * ay + (r___ * ax + r_ * ax_) * ay_;
+ dest[pos + 1] = (g * ax + g__ * ax_) * ay + (g___ * ax + g_ * ax_) * ay_;
+ dest[pos + 2] = (b * ax + b__ * ax_) * ay + (b___ * ax + b_ * ax_) * ay_;
break;
}