fix environment texture drag to viewport didn't create SkylightComponent; fix PhysicsWrappers::CreateConvexMesh collier worng scale;some tweaks
This commit is contained in:
@ -606,28 +606,39 @@ namespace Prism
|
||||
|
||||
if (ImGui::BeginDragDropTarget())
|
||||
{
|
||||
auto payload = ImGui::AcceptDragDropPayload("asset_payload");
|
||||
if (payload)
|
||||
if (auto payload = ImGui::AcceptDragDropPayload("asset_payload"))
|
||||
{
|
||||
int count = payload->DataSize / sizeof(AssetHandle);
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
AssetHandle assetHandle = *(((AssetHandle*)payload->Data) + i);
|
||||
AssetHandle assetHandle = *(static_cast<AssetHandle*>(payload->Data) + i);
|
||||
Ref<Asset> asset = AssetsManager::GetAsset<Asset>(assetHandle);
|
||||
|
||||
// We can't really support dragging and dropping scenes when we're dropping multiple assets
|
||||
if (count == 1 && asset->Type == AssetType::Scene)
|
||||
{
|
||||
OpenScene(asset->FilePath);
|
||||
break;
|
||||
}
|
||||
|
||||
if (asset->Type == AssetType::Mesh)
|
||||
switch (asset->Type)
|
||||
{
|
||||
case AssetType::Mesh:
|
||||
{
|
||||
Entity entity = m_EditorScene->CreateEntity(asset->FileName);
|
||||
entity.AddComponent<MeshComponent>(Ref<Mesh>(asset));
|
||||
SelectEntity(entity);
|
||||
break;
|
||||
}
|
||||
case AssetType::EnvMap:
|
||||
{
|
||||
Entity entity = m_EditorScene->CreateEntity(asset->FileName);
|
||||
entity.AddComponent<SkyLightComponent>(Ref<Environment>(asset));
|
||||
SelectEntity(entity);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
ImGui::EndDragDropTarget();
|
||||
|
||||
@ -145,7 +145,7 @@ namespace Prism
|
||||
if (!asset->Extension.empty())
|
||||
metaFileName += "." + asset->Extension;
|
||||
|
||||
FileSystem::Rename(oldFilePath + ".meta", metaFileName);
|
||||
FileSystem::PrismDeleteFile(oldFilePath + ".meta");
|
||||
AssetSerializer::CreateMetaFile(asset);
|
||||
}
|
||||
}
|
||||
@ -204,6 +204,7 @@ namespace Prism
|
||||
s_LoadedAssets[asset->Handle] = asset;
|
||||
|
||||
AssetSerializer::SerializeAsset(asset);
|
||||
AssetSerializer::CreateMetaFile(asset);
|
||||
|
||||
return asset;
|
||||
}
|
||||
@ -255,6 +256,7 @@ namespace Prism
|
||||
s_LoadedAssets[asset->Handle] = asset;
|
||||
|
||||
AssetSerializer::SerializeAsset(asset);
|
||||
AssetSerializer::CreateMetaFile(asset);
|
||||
|
||||
return asset;
|
||||
}
|
||||
@ -308,7 +310,6 @@ namespace Prism
|
||||
|
||||
const AssetType type = AssetTypes::GetAssetTypeFromExtension(extension);
|
||||
Ref<Asset> asset = AssetSerializer::LoadAssetInfo(filepath, parentHandle, type);
|
||||
|
||||
if (s_LoadedAssets.find(asset->Handle) != s_LoadedAssets.end())
|
||||
{
|
||||
if (s_LoadedAssets[asset->Handle]->IsDataLoaded)
|
||||
|
||||
@ -2,14 +2,12 @@
|
||||
// Created by sfd on 25-11-15.
|
||||
//
|
||||
|
||||
#include "pmpch.h"
|
||||
#include "Log.h"
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
#include "spdlog/sinks/basic_file_sink.h"
|
||||
#include "spdlog/sinks/stdout_color_sinks-inl.h"
|
||||
#include "spdlog/sinks/stdout_sinks.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define LOG_LEVEL spdlog::level::trace
|
||||
@ -30,29 +28,23 @@ namespace Prism
|
||||
|
||||
std::vector<spdlog::sink_ptr> prismSinks =
|
||||
{
|
||||
std::make_shared<spdlog::sinks::stdout_sink_mt>(),
|
||||
std::make_shared<spdlog::sinks::stdout_color_sink_mt>(),
|
||||
std::make_shared<spdlog::sinks::basic_file_sink_mt>("logs/PRISM.log", true)
|
||||
};
|
||||
|
||||
std::vector<spdlog::sink_ptr> appSinks =
|
||||
{
|
||||
std::make_shared<spdlog::sinks::stdout_sink_mt>(),
|
||||
std::make_shared<spdlog::sinks::stdout_color_sink_mt>(),
|
||||
std::make_shared<spdlog::sinks::basic_file_sink_mt>("logs/APP.log", true)
|
||||
};
|
||||
|
||||
s_CoreLogger = std::make_shared<spdlog::logger>("PRISM", prismSinks.begin(), prismSinks.end());
|
||||
s_CoreLogger->set_level(LOG_LEVEL);
|
||||
s_CoreLogger->set_pattern("%^[%Y-%m-%d %H:%M:%S.%e] [%l] %v%$");
|
||||
|
||||
s_ClientLogger = std::make_shared<spdlog::logger>("APP", appSinks.begin(), appSinks.end());
|
||||
s_ClientLogger->set_level(LOG_LEVEL);
|
||||
/*
|
||||
spdlog::set_pattern("%^[%T] [%n]%v%$");
|
||||
s_CoreLogger = spdlog::stdout_color_mt("PRISM");
|
||||
s_CoreLogger->set_level(LOG_LEVEL);
|
||||
|
||||
s_ClientLogger = spdlog::stdout_color_mt("APP");
|
||||
s_ClientLogger->set_level(LOG_LEVEL);
|
||||
*/
|
||||
s_CoreLogger->set_pattern("%^[%Y-%m-%d %H:%M:%S.%e] [%l] %v%$");
|
||||
}
|
||||
|
||||
void Log::Shutdown()
|
||||
|
||||
@ -26,18 +26,18 @@ namespace Prism
|
||||
}
|
||||
|
||||
|
||||
#define PM_CORE_TRACE(...) ::Prism::Log::GetCoreLogger()->trace("[TRACE]: " __VA_ARGS__)
|
||||
#define PM_CORE_DEBUG(...) ::Prism::Log::GetCoreLogger()->debug("[DEBUG]: " __VA_ARGS__)
|
||||
#define PM_CORE_INFO(...) ::Prism::Log::GetCoreLogger()->info("[INFO]: " __VA_ARGS__)
|
||||
#define PM_CORE_WARN(...) ::Prism::Log::GetCoreLogger()->warn("[WARN]: " __VA_ARGS__)
|
||||
#define PM_CORE_ERROR(...) ::Prism::Log::GetCoreLogger()->error("[ERROR]: " __VA_ARGS__)
|
||||
#define PM_CORE_FATAL(...) ::Prism::Log::GetCoreLogger()->critical("[FATAL]: " __VA_ARGS__)
|
||||
#define PM_CORE_TRACE(...) ::Prism::Log::GetCoreLogger()->trace(__VA_ARGS__)
|
||||
#define PM_CORE_DEBUG(...) ::Prism::Log::GetCoreLogger()->debug( __VA_ARGS__)
|
||||
#define PM_CORE_INFO(...) ::Prism::Log::GetCoreLogger()->info(__VA_ARGS__)
|
||||
#define PM_CORE_WARN(...) ::Prism::Log::GetCoreLogger()->warn(__VA_ARGS__)
|
||||
#define PM_CORE_ERROR(...) ::Prism::Log::GetCoreLogger()->error(__VA_ARGS__)
|
||||
#define PM_CORE_FATAL(...) ::Prism::Log::GetCoreLogger()->critical(__VA_ARGS__)
|
||||
|
||||
#define PM_CLIENT_TRACE(...) ::Prism::Log::GetClientLogger()->trace("[TRACE]: " __VA_ARGS__)
|
||||
#define PM_CLIENT_DEBUG(...) ::Prism::Log::GetClientLogger()->debug("[DEBUG]: " __VA_ARGS__)
|
||||
#define PM_CLIENT_INFO(...) ::Prism::Log::GetClientLogger()->info("[INFO]: " __VA_ARGS__)
|
||||
#define PM_CLIENT_WARN(...) ::Prism::Log::GetClientLogger()->warn("[WARN]: " __VA_ARGS__)
|
||||
#define PM_CLIENT_ERROR(...) ::Prism::Log::GetClientLogger()->error("[ERROR]: " __VA_ARGS__)
|
||||
#define PM_CLIENT_FATAL(...) ::Prism::Log::GetClientLogger()->critical("[FATAL]: " __VA_ARGS__)
|
||||
#define PM_CLIENT_TRACE(...) ::Prism::Log::GetClientLogger()->trace(__VA_ARGS__)
|
||||
#define PM_CLIENT_DEBUG(...) ::Prism::Log::GetClientLogger()->debug(__VA_ARGS__)
|
||||
#define PM_CLIENT_INFO(...) ::Prism::Log::GetClientLogger()->info(__VA_ARGS__)
|
||||
#define PM_CLIENT_WARN(...) ::Prism::Log::GetClientLogger()->warn(__VA_ARGS__)
|
||||
#define PM_CLIENT_ERROR(...) ::Prism::Log::GetClientLogger()->error(__VA_ARGS__)
|
||||
#define PM_CLIENT_FATAL(...) ::Prism::Log::GetClientLogger()->critical(__VA_ARGS__)
|
||||
|
||||
#endif //LOG_H
|
||||
|
||||
@ -9,8 +9,6 @@
|
||||
#include <cstdint>
|
||||
#include <type_traits>
|
||||
|
||||
#include "Log.h"
|
||||
|
||||
namespace Prism
|
||||
{
|
||||
class PRISM_API RefCounted
|
||||
@ -143,9 +141,6 @@ namespace Prism
|
||||
if (m_Instance)
|
||||
{
|
||||
m_Instance->IncRefCount();
|
||||
// PM_CORE_DEBUG("{");
|
||||
// PM_CORE_DEBUG("{0}:{1}: +{2}",(uint64_t)(&m_Instance), typeid(*m_Instance).name(), m_Instance->GetRefCount());
|
||||
// if (m_Instance->GetRefCount() >= 1000) PM_CORE_ASSERT(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -154,11 +149,8 @@ namespace Prism
|
||||
if (m_Instance)
|
||||
{
|
||||
m_Instance->DecRefCount();
|
||||
// PM_CORE_DEBUG("{0}:{1}: -{2}",(uint64_t)(&m_Instance), typeid(*m_Instance).name(), m_Instance->GetRefCount());
|
||||
// PM_CORE_DEBUG("}");
|
||||
if (m_Instance->GetRefCount() == 0)
|
||||
{
|
||||
// PM_CORE_DEBUG("{0}:{1}: delete",(uint64_t)(&m_Instance), typeid(*m_Instance).name());
|
||||
delete m_Instance;
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,7 +24,7 @@ namespace Prism
|
||||
|
||||
m_FocalPoint = glm::vec3(0.0f);
|
||||
|
||||
glm::vec3 position = { -5, 5, 5};
|
||||
constexpr glm::vec3 position = { -5, 5, 5};
|
||||
m_Distance = glm::distance(position, m_FocalPoint);
|
||||
|
||||
m_Yaw = 3.0f * (float)M_PI / 4.0f;
|
||||
@ -57,7 +57,6 @@ namespace Prism
|
||||
m_InitialMousePosition = { Input::GetMouseX(), Input::GetMouseY() };
|
||||
m_IsRightButtonDownState = true;
|
||||
m_FreeLookActive = true;
|
||||
m_FreeLookPosition = m_Position;
|
||||
m_Velocity = glm::vec3(0.0f);
|
||||
}
|
||||
|
||||
@ -88,11 +87,11 @@ namespace Prism
|
||||
|
||||
// m_Velocity *= (1.0f - m_Damping * deltaTime);
|
||||
|
||||
m_FreeLookPosition += m_Velocity * deltaTime.GetSeconds();
|
||||
m_Position += m_Velocity * deltaTime.GetSeconds();
|
||||
// ---------------------------------
|
||||
|
||||
glm::quat orientation = GetOrientation();
|
||||
m_ViewMatrix = glm::translate(glm::mat4(1.0f), m_FreeLookPosition) * glm::toMat4(orientation);
|
||||
m_ViewMatrix = glm::translate(glm::mat4(1.0f), m_Position) * glm::toMat4(orientation);
|
||||
m_ViewMatrix = glm::inverse(m_ViewMatrix);
|
||||
m_Rotation = glm::eulerAngles(orientation) * (180.0f / (float)M_PI);
|
||||
return;
|
||||
@ -105,7 +104,6 @@ namespace Prism
|
||||
m_IsRightButtonDownState = false;
|
||||
if (m_FreeLookActive)
|
||||
{
|
||||
m_Position = m_FreeLookPosition;
|
||||
m_FocalPoint = m_Position + GetForwardDirection() * m_Distance;
|
||||
m_FreeLookActive = false;
|
||||
}
|
||||
|
||||
@ -84,7 +84,6 @@ namespace Prism
|
||||
|
||||
bool m_IsAltKeyDownState = false;
|
||||
bool m_FreeLookActive;
|
||||
glm::vec3 m_FreeLookPosition;
|
||||
|
||||
glm::vec3 m_Velocity = glm::vec3(0.0f); // 当前速度
|
||||
float m_MaxSpeed = 20.0f; // 最大移动速度(单位/秒)
|
||||
|
||||
@ -449,11 +449,17 @@ namespace Prism
|
||||
continue;
|
||||
}
|
||||
|
||||
auto convexGeometry = physx::PxConvexMeshGeometry(convexMesh, physx::PxMeshScale(ToPhysXVector(scale)));
|
||||
|
||||
|
||||
glm::vec3 submeshTranslation, submeshRotation, submeshScale;
|
||||
Math::DecomposeTransform(submesh.Transform, submeshTranslation, submeshRotation, submeshScale);
|
||||
|
||||
auto convexGeometry = physx::PxConvexMeshGeometry( convexMesh, physx::PxMeshScale(ToPhysXVector(submeshScale * scale)) );
|
||||
convexGeometry.meshFlags = physx::PxConvexMeshGeometryFlag::eTIGHT_BOUNDS;
|
||||
|
||||
physx::PxMaterial* material = s_Physics->createMaterial(0, 0, 0); // Dummy material, will be replaced at runtime.
|
||||
physx::PxShape* shape = s_Physics->createShape(convexGeometry, *material, true);
|
||||
shape->setLocalPose(ToPhysXTransform(submesh.Transform));
|
||||
shape->setLocalPose(ToPhysXTransform(submeshTranslation, submeshRotation));
|
||||
|
||||
shapes.push_back(shape);
|
||||
|
||||
@ -499,7 +505,9 @@ namespace Prism
|
||||
}
|
||||
}
|
||||
|
||||
collider.ProcessedMeshes.push_back(Ref<Mesh>::Create(collisionVertices, collisionIndices, FromPhysXTransform(shape->getLocalPose())));
|
||||
glm::mat4 scale_mat = glm::scale(glm::mat4(1.0f), *(glm::vec3*)&convexGeometry.scale.scale);
|
||||
glm::mat4 transform = FromPhysXTransform(shape->getLocalPose()) * scale_mat;
|
||||
collider.ProcessedMeshes.push_back(Ref<Mesh>::Create(collisionVertices, collisionIndices, transform));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -50,7 +50,7 @@ namespace Prism
|
||||
|
||||
float CurrentExposure = 1.0f;
|
||||
bool EnableAutoExposure = true;
|
||||
float Key = 0.18f; // middle gray
|
||||
float Key = 0.11f; // middle gray
|
||||
float AdaptationSpeed = 5.0f; // stops per second
|
||||
|
||||
Timer ExposureTimer;
|
||||
|
||||
@ -284,6 +284,10 @@ namespace Prism
|
||||
float Intensity = 1.0f;
|
||||
float Angle = 0.0f;
|
||||
|
||||
SkyLightComponent(const Ref<Environment>& environment)
|
||||
: SceneEnvironment(environment)
|
||||
{
|
||||
}
|
||||
SkyLightComponent()
|
||||
: SceneEnvironment(Ref<Environment>::Create())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user