2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19 * All rights reserved.
21 * The Original Code is: all of this file.
23 * Contributor(s): none yet.
25 * ***** END GPL LICENSE BLOCK *****
28 /** \file KX_NearSensor.h
30 * \brief Sense if other objects are near
33 #ifndef __KX_NEARSENSOR_H__
34 #define __KX_NEARSENSOR_H__
36 #include "KX_TouchSensor.h"
37 #include "KX_ClientObjectInfo.h"
42 class KX_NearSensor : public KX_TouchSensor
49 KX_ClientObjectInfo* m_client_info;
51 KX_NearSensor(class SCA_EventManager* eventmgr,
52 class KX_GameObject* gameobj,
56 const STR_String& touchedpropname,
57 PHY_IPhysicsController* ctrl);
60 KX_NearSensor(class SCA_EventManager* eventmgr,
61 class KX_GameObject* gameobj,
65 const STR_String& touchedpropname,
66 class KX_Scene* scene);
68 virtual ~KX_NearSensor();
69 virtual void SynchronizeTransform();
70 virtual CValue* GetReplica();
71 virtual void ProcessReplica();
72 virtual void SetPhysCtrlRadius();
73 virtual bool Evaluate();
75 virtual void ReParent(SCA_IObject* parent);
76 virtual bool NewHandleCollision(void* obj1,void* obj2,
77 const PHY_CollData * coll_data);
78 virtual bool BroadPhaseFilterCollision(void*obj1,void*obj2);
79 virtual bool BroadPhaseSensorFilterCollision(void*obj1,void*obj2) { return false; };
80 virtual sensortype GetSensorType() { return ST_NEAR; }
84 /* --------------------------------------------------------------------- */
85 /* Python interface ---------------------------------------------------- */
86 /* --------------------------------------------------------------------- */
90 //This method is used to make sure the distance does not exceed the reset distance
91 static int CheckResetDistance(void *self, const PyAttributeDef*)
93 KX_NearSensor* sensor = reinterpret_cast<KX_NearSensor*>(self);
95 if (sensor->m_Margin > sensor->m_ResetMargin)
96 sensor->m_ResetMargin = sensor->m_Margin;
98 sensor->SetPhysCtrlRadius();
103 #endif // WITH_PYTHON
107 #endif //__KX_NEARSENSOR_H__