2011-02-22 10:33:14 +00:00
|
|
|
/*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2008-04-16 22:40:48 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
|
2011-02-22 10:33:14 +00:00
|
|
|
/** \file KX_NearSensor.h
|
|
|
|
* \ingroup ketsji
|
|
|
|
* \brief Sense if other objects are near
|
|
|
|
*/
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#ifndef KX_NEARSENSOR_H
|
|
|
|
#define KX_NEARSENSOR_H
|
|
|
|
|
|
|
|
#include "KX_TouchSensor.h"
|
2004-03-22 22:02:18 +00:00
|
|
|
#include "KX_ClientObjectInfo.h"
|
2002-11-25 11:16:17 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
class KX_Scene;
|
2005-03-25 10:33:39 +00:00
|
|
|
struct PHY_CollData;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
class KX_NearSensor : public KX_TouchSensor
|
|
|
|
{
|
2011-11-06 01:39:36 +00:00
|
|
|
Py_Header
|
2005-03-25 10:33:39 +00:00
|
|
|
protected:
|
2009-02-28 21:00:27 +00:00
|
|
|
float m_Margin;
|
|
|
|
float m_ResetMargin;
|
2009-07-31 09:05:13 +00:00
|
|
|
|
2004-03-22 22:02:18 +00:00
|
|
|
KX_ClientObjectInfo* m_client_info;
|
2005-03-25 10:33:39 +00:00
|
|
|
public:
|
2004-03-22 22:02:18 +00:00
|
|
|
KX_NearSensor(class SCA_EventManager* eventmgr,
|
2011-11-11 13:09:14 +00:00
|
|
|
class KX_GameObject* gameobj,
|
|
|
|
float margin,
|
|
|
|
float resetmargin,
|
|
|
|
bool bFindMaterial,
|
|
|
|
const STR_String& touchedpropname,
|
|
|
|
PHY_IPhysicsController* ctrl);
|
2005-03-25 10:33:39 +00:00
|
|
|
/*
|
2002-10-12 11:37:38 +00:00
|
|
|
public:
|
2004-03-22 22:02:18 +00:00
|
|
|
KX_NearSensor(class SCA_EventManager* eventmgr,
|
|
|
|
class KX_GameObject* gameobj,
|
|
|
|
double margin,
|
|
|
|
double resetmargin,
|
|
|
|
bool bFindMaterial,
|
|
|
|
const STR_String& touchedpropname,
|
2009-06-28 11:22:26 +00:00
|
|
|
class KX_Scene* scene);
|
2005-03-25 10:33:39 +00:00
|
|
|
*/
|
2002-10-12 11:37:38 +00:00
|
|
|
virtual ~KX_NearSensor();
|
2008-04-19 21:09:40 +00:00
|
|
|
virtual void SynchronizeTransform();
|
2002-10-12 11:37:38 +00:00
|
|
|
virtual CValue* GetReplica();
|
2009-06-08 20:08:19 +00:00
|
|
|
virtual void ProcessReplica();
|
2009-09-13 08:50:54 +00:00
|
|
|
virtual void SetPhysCtrlRadius();
|
2009-06-08 20:08:19 +00:00
|
|
|
virtual bool Evaluate();
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
virtual void ReParent(SCA_IObject* parent);
|
2005-03-25 10:33:39 +00:00
|
|
|
virtual bool NewHandleCollision(void* obj1,void* obj2,
|
|
|
|
const PHY_CollData * coll_data);
|
2008-03-01 19:17:37 +00:00
|
|
|
virtual bool BroadPhaseFilterCollision(void*obj1,void*obj2);
|
2009-06-08 20:08:19 +00:00
|
|
|
virtual bool BroadPhaseSensorFilterCollision(void*obj1,void*obj2) { return false; };
|
|
|
|
virtual sensortype GetSensorType() { return ST_NEAR; }
|
2009-02-28 21:00:27 +00:00
|
|
|
|
2010-10-31 04:11:39 +00:00
|
|
|
#ifdef WITH_PYTHON
|
2009-09-29 21:42:40 +00:00
|
|
|
|
2009-02-28 21:00:27 +00:00
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
/* Python interface ---------------------------------------------------- */
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
//No methods
|
|
|
|
|
|
|
|
//This method is used to make sure the distance does not exceed the reset distance
|
|
|
|
static int CheckResetDistance(void *self, const PyAttributeDef*)
|
|
|
|
{
|
|
|
|
KX_NearSensor* sensor = reinterpret_cast<KX_NearSensor*>(self);
|
|
|
|
|
|
|
|
if (sensor->m_Margin > sensor->m_ResetMargin)
|
|
|
|
sensor->m_ResetMargin = sensor->m_Margin;
|
|
|
|
|
2009-09-13 08:50:54 +00:00
|
|
|
sensor->SetPhysCtrlRadius();
|
|
|
|
|
2009-02-28 21:00:27 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2010-10-31 04:11:39 +00:00
|
|
|
#endif // WITH_PYTHON
|
2009-09-29 21:42:40 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
};
|
2002-10-30 02:07:20 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#endif //KX_NEARSENSOR_H
|
2002-10-30 02:07:20 +00:00
|
|
|
|