55 lines
1.3 KiB
C
55 lines
1.3 KiB
C
/**
|
|
* Copyright (c) 2026 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#include "entity/entitymanager.h"
|
|
|
|
void entityTriggerInit(
|
|
const entityid_t entityId,
|
|
const componentid_t componentId
|
|
) {
|
|
entitytrigger_t *t = componentGetData(
|
|
entityId, componentId, COMPONENT_TYPE_TRIGGER
|
|
);
|
|
glm_vec3_zero(t->min);
|
|
glm_vec3_zero(t->max);
|
|
}
|
|
|
|
entitytrigger_t * entityTriggerGet(
|
|
const entityid_t entityId,
|
|
const componentid_t componentId
|
|
) {
|
|
return componentGetData(entityId, componentId, COMPONENT_TYPE_TRIGGER);
|
|
}
|
|
|
|
bool_t entityTriggerContains(
|
|
const entityid_t entityId,
|
|
const componentid_t componentId,
|
|
const vec3 point
|
|
) {
|
|
entitytrigger_t *t = componentGetData(
|
|
entityId, componentId, COMPONENT_TYPE_TRIGGER
|
|
);
|
|
return (
|
|
point[0] >= t->min[0] && point[0] <= t->max[0] &&
|
|
point[1] >= t->min[1] && point[1] <= t->max[1] &&
|
|
point[2] >= t->min[2] && point[2] <= t->max[2]
|
|
);
|
|
}
|
|
|
|
void entityTriggerSetBounds(
|
|
const entityid_t entityId,
|
|
const componentid_t componentId,
|
|
const vec3 min,
|
|
const vec3 max
|
|
) {
|
|
entitytrigger_t *t = componentGetData(
|
|
entityId, componentId, COMPONENT_TYPE_TRIGGER
|
|
);
|
|
glm_vec3_copy((float_t*)min, t->min);
|
|
glm_vec3_copy((float_t*)max, t->max);
|
|
}
|