<commit_before>#include "renderer/pose.h"
#include "engine/math.h"
#include "engine/profiler.h"
#include "engine/math.h"
#include "renderer/model.h"


namespace Lumix
{


Pose::Pose(IAllocator& allocator)
	: allocator(allocator)
{
	positions = nullptr;
	rotations = nullptr;
	count = 0;
	is_absolute = false;
}


Pose::~Pose()
{
	allocator.deallocate(positions);
	allocator.deallocate(rotations);
}


void Pose::blend(Pose& rhs, float weight)
{
	ASSERT(count == rhs.count);
	if (weight <= 0.001f) return;
	weight = clamp(weight, 0.0f, 1.0f);
	float inv = 1.0f - weight;
	for (int i = 0, c = count; i < c; ++i)
	{
		positions[i] = positions[i] * inv + rhs.positions[i] * weight;
		rotations[i] = nlerp(rotations[i], rhs.rotations[i], weight);
	}
}


void Pose::resize(int count)
{
	is_absolute = false;
	allocator.deallocate(positions);
	allocator.deallocate(rotations);
	this->count = count;
	if (count)
	{
		positions = static_cast<Vec3*>(allocator.allocate(sizeof(Vec3) * count));
		rotations = static_cast<Quat*>(allocator.allocate(sizeof(Quat) * count));
	}
	else
	{
		positions = nullptr;
		rotations = nullptr;
	}
}


void Pose::computeAbsolute(Model& model)
{
	if (is_absolute) return;
	for (u32 i = model.getFirstNonrootBoneIndex(); i < count; ++i)
	{
		int parent = model.getBone(i).parent_idx;
		positions[i] = rotations[parent].rotate(positions[i]) + positions[parent];
		rotations[i] = rotations[parent] * rotations[i];
	}
	is_absolute = true;
}


void Pose::computeRelative(Model& model)
{
	if (!is_absolute) return;
	for (int i = count - 1; i >= model.getFirstNonrootBoneIndex(); --i)
	{
		int parent = model.getBone(i).parent_idx;
		positions[i] = -rotations[parent].conjugated().rotate(positions[i] - positions[parent]);
		rotations[i] = rotations[parent].conjugated() * rotations[i];
	}
	is_absolute = false;
}


} // namespace Lumix
<commit_msg>forgotten minus<commit_after>#include "renderer/pose.h"
#include "engine/math.h"
#include "engine/profiler.h"
#include "engine/math.h"
#include "renderer/model.h"


namespace Lumix
{


Pose::Pose(IAllocator& allocator)
	: allocator(allocator)
{
	positions = nullptr;
	rotations = nullptr;
	count = 0;
	is_absolute = false;
}


Pose::~Pose()
{
	allocator.deallocate(positions);
	allocator.deallocate(rotations);
}


void Pose::blend(Pose& rhs, float weight)
{
	ASSERT(count == rhs.count);
	if (weight <= 0.001f) return;
	weight = clamp(weight, 0.0f, 1.0f);
	float inv = 1.0f - weight;
	for (int i = 0, c = count; i < c; ++i)
	{
		positions[i] = positions[i] * inv + rhs.positions[i] * weight;
		rotations[i] = nlerp(rotations[i], rhs.rotations[i], weight);
	}
}


void Pose::resize(int count)
{
	is_absolute = false;
	allocator.deallocate(positions);
	allocator.deallocate(rotations);
	this->count = count;
	if (count)
	{
		positions = static_cast<Vec3*>(allocator.allocate(sizeof(Vec3) * count));
		rotations = static_cast<Quat*>(allocator.allocate(sizeof(Quat) * count));
	}
	else
	{
		positions = nullptr;
		rotations = nullptr;
	}
}


void Pose::computeAbsolute(Model& model)
{
	if (is_absolute) return;
	for (u32 i = model.getFirstNonrootBoneIndex(); i < count; ++i)
	{
		int parent = model.getBone(i).parent_idx;
		positions[i] = rotations[parent].rotate(positions[i]) + positions[parent];
		rotations[i] = rotations[parent] * rotations[i];
	}
	is_absolute = true;
}


void Pose::computeRelative(Model& model)
{
	if (!is_absolute) return;
	for (int i = count - 1; i >= model.getFirstNonrootBoneIndex(); --i)
	{
		int parent = model.getBone(i).parent_idx;
		positions[i] = rotations[parent].conjugated().rotate(positions[i] - positions[parent]);
		rotations[i] = rotations[parent].conjugated() * rotations[i];
	}
	is_absolute = false;
}


} // namespace Lumix

{'fraction_non_alphanumeric': 0.1650120740541991, 'fraction_numerical': 0.009122618728199625, 'mean_word_length': 4.81591263650546, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5772538', 'n_tokens_mistral': 1518, 'n_tokens_neox': 1401, 'n_words': 273}