Merge pull request #21602 from karroffel/gdnative-core-1.1
[GDNative] add initial core 1.1 extension
This commit is contained in:
commit
a1019c2c82
|
@ -113,6 +113,40 @@ godot_vector3 GDAPI godot_basis_get_scale(const godot_basis *p_self) {
|
|||
return dest;
|
||||
}
|
||||
|
||||
godot_quat GDAPI godot_basis_get_quat(const godot_basis *p_self) {
|
||||
godot_quat dest;
|
||||
const Basis *self = (const Basis *)p_self;
|
||||
*((Quat *)&dest) = self->get_quat();
|
||||
return dest;
|
||||
}
|
||||
|
||||
void GDAPI godot_basis_set_quat(godot_basis *p_self, const godot_quat *p_quat) {
|
||||
Basis *self = (Basis *)p_self;
|
||||
const Quat *quat = (const Quat *)p_quat;
|
||||
self->set_quat(*quat);
|
||||
}
|
||||
|
||||
void GDAPI godot_basis_set_axis_angle_scale(godot_basis *p_self, const godot_vector3 *p_axis, godot_real p_phi, const godot_vector3 *p_scale) {
|
||||
Basis *self = (Basis *)p_self;
|
||||
const Vector3 *axis = (const Vector3 *)p_axis;
|
||||
const Vector3 *scale = (const Vector3 *)p_scale;
|
||||
self->set_axis_angle_scale(*axis, p_phi, *scale);
|
||||
}
|
||||
|
||||
void GDAPI godot_basis_set_euler_scale(godot_basis *p_self, const godot_vector3 *p_euler, const godot_vector3 *p_scale) {
|
||||
Basis *self = (Basis *)p_self;
|
||||
const Vector3 *euler = (const Vector3 *)p_euler;
|
||||
const Vector3 *scale = (const Vector3 *)p_scale;
|
||||
self->set_euler_scale(*euler, *scale);
|
||||
}
|
||||
|
||||
void GDAPI godot_basis_set_quat_scale(godot_basis *p_self, const godot_quat *p_quat, const godot_vector3 *p_scale) {
|
||||
Basis *self = (Basis *)p_self;
|
||||
const Quat *quat = (const Quat *)p_quat;
|
||||
const Vector3 *scale = (const Vector3 *)p_scale;
|
||||
self->set_quat_scale(*quat, *scale);
|
||||
}
|
||||
|
||||
godot_vector3 GDAPI godot_basis_get_euler(const godot_basis *p_self) {
|
||||
godot_vector3 dest;
|
||||
const Basis *self = (const Basis *)p_self;
|
||||
|
|
|
@ -155,6 +155,12 @@ godot_string GDAPI godot_dictionary_to_json(const godot_dictionary *p_self) {
|
|||
return raw_dest;
|
||||
}
|
||||
|
||||
godot_bool GDAPI godot_dictionary_erase_with_return(godot_dictionary *p_self, const godot_variant *p_key) {
|
||||
Dictionary *self = (Dictionary *)p_self;
|
||||
const Variant *key = (const Variant *)p_key;
|
||||
return self->erase(*key);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -166,6 +166,10 @@ void _gdnative_report_loading_error(const godot_object *p_library, const char *p
|
|||
_err_print_error("gdnative_init", library->get_current_library_path().utf8().ptr(), 0, message.utf8().ptr());
|
||||
}
|
||||
|
||||
bool GDAPI godot_is_instance_valid(const godot_object *p_object) {
|
||||
return ObjectDB::instance_validate((Object *)p_object);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -49,6 +49,18 @@ void GDAPI godot_quat_new_with_axis_angle(godot_quat *r_dest, const godot_vector
|
|||
*dest = Quat(*axis, p_angle);
|
||||
}
|
||||
|
||||
void GDAPI godot_quat_new_with_basis(godot_quat *r_dest, const godot_basis *p_basis) {
|
||||
const Basis *basis = (const Basis *)p_basis;
|
||||
Quat *dest = (Quat *)r_dest;
|
||||
*dest = Quat(*basis);
|
||||
}
|
||||
|
||||
void GDAPI godot_quat_new_with_euler(godot_quat *r_dest, const godot_vector3 *p_euler) {
|
||||
const Vector3 *euler = (const Vector3 *)p_euler;
|
||||
Quat *dest = (Quat *)r_dest;
|
||||
*dest = Quat(*euler);
|
||||
}
|
||||
|
||||
godot_real GDAPI godot_quat_get_x(const godot_quat *p_self) {
|
||||
const Quat *self = (const Quat *)p_self;
|
||||
return self->x;
|
||||
|
|
|
@ -56,6 +56,12 @@ void GDAPI godot_transform_new(godot_transform *r_dest, const godot_basis *p_bas
|
|||
*dest = Transform(*basis, *origin);
|
||||
}
|
||||
|
||||
void GDAPI godot_transform_new_with_quat(godot_transform *r_dest, const godot_quat *p_quat) {
|
||||
const Quat *quat = (const Quat *)p_quat;
|
||||
Transform *dest = (Transform *)r_dest;
|
||||
*dest = Transform(*quat);
|
||||
}
|
||||
|
||||
godot_basis GDAPI godot_transform_get_basis(const godot_transform *p_self) {
|
||||
godot_basis dest;
|
||||
const Transform *self = (const Transform *)p_self;
|
||||
|
|
|
@ -5,7 +5,98 @@
|
|||
"major": 1,
|
||||
"minor": 0
|
||||
},
|
||||
"next": {
|
||||
"type": "CORE",
|
||||
"version": {
|
||||
"major": 1,
|
||||
"minor": 1
|
||||
},
|
||||
"next": null,
|
||||
"api": [
|
||||
{
|
||||
"name": "godot_basis_get_quat",
|
||||
"return_type": "godot_quat",
|
||||
"arguments": [
|
||||
["const godot_basis *", "p_self"]
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "godot_basis_set_quat",
|
||||
"return_type": "void",
|
||||
"arguments": [
|
||||
["godot_basis *", "p_self"],
|
||||
["const godot_quat *", "p_quat"]
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "godot_basis_set_axis_angle_scale",
|
||||
"return_type": "void",
|
||||
"arguments": [
|
||||
["godot_basis *", "p_self"],
|
||||
["const godot_vector3 *", "p_axis"],
|
||||
["godot_real", "p_phi"],
|
||||
["const godot_vector3 *", "p_scale"]
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "godot_basis_set_euler_scale",
|
||||
"return_type": "void",
|
||||
"arguments": [
|
||||
["godot_basis *", "p_self"],
|
||||
["const godot_vector3 *", "p_euler"],
|
||||
["const godot_vector3 *", "p_scale"]
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "godot_basis_set_quat_scale",
|
||||
"return_type": "void",
|
||||
"arguments": [
|
||||
["godot_basis *", "p_self"],
|
||||
["const godot_quat *", "p_quat"],
|
||||
["const godot_vector3 *", "p_scale"]
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "godot_dictionary_erase_with_return",
|
||||
"return_type": "bool",
|
||||
"arguments": [
|
||||
["godot_dictionary *", "p_self"],
|
||||
["const godot_variant *", "p_key"]
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "godot_is_instance_valid",
|
||||
"return_type": "bool",
|
||||
"arguments": [
|
||||
["const godot_object *", "p_object"]
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "godot_quat_new_with_basis",
|
||||
"return_type": "void",
|
||||
"arguments": [
|
||||
["godot_quat *", "r_dest"],
|
||||
["const godot_basis *", "p_basis"]
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "godot_quat_new_with_euler",
|
||||
"return_type": "void",
|
||||
"arguments": [
|
||||
["godot_quat *", "r_dest"],
|
||||
["const godot_vector3 *", "p_euler"]
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "godot_transform_new_with_quat",
|
||||
"return_type": "void",
|
||||
"arguments": [
|
||||
["godot_transform *", "r_dest"],
|
||||
["const godot_quat *", "p_quat"]
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"api": [
|
||||
{
|
||||
"name": "godot_color_new_rgba",
|
||||
|
|
|
@ -82,10 +82,35 @@ def _build_gdnative_api_struct_header(api):
|
|||
|
||||
return ret_val
|
||||
|
||||
|
||||
def generate_core_extension_struct(core):
|
||||
ret_val = []
|
||||
if core['next']:
|
||||
ret_val += generate_core_extension_struct(core['next'])
|
||||
|
||||
ret_val += [
|
||||
'typedef struct godot_gdnative_core_' + ('{0}_{1}'.format(core['version']['major'], core['version']['minor'])) + '_api_struct {',
|
||||
'\tunsigned int type;',
|
||||
'\tgodot_gdnative_api_version version;',
|
||||
'\tconst godot_gdnative_api_struct *next;',
|
||||
]
|
||||
|
||||
for funcdef in core['api']:
|
||||
args = ', '.join(['%s%s' % (_spaced(t), n) for t, n in funcdef['arguments']])
|
||||
ret_val.append('\t%s(*%s)(%s);' % (_spaced(funcdef['return_type']), funcdef['name'], args))
|
||||
|
||||
ret_val += ['} godot_gdnative_core_' + '{0}_{1}'.format(core['version']['major'], core['version']['minor']) + '_api_struct;', '']
|
||||
|
||||
return ret_val
|
||||
|
||||
|
||||
for ext in api['extensions']:
|
||||
name = ext['name']
|
||||
out += generate_extension_struct(name, ext, False)
|
||||
|
||||
if api['core']['next']:
|
||||
out += generate_core_extension_struct(api['core']['next'])
|
||||
|
||||
out += [
|
||||
'typedef struct godot_gdnative_core_api_struct {',
|
||||
'\tunsigned int type;',
|
||||
|
@ -147,6 +172,27 @@ def _build_gdnative_api_struct_source(api):
|
|||
|
||||
return ret_val
|
||||
|
||||
|
||||
def get_core_struct_definition(core):
|
||||
ret_val = []
|
||||
|
||||
if core['next']:
|
||||
ret_val += get_core_struct_definition(core['next'])
|
||||
|
||||
ret_val += [
|
||||
'extern const godot_gdnative_core_' + ('{0}_{1}_api_struct api_{0}_{1}'.format(core['version']['major'], core['version']['minor'])) + ' = {',
|
||||
'\tGDNATIVE_' + core['type'] + ',',
|
||||
'\t{' + str(core['version']['major']) + ', ' + str(core['version']['minor']) + '},',
|
||||
'\t' + ('NULL' if not core['next'] else ('(const godot_gdnative_api_struct *)& api_{0}_{1}'.format(core['version']['major'], core['version']['minor']))) + ','
|
||||
]
|
||||
|
||||
for funcdef in core['api']:
|
||||
ret_val.append('\t%s,' % funcdef['name'])
|
||||
|
||||
ret_val += ['};\n']
|
||||
|
||||
return ret_val
|
||||
|
||||
for ext in api['extensions']:
|
||||
name = ext['name']
|
||||
out += get_extension_struct_definition(name, ext, False)
|
||||
|
@ -159,6 +205,9 @@ def _build_gdnative_api_struct_source(api):
|
|||
|
||||
out += ['};\n']
|
||||
|
||||
if api['core']['next']:
|
||||
out += get_core_struct_definition(api['core']['next'])
|
||||
|
||||
out += [
|
||||
'extern const godot_gdnative_core_api_struct api_struct = {',
|
||||
'\tGDNATIVE_' + api['core']['type'] + ',',
|
||||
|
|
|
@ -62,6 +62,7 @@ extern "C" {
|
|||
void GDAPI godot_basis_new_with_rows(godot_basis *r_dest, const godot_vector3 *p_x_axis, const godot_vector3 *p_y_axis, const godot_vector3 *p_z_axis);
|
||||
void GDAPI godot_basis_new_with_axis_and_angle(godot_basis *r_dest, const godot_vector3 *p_axis, const godot_real p_phi);
|
||||
void GDAPI godot_basis_new_with_euler(godot_basis *r_dest, const godot_vector3 *p_euler);
|
||||
void GDAPI godot_basis_new_with_euler_quat(godot_basis *r_dest, const godot_quat *p_euler);
|
||||
|
||||
godot_string GDAPI godot_basis_as_string(const godot_basis *p_self);
|
||||
|
||||
|
@ -81,6 +82,16 @@ godot_vector3 GDAPI godot_basis_get_scale(const godot_basis *p_self);
|
|||
|
||||
godot_vector3 GDAPI godot_basis_get_euler(const godot_basis *p_self);
|
||||
|
||||
godot_quat GDAPI godot_basis_get_quat(const godot_basis *p_self);
|
||||
|
||||
void GDAPI godot_basis_set_quat(godot_basis *p_self, const godot_quat *p_quat);
|
||||
|
||||
void GDAPI godot_basis_set_axis_angle_scale(godot_basis *p_self, const godot_vector3 *p_axis, godot_real p_phi, const godot_vector3 *p_scale);
|
||||
|
||||
void GDAPI godot_basis_set_euler_scale(godot_basis *p_self, const godot_vector3 *p_euler, const godot_vector3 *p_scale);
|
||||
|
||||
void GDAPI godot_basis_set_quat_scale(godot_basis *p_self, const godot_quat *p_quat, const godot_vector3 *p_scale);
|
||||
|
||||
godot_real GDAPI godot_basis_tdotx(const godot_basis *p_self, const godot_vector3 *p_with);
|
||||
|
||||
godot_real GDAPI godot_basis_tdoty(const godot_basis *p_self, const godot_vector3 *p_with);
|
||||
|
@ -95,8 +106,6 @@ godot_int GDAPI godot_basis_get_orthogonal_index(const godot_basis *p_self);
|
|||
|
||||
void GDAPI godot_basis_new(godot_basis *r_dest);
|
||||
|
||||
void GDAPI godot_basis_new_with_euler_quat(godot_basis *r_dest, const godot_quat *p_euler);
|
||||
|
||||
// p_elements is a pointer to an array of 3 (!!) vector3
|
||||
void GDAPI godot_basis_get_elements(const godot_basis *p_self, godot_vector3 *p_elements);
|
||||
|
||||
|
|
|
@ -94,6 +94,8 @@ godot_bool GDAPI godot_dictionary_operator_equal(const godot_dictionary *p_self,
|
|||
|
||||
godot_string GDAPI godot_dictionary_to_json(const godot_dictionary *p_self);
|
||||
|
||||
godot_bool GDAPI godot_dictionary_erase_with_return(godot_dictionary *p_self, const godot_variant *p_key);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -282,6 +282,10 @@ void GDAPI godot_print_error(const char *p_description, const char *p_function,
|
|||
void GDAPI godot_print_warning(const char *p_description, const char *p_function, const char *p_file, int p_line);
|
||||
void GDAPI godot_print(const godot_string *p_message);
|
||||
|
||||
// GDNATIVE CORE 1.0.1
|
||||
|
||||
bool GDAPI godot_is_instance_valid(const godot_object *p_object);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -60,6 +60,8 @@ extern "C" {
|
|||
|
||||
void GDAPI godot_quat_new(godot_quat *r_dest, const godot_real p_x, const godot_real p_y, const godot_real p_z, const godot_real p_w);
|
||||
void GDAPI godot_quat_new_with_axis_angle(godot_quat *r_dest, const godot_vector3 *p_axis, const godot_real p_angle);
|
||||
void GDAPI godot_quat_new_with_basis(godot_quat *r_dest, const godot_basis *p_basis);
|
||||
void GDAPI godot_quat_new_with_euler(godot_quat *r_dest, const godot_vector3 *p_euler);
|
||||
|
||||
godot_real GDAPI godot_quat_get_x(const godot_quat *p_self);
|
||||
void GDAPI godot_quat_set_x(godot_quat *p_self, const godot_real val);
|
||||
|
|
|
@ -62,6 +62,7 @@ extern "C" {
|
|||
|
||||
void GDAPI godot_transform_new_with_axis_origin(godot_transform *r_dest, const godot_vector3 *p_x_axis, const godot_vector3 *p_y_axis, const godot_vector3 *p_z_axis, const godot_vector3 *p_origin);
|
||||
void GDAPI godot_transform_new(godot_transform *r_dest, const godot_basis *p_basis, const godot_vector3 *p_origin);
|
||||
void GDAPI godot_transform_new_with_quat(godot_transform *r_dest, const godot_quat *p_quat);
|
||||
|
||||
godot_basis GDAPI godot_transform_get_basis(const godot_transform *p_self);
|
||||
void GDAPI godot_transform_set_basis(godot_transform *p_self, const godot_basis *p_v);
|
||||
|
|
Loading…
Reference in New Issue