Logic UI - fixing missing rna default values

there are some cases (i.e. Constraint Actuator) where the same DNA property is being used by different RNAs with different ranges.
It's easy to change (reset the values to their default in the set func of the constrant type rna).
Not sure it's necessary though.
This commit is contained in:
Dalai Felinto
2010-05-07 18:53:28 +00:00
parent 5774e61f4a
commit 22978ebfdc
4 changed files with 23 additions and 6 deletions

View File

@@ -98,6 +98,8 @@ void init_sensor(bSensor *sens)
/* also use when sensor changes type */
bNearSensor *ns;
bMouseSensor *ms;
bJoystickSensor *js;
bRaySensor *rs;
if(sens->data) MEM_freeN(sens->data);
sens->data= NULL;
@@ -145,12 +147,18 @@ void init_sensor(bSensor *sens)
break;
case SENS_RAY:
sens->data= MEM_callocN(sizeof(bRaySensor), "raysens");
rs = sens->data;
rs->range = 0.01f;
break;
case SENS_MESSAGE:
sens->data= MEM_callocN(sizeof(bMessageSensor), "messagesens");
break;
case SENS_JOYSTICK:
sens->data= MEM_callocN(sizeof(bJoystickSensor), "joysticksens");
js= sens->data;
js->hatf = SENS_JOY_HAT_UP;
js->axis = 1;
js->hat = 1;
break;
default:
; /* this is very severe... I cannot make any memory for this */
@@ -383,7 +391,9 @@ void copy_actuators(ListBase *lbn, ListBase *lbo)
void init_actuator(bActuator *act)
{
/* also use when actuator changes type */
bCameraActuator *ca;
bObjectActuator *oa;
bRandomActuator *ra;
bSoundActuator *sa;
if(act->data) MEM_freeN(act->data);
@@ -417,6 +427,8 @@ void init_actuator(bActuator *act)
break;
case ACT_CAMERA:
act->data= MEM_callocN(sizeof(bCameraActuator), "camact");
ca = act->data;
ca->axis = ACT_CAMERA_X;
break;
case ACT_EDIT_OBJECT:
act->data= MEM_callocN(sizeof(bEditObjectActuator), "editobact");
@@ -432,6 +444,8 @@ void init_actuator(bActuator *act)
break;
case ACT_RANDOM:
act->data= MEM_callocN(sizeof(bRandomActuator), "random act");
ra=act->data;
ra->float_arg_1 = 0.1f;
break;
case ACT_MESSAGE:
act->data= MEM_callocN(sizeof(bMessageActuator), "message act");

View File

@@ -3284,7 +3284,7 @@ static void draw_sensor_joystick(uiLayout *layout, PointerRNA *ptr)
col = uiLayoutColumn(layout, 0);
uiLayoutSetActive(col, RNA_boolean_get(ptr, "all_events")==0);
uiItemR(col, ptr, "hat_direction", 0, NULL, 0); //XXXSENSOR - needs a default value (somewhere else in the code)
uiItemR(col, ptr, "hat_direction", 0, NULL, 0);
break;
case SENS_JOY_AXIS_SINGLE:
row = uiLayoutRow(layout, 0);
@@ -3924,6 +3924,8 @@ static void draw_actuator_motion(uiLayout *layout, PointerRNA *ptr)
uiItemR(subcol, ptr, "force_min_z", 0, NULL, 0);
//XXXACTUATOR missing labels from original 2.49 ui (e.g. Servo, Min, Max, Fast)
//Layout designers willing to help on that, please compare with 2.49 ui
// (since the old code is going to be deleted ... soon)
col = uiLayoutColumn(layout, 1);
uiItemR(col, ptr, "proportional_coefficient", UI_ITEM_R_SLIDER, NULL, 0);

View File

@@ -498,6 +498,10 @@ typedef struct FreeCamera {
#define ACT_STATE_REMOVE 2
#define ACT_STATE_CHANGE 3
/* cameraactuator->axis */
#define ACT_CAMERA_X (float)'x'
#define ACT_CAMERA_Y (float)'y'
#endif

View File

@@ -776,8 +776,8 @@ static void rna_def_camera_actuator(BlenderRNA *brna)
PropertyRNA *prop;
static EnumPropertyItem prop_axis_items[] ={
{(float)'x', "X", 0, "X", "Camera tries to get behind the X axis"},
{(float)'y', "Y", 0, "Y", "Camera tries to get behind the Y axis"},
{ACT_CAMERA_X, "X", 0, "X", "Camera tries to get behind the X axis"},
{ACT_CAMERA_Y, "Y", 0, "Y", "Camera tries to get behind the Y axis"},
{0, NULL, 0, NULL, NULL}};
srna= RNA_def_struct(brna, "CameraActuator", "Actuator");
@@ -808,14 +808,11 @@ static void rna_def_camera_actuator(BlenderRNA *brna)
RNA_def_property_update(prop, NC_LOGIC, NULL);
/* x/y */
// It could be changed to be a regular ENUM instead of this weird "(float)string enum"
prop= RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "axis");
RNA_def_property_enum_items(prop, prop_axis_items);
RNA_def_property_ui_text(prop, "Axis", "Specify the axis the Camera will try to get behind");
RNA_def_property_update(prop, NC_LOGIC, NULL);
//XXX it's not working (no default value)
// probably need to make a get/set function
}
static void rna_def_sound_actuator(BlenderRNA *brna)