~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to source/gameengine/Ketsji/KX_MouseFocusSensor.cpp

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 *  \ingroup ketsji
31
31
 */
32
32
 
33
 
 
34
 
#if defined(WIN32) && !defined(FREE_WINDOWS)
35
 
// This warning tells us about truncation of __long__ stl-generated names.
36
 
// It can occasionally cause DevStudio to have internal compiler warnings.
37
 
#pragma warning( disable : 4786 )     
 
33
#ifdef _MSC_VER
 
34
  /* This warning tells us about truncation of __long__ stl-generated names.
 
35
   * It can occasionally cause DevStudio to have internal compiler warnings. */
 
36
#  pragma warning(disable:4786)
38
37
#endif
39
38
 
40
39
#include "MT_Point3.h"
60
59
/* ------------------------------------------------------------------------- */
61
60
 
62
61
KX_MouseFocusSensor::KX_MouseFocusSensor(SCA_MouseManager* eventmgr, 
63
 
                                                                                 int startx,
64
 
                                                                                 int starty,
65
 
                                                                                 short int mousemode,
66
 
                                                                                 int focusmode,
67
 
                                                                                 bool bTouchPulse,
68
 
                                                                                 KX_Scene* kxscene,
69
 
                                                                                 KX_KetsjiEngine *kxengine,
70
 
                                                                                 SCA_IObject* gameobj)
 
62
                                         int startx,
 
63
                                         int starty,
 
64
                                         short int mousemode,
 
65
                                         int focusmode,
 
66
                                         bool bTouchPulse,
 
67
                                         KX_Scene* kxscene,
 
68
                                         KX_KetsjiEngine *kxengine,
 
69
                                         SCA_IObject* gameobj)
71
70
        : SCA_MouseSensor(eventmgr, startx, starty, mousemode, gameobj),
72
71
          m_focusmode(focusmode),
73
72
          m_bTouchPulse(bTouchPulse),
142
141
        KX_GameObject* hitKXObj = client_info->m_gameobject;
143
142
        
144
143
        /* Is this me? In the ray test, there are a lot of extra checks
145
 
         * for aliasing artefacts from self-hits. That doesn't happen
 
144
         * for aliasing artifacts from self-hits. That doesn't happen
146
145
         * here, so a simple test suffices. Or does the camera also get
147
146
         * self-hits? (No, and the raysensor shouldn't do it either, since
148
147
         * self-hits are excluded by setting the correct ignore-object.)
239
238
        
240
239
        /*      build the from and to point in normalized device coordinates 
241
240
         *      Normalized device coordinates are [-1,1] in x, y, z
242
 
         *      
 
241
         *
243
242
         *      The actual z coordinates used don't have to be exact just infront and 
244
243
         *      behind of the near and far clip planes.
245
244
         */ 
309
308
        list<class KX_Camera*>* cameras = m_kxscene->GetCameras();
310
309
        list<KX_Camera*>::iterator it = cameras->begin();
311
310
        
312
 
        while(it != cameras->end())
313
 
        {
 
311
        while (it != cameras->end()) {
314
312
                if (((*it) != cam) && (*it)->GetViewport())
315
313
                        if (ParentObjectHasFocusCamera(*it))
316
314
                                return true;
392
390
};
393
391
 
394
392
/* Attributes */
395
 
PyObject* KX_MouseFocusSensor::pyattr_get_ray_source(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
 
393
PyObject *KX_MouseFocusSensor::pyattr_get_ray_source(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
396
394
{
397
 
        KX_MouseFocusSensor* self= static_cast<KX_MouseFocusSensor*>(self_v);
 
395
        KX_MouseFocusSensor* self = static_cast<KX_MouseFocusSensor*>(self_v);
398
396
        return PyObjectFrom(self->RaySource());
399
397
}
400
398
 
401
 
PyObject* KX_MouseFocusSensor::pyattr_get_ray_target(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
 
399
PyObject *KX_MouseFocusSensor::pyattr_get_ray_target(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
402
400
{
403
 
        KX_MouseFocusSensor* self= static_cast<KX_MouseFocusSensor*>(self_v);
 
401
        KX_MouseFocusSensor* self = static_cast<KX_MouseFocusSensor*>(self_v);
404
402
        return PyObjectFrom(self->RayTarget());
405
403
}
406
404
 
407
 
PyObject* KX_MouseFocusSensor::pyattr_get_ray_direction(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
 
405
PyObject *KX_MouseFocusSensor::pyattr_get_ray_direction(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
408
406
{
409
 
        KX_MouseFocusSensor* self= static_cast<KX_MouseFocusSensor*>(self_v);
 
407
        KX_MouseFocusSensor* self = static_cast<KX_MouseFocusSensor*>(self_v);
410
408
        MT_Vector3 dir = self->RayTarget() - self->RaySource();
411
409
        if (MT_fuzzyZero(dir))  dir.setValue(0,0,0);
412
410
        else                                    dir.normalize();
413
411
        return PyObjectFrom(dir);
414
412
}
415
413
 
416
 
PyObject* KX_MouseFocusSensor::pyattr_get_hit_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
 
414
PyObject *KX_MouseFocusSensor::pyattr_get_hit_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
417
415
{
418
 
        KX_MouseFocusSensor* self= static_cast<KX_MouseFocusSensor*>(self_v);
 
416
        KX_MouseFocusSensor* self = static_cast<KX_MouseFocusSensor*>(self_v);
419
417
        
420
418
        if (self->m_hitObject)
421
419
                return self->m_hitObject->GetProxy();
423
421
        Py_RETURN_NONE;
424
422
}
425
423
 
426
 
PyObject* KX_MouseFocusSensor::pyattr_get_hit_position(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
 
424
PyObject *KX_MouseFocusSensor::pyattr_get_hit_position(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
427
425
{
428
 
        KX_MouseFocusSensor* self= static_cast<KX_MouseFocusSensor*>(self_v);
 
426
        KX_MouseFocusSensor* self = static_cast<KX_MouseFocusSensor*>(self_v);
429
427
        return PyObjectFrom(self->HitPosition());
430
428
}
431
429
 
432
 
PyObject* KX_MouseFocusSensor::pyattr_get_hit_normal(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
 
430
PyObject *KX_MouseFocusSensor::pyattr_get_hit_normal(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
433
431
{
434
 
        KX_MouseFocusSensor* self= static_cast<KX_MouseFocusSensor*>(self_v);
 
432
        KX_MouseFocusSensor* self = static_cast<KX_MouseFocusSensor*>(self_v);
435
433
        return PyObjectFrom(self->HitNormal());
436
434
}
437
435
 
438
 
PyObject* KX_MouseFocusSensor::pyattr_get_hit_uv(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
 
436
PyObject *KX_MouseFocusSensor::pyattr_get_hit_uv(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
439
437
{
440
 
        KX_MouseFocusSensor* self= static_cast<KX_MouseFocusSensor*>(self_v);
 
438
        KX_MouseFocusSensor* self = static_cast<KX_MouseFocusSensor*>(self_v);
441
439
        return PyObjectFrom(self->HitUV());
442
440
}
443
441