Skip to content

Commit

Permalink
Script replacement works well!
Browse files Browse the repository at this point in the history
  • Loading branch information
DronCode committed Apr 28, 2024
1 parent 95c8165 commit 9a8efa6
Show file tree
Hide file tree
Showing 24 changed files with 833 additions and 291 deletions.
27 changes: 26 additions & 1 deletion BMEdit/Editor/Include/Models/SceneObjectControllerModel.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
#pragma once

#include <QColor>
#include <Models/ValueModelBase.h>
#include <GameLib/Scene/SceneObject.h>
#include <Types/QGlacierController.h>
#include <vector>


namespace models
{
class SceneObjectControllerModel : public ValueModelBase
{
Q_OBJECT

private:
struct SpecialRow
{
int startRow { 0 };
int endRow { 0 };
QColor backgroundColor {};

bool includes(int row) const
{
return row >= startRow && row <= endRow;
}
};

public:
SceneObjectControllerModel(QObject *parent = nullptr);

Expand All @@ -18,11 +34,20 @@ namespace models
void setControllerIndex(int controllerIndex);
void resetController();

QVariant data(const QModelIndex &index, int role) const override;

private:
void addSugarViews(const gamelib::Type* pControllerType, gamelib::Value& v, const std::string& scriptName);
void removeSugarViews(const gamelib::Type* pControllerType, gamelib::Value& v);

private slots:
void onValueChanged();

private:
static constexpr int kUnset = -1;

gamelib::scene::SceneObject *m_geom { nullptr };
int m_currentControllerIndex = -1;
int m_currentControllerIndex = kUnset;
std::vector<SpecialRow> m_specialRows {};
};
}
49 changes: 38 additions & 11 deletions BMEdit/Editor/Include/Widgets/SceneRenderWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,29 @@ namespace widgets
float fFrameTime { .0f }; // how much time used for render this frame
};

struct RayCastObjectDescription
enum class EObjectPriority
{
enum EPriority {
EP_STATIC_OBJECT = 0,
EP_DYNAMIC_OBJECT = 1
};
EP_STATIC_OBJECT = 0,
EP_DYNAMIC_OBJECT = 1
};

EPriority ePrio { EPriority::EP_STATIC_OBJECT };
struct RayCastObjectDescription
{
EObjectPriority ePrio { EObjectPriority::EP_STATIC_OBJECT };
float fRayOriginDistance { .0f };
gamelib::scene::SceneObject::Ptr pObject { nullptr };

// Operators
bool operator<(const RayCastObjectDescription& another) const;
};

struct SeebleObject
{
EObjectPriority ePrio { EObjectPriority::EP_STATIC_OBJECT };
gamelib::BoundingBox sBoundingBox {};
gamelib::scene::SceneObject::Ptr pObject {};
};

class SceneRenderWidget : public QOpenGLWidget
{
Q_OBJECT
Expand Down Expand Up @@ -101,8 +109,6 @@ namespace widgets
bool shouldRenderRoomBoundingBox() const;
void setShouldRenderRoomBoundingBox(bool bVal);

bool isGameObjectInActiveRoom(const gamelib::scene::SceneObject::Ptr& pObject) const;

int32_t getGameObjectPrimitiveId(const gamelib::scene::SceneObject::Ptr& pObject) const;
int32_t getGameObjectPrimitiveId(const gamelib::scene::SceneObject* pObject) const;

Expand Down Expand Up @@ -146,13 +152,12 @@ namespace widgets
[[nodiscard]] glm::ivec2 getViewportSize() const;

void collectRenderList(const render::Camera& camera, const gamelib::scene::SceneObject* pRootGeom, render::RenderEntriesList& entries, RenderStats& stats, bool bIgnoreVisibility);
void collectRenderEntriesIntoRenderList(const gamelib::scene::SceneObject* pRootGeom, render::RenderEntriesList& entries, RenderStats& stats, bool bIgnoreVisibility);
void collectRenderEntriesIntoRenderList(const gamelib::scene::SceneObject* pRootGeom, render::RenderEntriesList& entries, RenderStats& stats, bool bIgnoreVisibility, bool bBreakOnChild = false);
void performRender(QOpenGLFunctions_3_3_Core* glFunctions, const render::RenderEntriesList& entries, const render::Camera& camera, const std::function<bool(const render::RenderEntry&)>& filter);

void invalidateRenderList();

void buildRoomCache(QOpenGLFunctions_3_3_Core* glFunctions);
void resetLastRoom();

/**
* @brief Method trying to find a new room for current camera (if camera not in that room of bRejectLastResult is true)
Expand Down Expand Up @@ -211,6 +216,13 @@ namespace widgets
eBOTH = 3,
};

enum class EBoundingBoxSource : int {
BBS_ROOM_COLLISION_MESH, ///< Calculated via collision mesh
BBS_ZBOUNDS_AUTO_EXPAND, ///< Calculated by ZBOUND object points
BBS_AUTO_ROOM_EXPAND, ///< Calculated as expand of all objects in room
BBS_NONE ///< Not calculated or other BoundingBox source (auto-gen as example)
};

/**
* @brief Weak pointer to entity which represent room
*/
Expand All @@ -226,6 +238,11 @@ namespace widgets
*/
ELocation eLocation { ELocation::eUNDEFINED };

/**
* @brief How bounding box calculated
*/
EBoundingBoxSource eBoundingBoxSource { EBoundingBoxSource::BBS_NONE };

/**
* @brief Information about room exits
*/
Expand All @@ -241,14 +258,24 @@ namespace widgets
*/
std::unique_ptr<render::Model> mExitsDebugModel { nullptr };

/**
* @brief This list contains objects which could be visible in this specific room
*/
std::vector<SeebleObject> vObjects {};

/**
* @brief Room bounding box debug model
*/
std::unique_ptr<render::Model> mBBoxModel { nullptr };

/**
* @brief Means "is this room created because no other rooms exists"
*/
bool bIsVirtualBigRoom { false };
};

std::list<RoomDef> m_rooms {};
const RoomDef* m_pLastRoom { nullptr };
std::list<const RoomDef*> m_cameraInRooms {};

private:
void computeRoomBoundingBox(RoomDef& d);
Expand Down
1 change: 1 addition & 0 deletions BMEdit/Editor/Resources/Shaders/TexturedEntity_GL33.fsh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ struct Material
vec4 gm_vZBiasOffset;
vec4 v4Opacity;
vec4 v4Bias;
float fZOffset;
int alphaREF;

// Textures
Expand Down
29 changes: 28 additions & 1 deletion BMEdit/Editor/Resources/Shaders/TexturedEntity_GL33.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,29 @@ struct Transform
mat4 model;
};

struct Material
{
// See Common.fx for details
// Common uniforms
vec4 v4DiffuseColor;
vec4 gm_vZBiasOffset;
vec4 v4Opacity;
vec4 v4Bias;
float fZOffset;
int alphaREF;

// Textures
sampler2D mapDiffuse;
sampler2D mapSpecularMask;
sampler2D mapEnvironment;
sampler2D mapReflectionMask;
sampler2D mapReflectionFallOff;
sampler2D mapIllumination;
sampler2D mapTranslucency;
};

uniform Material i_uMaterial;

// Uniforms
uniform Camera i_uCamera;
uniform Transform i_uTransform;
Expand All @@ -30,6 +53,10 @@ out vec2 g_TexCoord;

void main()
{
gl_Position = i_uCamera.proj * i_uCamera.view * i_uTransform.model * vec4(aPos.x, aPos.y, aPos.z, 1.0);
vec4 vOut = i_uCamera.proj * i_uCamera.view * i_uTransform.model * vec4(aPos.x, aPos.y, aPos.z, 1.0);
vOut -= i_uMaterial.gm_vZBiasOffset;
vOut.z -= i_uMaterial.fZOffset;

gl_Position = vOut;
g_TexCoord = aUV;
}
Loading

0 comments on commit 9a8efa6

Please sign in to comment.