<commit_before>/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   update.c                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: gpinchon <<EMAIL>>          +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2017/01/07 16:14:33 by gpinchon          #+#    #+#             */
/*   Updated: 2017/01/07 16:48:12 by gpinchon         ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <vml.h>

void	transform_update(TRANSFORM *transform)
{
	if (!transform)
		return ;
	transform->translate = mat4_translate(transform->position);
	transform->rotate = mat4_rotation(transform->rotation);
	transform->scale = mat4_scale(transform->scaling);
	transform->transform = mat4_combine(transform->translate,
		transform->rotate, transform->scale);
	transform->updated = 1;
}

void	transform_set_target(TRANSFORM *transform, TRANSFORM *target)
{
	VEC3	direction;

	if (!transform || !target)
		return ;
	if (!target->updated)
		transform_update(target);
	direction = vec3_normalize(vec3_sub(target->position, transform->position));
	transform->rotation = (VEC3){asin(direction.y), -atan2(direction.x, direction.z), transform->rotation.z};
	transform_update(transform);
}

void	transform_set_parent(TRANSFORM *transform, TRANSFORM *parent)
{

	if (!parent || !transform)
		return ;
	transform->transform = mat4_mult_mat4(parent->transform, transform->transform);
}<commit_msg>Removed target transform update from transform_set_target<commit_after>/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   update.c                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: gpinchon <<EMAIL>>          +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2017/01/07 16:14:33 by gpinchon          #+#    #+#             */
/*   Updated: 2017/01/07 16:48:12 by gpinchon         ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <vml.h>

void	transform_update(TRANSFORM *transform)
{
	if (!transform)
		return ;
	transform->translate = mat4_translate(transform->position);
	transform->rotate = mat4_rotation(transform->rotation);
	transform->scale = mat4_scale(transform->scaling);
	transform->transform = mat4_combine(transform->translate,
		transform->rotate, transform->scale);
	transform->updated = 1;
}

void	transform_set_target(TRANSFORM *transform, TRANSFORM *target)
{
	VEC3	direction;

	if (!transform || !target)
		return ;
	direction = vec3_normalize(vec3_sub(target->position, transform->position));
	transform->rotation = (VEC3){asin(direction.y), -atan2(direction.x, direction.z), transform->rotation.z};
	transform_update(transform);
}

void	transform_set_parent(TRANSFORM *transform, TRANSFORM *parent)
{

	if (!parent || !transform)
		return ;
	transform->transform = mat4_mult_mat4(parent->transform, transform->transform);
}
{'fraction_non_alphanumeric': 0.2218075179952013, 'fraction_numerical': 0.021327645961077047, 'mean_word_length': 1.8104868913857677, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 46, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 30, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3357778', 'n_tokens_mistral': 1032, 'n_tokens_neox': 951, 'n_words': 144}