Example #1
0
DWORD WINAPI MainWorkingThread(LPVOID lParam) {
MSG msg; int bret;
HANDLE EventHandle = *(HANDLE*) lParam;
TINFO("Thread gestartet!");
TINFO("Erstelle Message-Queue...");
PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE);
TINFO("Messasge Queue erstellt!");
SetEvent(EventHandle);
while(bret = GetMessage(&msg,NULL,0,0)> 0) {
if(handleMessage(msg.message,msg.wParam,msg.lParam) == 0) {
TERR("Nachricht konnte nicht bearbeitet werden!");
}
}
TINFO("Worker Thread wird beendet...");
SetEvent(EventHandle);
ExitThread(0);	
}
Example #2
0
BOOL handleMessage(UINT msg, WPARAM wParam, LPARAM lParam) {
	switch(msg) {
		case TH_PYTHON_START:
		TINFO("Starte Python Interpreter!");
		start_python();
		break;
		case TH_START:
			TINFO("Nachricht empfangen!");
		break;
		case WM_CLOSE:
			TINFO("Beende Python Interpreter...");
			close_python();
			PostQuitMessage(0);
		break;
		case TH_HANDLE: {
				char** it = getItems(items[4].handle);
				TINFO(it[0]);
		}
		break;
		default:
		return 0;
	}
	return 1;
}
Example #3
0
bool Bvh::intersect( Ray& l_pRay, HitInfo* pHitInfo )
{
    bool found = false;
    pHitInfo->hitTime = POS_INF;
    pHitInfo->bHasInfo = false;

    //double maxhit = info.hitTime;
    float tmin, tmax;
    float lhit, rhit,hit1, hit2;
    hit1 = POS_INF;
    
    if(!myBound.Intersect(l_pRay, tmin, tmax))
    {
        return false;
    }

    std::deque<TINFO> todo;
    bool lefthit, righthit;
    lefthit = righthit = false;
    bvhNode* current = &bTree[0];
    while (!found)
    {
        if (current->extra) // is leaf
        {
            if (pHitInfo->hitTime == POS_INF || hit1 < pHitInfo->hitTime)
            {
                HitInfo newinfo;
                current->pTris->intersect(l_pRay, &newinfo);
                if(newinfo.hitTime < pHitInfo->hitTime)
                {
                    *pHitInfo = newinfo;
                    pHitInfo->bHasInfo = true;
                }
            }

            if( !todo.empty())
            {
                current = &bTree[todo[0].index];
                hit1 = todo[0].tmin;
                todo.pop_front();
            }
            else
            {
                found = true;
            }
        }
        else // is node
        {
            lefthit = righthit = false;
            unsigned int left = current->leftChild;
            unsigned int right = left+1;
            if (pHitInfo->hitTime == POS_INF || hit1 < pHitInfo->hitTime)
            {
                if (bTree[left].bound.Intersect(l_pRay, lhit, hit2))
                {
                    lefthit = true;
                }

                if (bTree[right].bound.Intersect(l_pRay, rhit, hit2))
                {
                    righthit = true;
                }
            }
            
            if (lefthit && righthit)
            {
                if (rhit > lhit)
                {
                    current = &bTree[left];
                    todo.push_front(TINFO(right, rhit));
                    hit1 = lhit;
                }
                else
                {
                    current = &bTree[right];
                    todo.push_front(TINFO(left, lhit));
                    hit1 = rhit;
                }
            }
            else if(lefthit)
            {
                current = &bTree[left];
                hit1 = lhit;
            }
            else if(righthit)
            {
                current = &bTree[right];
                hit1 = rhit;
            }
            else
            {
                if(!todo.empty())
                {
                    current = &bTree[todo[0].index];
                    hit1 = todo[0].tmin;
                    todo.pop_front();
                }
                else
                {
                    break; // hit nothing
                }
            }
        }
    }

    return pHitInfo->bHasInfo;
}