void CreatureCore::SetGlobalEnablePointCache(bool flag_in) { auto cur_creature_manager = GetCreatureManager(); if (cur_creature_manager != nullptr) { cur_creature_manager->SetDoPointCache(flag_in); } }
void CreatureCore::ClearBluePrintPointCache(FString name_in, int32 approximation_level) { auto cur_creature_manager = GetCreatureManager(); if (!cur_creature_manager) { UE_LOG(LogTemp, Warning, TEXT("ACreatureActor::MakeBluePrintPointCache() - ERROR! Could not generate point cache for %s"), *name_in); return; } cur_creature_manager->ClearPointCache(ConvertToString(name_in)); }
void CreatureCore::MakeBluePrintPointCache(FString name_in, int32 approximation_level) { auto cur_creature_manager = GetCreatureManager(); if (!cur_creature_manager) { UE_LOG(LogTemp, Warning, TEXT("ACreatureActor::MakeBluePrintPointCache() - ERROR! Could not generate point cache for %s"), *name_in); return; } int32 real_approximation_level = approximation_level; if (real_approximation_level <= 0) { real_approximation_level = 1; } else if (real_approximation_level > 10) { real_approximation_level = 10; } cur_creature_manager->MakePointCache(ConvertToString(name_in), real_approximation_level); }
std::vector<meshBone *> CreatureCore::getAllChildrenWithIgnore(const std::string& ignore_name, meshBone * base_bone) { if (base_bone == nullptr) { base_bone = GetCreatureManager()->GetCreature()->GetRenderComposition()->getRootBone(); } std::vector<meshBone *> ret_data; if (base_bone->getKey() == ignore_name) { return ret_data; } ret_data.push_back(base_bone); for (auto cur_child : base_bone->getChildren()) { std::vector<meshBone *> append_data = getAllChildrenWithIgnore(ignore_name, cur_child); ret_data.insert(ret_data.end(), append_data.begin(), append_data.end()); } return ret_data; }
bool CreatureCore::GetGlobalEnablePointCache() { auto cur_creature_manager = GetCreatureManager(); return cur_creature_manager->GetDoPointCache(); }
void ACreatureCollectionActor::Tick(float DeltaTime) { Super::Tick(DeltaTime); // Call parent class tick function if (!should_play) { return; } if(AreAllActorsReady() == false) { return; } else { if (delay_set_clip_name.empty() == false) { SetBluePrintActiveClip(FString(delay_set_clip_name.c_str())); delay_set_clip_name = std::string(""); return; } } float true_delta_time = DeltaTime * animation_speed; // hide other actors in other clips for (auto& cur_collection_data : collection_clips) { if (cur_collection_data.first != active_clip_name) { HideAllActors(cur_collection_data.second, GetActiveActor()); } } // see if we need to hide everybody and return if (hide_all_actors) { for (auto& cur_collection_data : collection_clips) { HideAllActors(cur_collection_data.second, nullptr); } return; } // process active clip if (collection_clips.count(active_clip_name)) { auto& cur_collection = collection_clips[active_clip_name]; int& ref_index = cur_collection.ref_index; auto& cur_data = cur_collection.actor_sequence[ref_index]; auto cur_actor = cur_data.first; auto cur_manager = cur_actor->GetCreatureManager(); cur_manager->Update(true_delta_time); // update visiblity UpdateActorsVisibility(cur_collection); // check to see if we are at the end of the current actor animation auto& all_actor_animations = cur_manager->GetAllAnimations(); bool is_actor_animation_done = false; bool is_at_sequence_end = false; if (all_actor_animations.count(cur_data.second) > 0) { auto& actor_animation = all_actor_animations.at(cur_data.second); float cur_runtime = (cur_manager->getActualRunTime()); if (cur_runtime + true_delta_time >= actor_animation->getEndTime()) { is_actor_animation_done = true; if (ref_index + 1 < cur_collection.actor_sequence.size()) { // switch to new actor animation ref_index++; UpdateActorAnimationToStart(cur_collection); } else { is_at_sequence_end = true; CreatureAnimationEndEvent.Broadcast(cur_runtime); } } } if (is_at_sequence_end && is_looping) { ref_index = 0; UpdateActorAnimationToStart(cur_collection); } } }