Now renders func brush materials correclty
This commit is contained in:
@@ -400,23 +400,15 @@ namespace Nuake
|
||||
bodySettings.mMassPropertiesOverride.mMass = mass;
|
||||
}
|
||||
|
||||
if (rb->GetEntity().GetID() == 0)
|
||||
if (int entityId = rb->GetEntity().GetHandle(); rb->GetEntity().IsValid())
|
||||
{
|
||||
Logger::Log("Entity with ID 0 detected. Name: " + rb->GetEntity().GetComponent<NameComponent>().Name, "DEBUG");
|
||||
bodySettings.mUserData = rb->GetEntity().GetHandle();
|
||||
|
||||
// Create the actual rigid body
|
||||
JPH::BodyID body = _JoltBodyInterface->CreateAndAddBody(bodySettings, JPH::EActivation::Activate); // Note that if we run out of bodies this can return nullptr
|
||||
uint32_t bodyIndex = (uint32_t)body.GetIndexAndSequenceNumber();
|
||||
_registeredBodies.push_back(bodyIndex);
|
||||
}
|
||||
|
||||
int entityId = rb->GetEntity().GetHandle();
|
||||
|
||||
if (entityId == 0)
|
||||
{
|
||||
Logger::Log("ERROR");
|
||||
}
|
||||
|
||||
bodySettings.mUserData = entityId;
|
||||
// Create the actual rigid body
|
||||
JPH::BodyID body = _JoltBodyInterface->CreateAndAddBody(bodySettings, JPH::EActivation::Activate); // Note that if we run out of bodies this can return nullptr
|
||||
uint32_t bodyIndex = (uint32_t)body.GetIndexAndSequenceNumber();
|
||||
_registeredBodies.push_back(bodyIndex);
|
||||
}
|
||||
|
||||
void DynamicWorld::AddGhostbody(Ref<GhostObject> gb)
|
||||
@@ -501,7 +493,9 @@ namespace Nuake
|
||||
if (newPosition != currentPosition || currentRotation != newRotation)
|
||||
{
|
||||
std::string name = entity.GetComponent<NameComponent>().Name;
|
||||
|
||||
_JoltBodyInterface->SetPositionAndRotation(bodyId, newPosition, newRotation, JPH::EActivation::DontActivate);
|
||||
//_JoltBodyInterface->MoveKinematic(bodyId, newPosition, newRotation, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,8 +169,11 @@ namespace Nuake {
|
||||
exposedVar.DefaultValue = (bool)exposedVarJson["DefaultValue"];
|
||||
break;
|
||||
case NetScriptExposedVarType::Float:
|
||||
exposedVar.Value = (float)exposedVarJson["Value"];
|
||||
exposedVar.DefaultValue = (float)exposedVarJson["DefaultValue"];
|
||||
if (exposedVarJson.contains("Value"))
|
||||
{
|
||||
exposedVar.Value = (float)exposedVarJson["Value"];
|
||||
}
|
||||
exposedVar.DefaultValue = 0.0f;
|
||||
break;
|
||||
case NetScriptExposedVarType::Double:
|
||||
exposedVar.Value = (double)exposedVarJson["Value"];
|
||||
@@ -183,8 +186,8 @@ namespace Nuake {
|
||||
break;
|
||||
}
|
||||
case NetScriptExposedVarType::String:
|
||||
exposedVar.Value = (std::string)exposedVarJson["Value"];
|
||||
exposedVar.DefaultValue = (std::string)exposedVarJson["DefaultValue"];
|
||||
//exposedVar.Value = (std::string)exposedVarJson["Value"];
|
||||
//exposedVar.DefaultValue = (std::string)exposedVarJson["DefaultValue"];
|
||||
break;
|
||||
case NetScriptExposedVarType::Vector2:
|
||||
{
|
||||
|
||||
@@ -131,6 +131,7 @@ namespace Nuake
|
||||
const Quat& startRotation = transformComponent.GetGlobalRotation();
|
||||
const auto collisionShape = CreateRef<Physics::ConvexHullShape>(hull);
|
||||
|
||||
|
||||
auto rigidBody = CreateRef<Physics::RigidBody>(0.0f, startPosition, startRotation, startTransform, collisionShape, entity);
|
||||
brushComponent.Rigidbody.push_back(rigidBody);
|
||||
rigidBody->SetIsTrigger(brushComponent.IsTrigger);
|
||||
@@ -321,6 +322,7 @@ namespace Nuake
|
||||
}
|
||||
|
||||
Ref<Physics::PhysicShape> shape;
|
||||
bool hasValidShape = true;
|
||||
if (entity.HasComponent<CapsuleColliderComponent>())
|
||||
{
|
||||
const auto& capsuleColliderComponent = entity.GetComponent<CapsuleColliderComponent>();
|
||||
@@ -343,7 +345,9 @@ namespace Nuake
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
hasValidShape = false;
|
||||
Logger::Log("No shape was provided for character controller. Default one was provided.", "physics", WARNING);
|
||||
shape = CreateRef<Physics::Capsule>(1.0f, 0.5f);
|
||||
}
|
||||
|
||||
Physics::CharacterControllerSettings settings
|
||||
|
||||
@@ -244,6 +244,8 @@ namespace Nuake {
|
||||
TransformComponent& transformComponent = brushEntity.GetComponent<TransformComponent>();
|
||||
BSPBrushComponent& bsp = brushEntity.AddComponent<BSPBrushComponent>();
|
||||
|
||||
std::map<std::string, Ref<Material>> m_Materials;
|
||||
|
||||
bsp.IsSolid = !fgdBrush.IsTrigger;
|
||||
bsp.IsTransparent = !fgdBrush.Visible;
|
||||
bsp.IsFunc = true;
|
||||
@@ -298,6 +300,37 @@ namespace Nuake {
|
||||
texture->width = tex->GetWidth();
|
||||
}
|
||||
|
||||
Ref<Material> currentMaterial;
|
||||
if (std::string(texture->name) != "__TB_empty")
|
||||
{
|
||||
std::string path = FileSystem::Root + "Textures/" + std::string(texture->name) + ".png";
|
||||
|
||||
if (const std::string materialPath = "Materials/" + std::string(texture->name) + ".material";
|
||||
FileSystem::FileExists(materialPath))
|
||||
{
|
||||
Ref<Material> material = ResourceLoader::LoadMaterial(materialPath);
|
||||
m_Materials[path] = material;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_Materials.find(path) == m_Materials.end())
|
||||
{
|
||||
m_Materials[path] = MaterialManager::Get()->GetMaterial(path);
|
||||
}
|
||||
}
|
||||
|
||||
currentMaterial = m_Materials[path];
|
||||
texture->height = currentMaterial->m_Albedo->GetHeight();
|
||||
texture->width = currentMaterial->m_Albedo->GetWidth();
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
|
||||
currentMaterial = MaterialManager::Get()->GetMaterial("resources/Textures/default/Default.png");
|
||||
texture->height = texture->width = 1;
|
||||
}
|
||||
|
||||
face_geometry* face_geo_inst = &brush_inst->faces[f];
|
||||
|
||||
for (int i = 0; i < face_geo_inst->vertex_count; ++i)
|
||||
@@ -344,8 +377,7 @@ namespace Nuake {
|
||||
|
||||
if (std::string(texture->name) != "__TB_empty")
|
||||
{
|
||||
Ref<Material> material = MaterialManager::Get()->GetMaterial(lastTexturePath);
|
||||
mesh->SetMaterial(material);
|
||||
mesh->SetMaterial(currentMaterial);
|
||||
}
|
||||
|
||||
bsp.Meshes.push_back(mesh);
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace Nuake {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (static_cast<ComponentTypes>(componentEnumValue))
|
||||
switch (static_cast<ComponentTypes>(componentType))
|
||||
{
|
||||
case PARENT: return entity.HasComponent<ParentComponent>();
|
||||
case NAME: return entity.HasComponent<NameComponent>();
|
||||
|
||||
@@ -280,7 +280,7 @@ namespace Nuake
|
||||
{
|
||||
if (!m_IsInitialized)
|
||||
{
|
||||
Initialize();
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string sanitizedProjectName = String::Sanitize(project->Name);
|
||||
@@ -522,6 +522,11 @@ namespace Nuake
|
||||
// Override with user values set in the editor.
|
||||
for (auto& exposedVarUserValue : component.ExposedVar)
|
||||
{
|
||||
if (!exposedVarUserValue.Value.has_value())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (exposedVarUserValue.Type == NetScriptExposedVarType::String)
|
||||
{
|
||||
std::string stringValue = std::any_cast<std::string>(exposedVarUserValue.Value);
|
||||
|
||||
@@ -201,7 +201,7 @@ namespace Nuake.Net
|
||||
return (T?)Activator.CreateInstance(typeof(T), ECSHandle);
|
||||
}
|
||||
|
||||
return null;
|
||||
throw new Exception("Component not found: " + typeof(T).GetType().Name);
|
||||
}
|
||||
|
||||
public T? GetEntity<T>(string path) where T : Entity
|
||||
|
||||
@@ -49,6 +49,19 @@ namespace Nuake.Net
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public sealed class PointScript : Attribute
|
||||
{
|
||||
public string Description = "";
|
||||
public bool IsTrigger = false;
|
||||
|
||||
public PointScript(string description = "")
|
||||
{
|
||||
Description = description;
|
||||
IsTrigger = isTrigger;
|
||||
}
|
||||
}
|
||||
|
||||
public class Debug
|
||||
{
|
||||
internal static unsafe delegate*</* start */ float, float, float,
|
||||
|
||||
Reference in New Issue
Block a user