Skip to content

Commit

Permalink
Handle empty garment processor params
Browse files Browse the repository at this point in the history
  • Loading branch information
psiberx committed Aug 19, 2023
1 parent 648393e commit c82b184
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lib/Red/Utils/Resources.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ inline void WaitForResource(const R& aResource, const W& aTimeout)
std::unique_lock lock(mutex);
std::condition_variable cv;

Red::JobQueue queue;
JobQueue queue;
queue.Wait(Trait::GetJobHandle(aResource));
queue.Dispatch([&lock, &cv]() {
lock.release();
Expand All @@ -92,7 +92,7 @@ inline void WaitForResources(const V<R, A...>& aResources, const W& aTimeout)
std::unique_lock lock(mutex);
std::condition_variable cv;

Red::JobQueue queue;
JobQueue queue;
for (const auto& resource : aResources)
{
queue.Wait(Trait::GetJobHandle(resource));
Expand Down
13 changes: 8 additions & 5 deletions src/App/Extensions/GarmentOverride/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,11 +450,14 @@ void App::GarmentOverrideModule::OnRegisterPart(uintptr_t, Red::Handle<Red::Enti
UpdatePartAssignments(aComponentStorage->components, aPart->path);
}

uintptr_t App::GarmentOverrideModule::OnProcessGarment(Red::SharedPtr<Red::GarmentProcessor>& aProcessor,
uintptr_t a2, uintptr_t a3, Red::Handle<Red::Entity>& aEntity)
uintptr_t App::GarmentOverrideModule::OnProcessGarment(Red::SharedPtr<Red::GarmentProcessor>& aProcessor, uintptr_t a2,
uintptr_t a3, Red::GarmentProcessorParams* aParams)
{
if (!aParams)
return Raw::GarmentAssembler::ProcessGarment(aProcessor, a2, a3, aParams);

std::unique_lock _(s_mutex);
if (auto& entityState = s_stateManager->FindEntityState(aEntity))
if (auto& entityState = s_stateManager->FindEntityState(aParams->entity))
{
#ifndef NDEBUG
LogDebug("|{}| [event=ProcessGarment entity={}]", ModuleName, entityState->GetName());
Expand All @@ -463,9 +466,9 @@ uintptr_t App::GarmentOverrideModule::OnProcessGarment(Red::SharedPtr<Red::Garme
UpdateDynamicAttributes(entityState);
}

auto result = Raw::GarmentAssembler::ProcessGarment(aProcessor, a2, a3, aEntity);
auto result = Raw::GarmentAssembler::ProcessGarment(aProcessor, a2, a3, aParams);

s_stateManager->LinkEntityToAssembler(aEntity, aProcessor);
s_stateManager->LinkEntityToAssembler(aParams->entity, aProcessor);

return result;
}
Expand Down
2 changes: 1 addition & 1 deletion src/App/Extensions/GarmentOverride/Module.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class GarmentOverrideModule : public ConfigurableUnitModule<GarmentOverrideUnit>
Red::Handle<Red::ComponentsStorage>& aComponents,
Red::Handle<Red::AppearanceDefinition>& aAppearance);
static uintptr_t OnProcessGarment(Red::SharedPtr<Red::GarmentProcessor>& aProcessor, uintptr_t a2, uintptr_t a3,
Red::Handle<Red::Entity>& aEntity);
Red::GarmentProcessorParams* aParams);
static void OnProcessGarmentMesh(Red::GarmentProcessor* aProcessor, uint32_t,
Red::Handle<Red::EntityTemplate>& aPartTemplate,
Red::SharedPtr<Red::ResourceToken<Red::CMesh>>& aMeshToken,
Expand Down
10 changes: 7 additions & 3 deletions src/Red/GarmentAssembler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ using AppearancePartOverrides = appearance::AppearancePartOverrides;

struct GarmentProcessor {};

struct GarmentProcessorParams
{
Handle<Entity> entity;
};

struct GarmentItemAddRequest
{
Handle<AppearanceDefinition> apperance; // 00
Expand Down Expand Up @@ -88,9 +93,8 @@ constexpr auto RemoveItem = Core::RawFunc<

constexpr auto ProcessGarment = Core::RawFunc<
/* addr = */ Red::Addresses::GarmentAssembler_ProcessGarment,
/* type = */ uintptr_t (*)(Red::SharedPtr<Red::GarmentProcessor>& aProcessor,
uintptr_t a2, uintptr_t a3,
Red::Handle<Red::Entity>& aEntity)>();
/* type = */ uintptr_t (*)(Red::SharedPtr<Red::GarmentProcessor>& aProcessor, uintptr_t a2, uintptr_t a3,
Red::GarmentProcessorParams* aParams)>();

constexpr auto ProcessSkinnedMesh = Core::RawFunc<
/* addr = */ Red::Addresses::GarmentAssembler_ProcessSkinnedMesh,
Expand Down

0 comments on commit c82b184

Please sign in to comment.