Skip to content

Commit

Permalink
Added vector division
Browse files Browse the repository at this point in the history
  • Loading branch information
Raikiri committed Oct 21, 2024
1 parent 9a49872 commit 0586bf1
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions LegitScript/source/RenderGraphScript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,28 @@ void RenderGraphScript::Impl::RegisterVecType(std::string type_name, std::string
}
gen->SetReturnObject(&res);
});
as_script_engine->RegisterMethod(type_name.c_str(), (type_name + " " + "opDiv(" + type_name + ") const").c_str(), [=](asIScriptGeneric *gen)
{
auto *this_ptr = (VecType*)gen->GetObject();
auto *other_ptr = (VecType*)gen->GetArgObject(0);
VecType res;
for(size_t i = 0; i < CompCount; i++)
{
SetComp(res, i, GetComp<VecType, CompType>(*this_ptr, i) / GetComp<VecType, CompType>(*other_ptr, i));
}
gen->SetReturnObject(&res);
});
as_script_engine->RegisterMethod(type_name.c_str(), (type_name + " " + "opDiv(" + comp_type_name + ") const").c_str(), [=](asIScriptGeneric *gen)
{
auto *this_ptr = (VecType*)gen->GetObject();
auto other = GetArg<CompType>(gen, 0);
VecType res;
for(size_t i = 0; i < CompCount; i++)
{
SetComp(res, i, GetComp<VecType, CompType>(*this_ptr, i) / other);
}
gen->SetReturnObject(&res);
});

as_script_engine->RegisterGlobalFunction(std::string("string to_string(") + type_name + " v)", [](asIScriptGeneric *gen)
{
Expand Down

0 comments on commit 0586bf1

Please sign in to comment.