forked from bartvdbraak/blender
BGE Bugfix: [#24926] Sensor 'Radar' les axes X+ et Y+ ont été inversé. (oui, a french bug report :)
we were using SENSOR_RAY for the radar sensor axis. However the Ray axis is inverted (God knows why) so I created a set of defines only for radar sensor. Also I thought it was a good idea to replace some hardcoded values in Radar and Ray codes by their defines in DNA_sensor_types.h (similar to what Benoit did for Armature Sensor, so I see no problem on that).
This commit is contained in:
parent
886e7a7f45
commit
9d9a88348e
@ -207,6 +207,14 @@ typedef struct bJoystickSensor {
|
||||
#define SENS_RAY_NEG_Z_AXIS 5
|
||||
//#define SENS_RAY_NEGATIVE_AXIS 1
|
||||
|
||||
/* bRadarSensor->axis */
|
||||
#define SENS_RADAR_X_AXIS 0
|
||||
#define SENS_RADAR_Y_AXIS 1
|
||||
#define SENS_RADAR_Z_AXIS 2
|
||||
#define SENS_RADAR_NEG_X_AXIS 3
|
||||
#define SENS_RADAR_NEG_Y_AXIS 4
|
||||
#define SENS_RADAR_NEG_Z_AXIS 5
|
||||
|
||||
/* bMessageSensor->type */
|
||||
#define SENS_MESG_MESG 0
|
||||
#define SENS_MESG_PROP 1
|
||||
|
@ -606,12 +606,12 @@ static void rna_def_radar_sensor(BlenderRNA *brna)
|
||||
StructRNA *srna;
|
||||
PropertyRNA *prop;
|
||||
static EnumPropertyItem axis_items[] ={
|
||||
{SENS_RAY_X_AXIS, "XAXIS", 0, "+X axis", ""},
|
||||
{SENS_RAY_Y_AXIS, "YAXIS", 0, "+Y axis", ""},
|
||||
{SENS_RAY_Z_AXIS, "ZAXIS", 0, "+Z axis", ""},
|
||||
{SENS_RAY_NEG_X_AXIS, "NEGXAXIS", 0, "-X axis", ""},
|
||||
{SENS_RAY_NEG_Y_AXIS, "NEGYAXIS", 0, "-Y axis", ""},
|
||||
{SENS_RAY_NEG_Z_AXIS, "NEGZAXIS", 0, "-Z axis", ""},
|
||||
{SENS_RADAR_X_AXIS, "XAXIS", 0, "+X axis", ""},
|
||||
{SENS_RADAR_Y_AXIS, "YAXIS", 0, "+Y axis", ""},
|
||||
{SENS_RADAR_Z_AXIS, "ZAXIS", 0, "+Z axis", ""},
|
||||
{SENS_RADAR_NEG_X_AXIS, "NEGXAXIS", 0, "-X axis", ""},
|
||||
{SENS_RADAR_NEG_Y_AXIS, "NEGYAXIS", 0, "-Y axis", ""},
|
||||
{SENS_RADAR_NEG_Z_AXIS, "NEGZAXIS", 0, "-Z axis", ""},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
|
||||
srna= RNA_def_struct(brna, "RadarSensor", "Sensor");
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "KX_PyMath.h"
|
||||
#include "PHY_IPhysicsController.h"
|
||||
#include "PHY_IMotionState.h"
|
||||
#include "DNA_sensor_types.h"
|
||||
|
||||
/**
|
||||
* RadarSensor constructor. Creates a near-sensor derived class, with a cone collision shape.
|
||||
@ -95,42 +96,42 @@ void KX_RadarSensor::SynchronizeTransform()
|
||||
// depends on the radar 'axis'
|
||||
switch (m_axis)
|
||||
{
|
||||
case 0: // +X Axis
|
||||
case SENS_RADAR_X_AXIS: // +X Axis
|
||||
{
|
||||
MT_Quaternion rotquatje(MT_Vector3(0,0,1),MT_radians(90));
|
||||
trans.rotate(rotquatje);
|
||||
trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0));
|
||||
break;
|
||||
};
|
||||
case 1: // +Y Axis
|
||||
case SENS_RADAR_Y_AXIS: // +Y Axis
|
||||
{
|
||||
MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(-180));
|
||||
trans.rotate(rotquatje);
|
||||
trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0));
|
||||
break;
|
||||
};
|
||||
case 2: // +Z Axis
|
||||
case SENS_RADAR_Z_AXIS: // +Z Axis
|
||||
{
|
||||
MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(-90));
|
||||
trans.rotate(rotquatje);
|
||||
trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0));
|
||||
break;
|
||||
};
|
||||
case 3: // -X Axis
|
||||
case SENS_RADAR_NEG_X_AXIS: // -X Axis
|
||||
{
|
||||
MT_Quaternion rotquatje(MT_Vector3(0,0,1),MT_radians(-90));
|
||||
trans.rotate(rotquatje);
|
||||
trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0));
|
||||
break;
|
||||
};
|
||||
case 4: // -Y Axis
|
||||
case SENS_RADAR_NEG_Y_AXIS: // -Y Axis
|
||||
{
|
||||
//MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(-180));
|
||||
//trans.rotate(rotquatje);
|
||||
trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0));
|
||||
break;
|
||||
};
|
||||
case 5: // -Z Axis
|
||||
case SENS_RADAR_NEG_Z_AXIS: // -Z Axis
|
||||
{
|
||||
MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(90));
|
||||
trans.rotate(rotquatje);
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "PHY_IPhysicsEnvironment.h"
|
||||
#include "KX_IPhysicsController.h"
|
||||
#include "PHY_IPhysicsController.h"
|
||||
#include "DNA_sensor_types.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@ -198,42 +199,42 @@ bool KX_RaySensor::Evaluate()
|
||||
m_reset = false;
|
||||
switch (m_axis)
|
||||
{
|
||||
case 1: // X
|
||||
case SENS_RAY_X_AXIS: // X
|
||||
{
|
||||
todir[0] = invmat[0][0];
|
||||
todir[1] = invmat[0][1];
|
||||
todir[2] = invmat[0][2];
|
||||
break;
|
||||
}
|
||||
case 0: // Y
|
||||
case SENS_RAY_Y_AXIS: // Y
|
||||
{
|
||||
todir[0] = invmat[1][0];
|
||||
todir[1] = invmat[1][1];
|
||||
todir[2] = invmat[1][2];
|
||||
break;
|
||||
}
|
||||
case 2: // Z
|
||||
case SENS_RAY_Z_AXIS: // Z
|
||||
{
|
||||
todir[0] = invmat[2][0];
|
||||
todir[1] = invmat[2][1];
|
||||
todir[2] = invmat[2][2];
|
||||
break;
|
||||
}
|
||||
case 3: // -X
|
||||
case SENS_RAY_NEG_X_AXIS: // -X
|
||||
{
|
||||
todir[0] = -invmat[0][0];
|
||||
todir[1] = -invmat[0][1];
|
||||
todir[2] = -invmat[0][2];
|
||||
break;
|
||||
}
|
||||
case 4: // -Y
|
||||
case SENS_RAY_NEG_Y_AXIS: // -Y
|
||||
{
|
||||
todir[0] = -invmat[1][0];
|
||||
todir[1] = -invmat[1][1];
|
||||
todir[2] = -invmat[1][2];
|
||||
break;
|
||||
}
|
||||
case 5: // -Z
|
||||
case SENS_RAY_NEG_Z_AXIS: // -Z
|
||||
{
|
||||
todir[0] = -invmat[2][0];
|
||||
todir[1] = -invmat[2][1];
|
||||
|
Loading…
Reference in New Issue
Block a user