Working on optimization: GPU skinning and binary animations
This commit is contained in:
1 parent
a589765b7e
commit
f708843747
24 files changed
+890
-489525
No files matched your search
@@ -23,6 +23,7 @@ enum class AnimationState {
|
||||
class Character {
|
||||
public:
|
||||
void loadAnimation(AnimationState state, const std::string& filename, const std::string& zipFile = "");
|
||||
void loadBinaryAnimation(AnimationState state, const std::string& filename, const std::string& zipFile = "");
|
||||
// void setTexture(std::shared_ptr<Texture> texture);
|
||||
void setTexture(std::shared_ptr<Texture> texture) {
|
||||
this->texture = texture;
|
||||
@@ -59,6 +60,7 @@ public:
|
||||
bool canAttack = false;
|
||||
Character* attackTarget = nullptr;
|
||||
bool isPlayer = false;
|
||||
bool useGpuSkinning = true;
|
||||
|
||||
private:
|
||||
struct AnimationData {
|
||||
@@ -67,6 +69,15 @@ private:
|
||||
float currentFrame = 0.f;
|
||||
int lastFrame = -1;
|
||||
int totalFrames = 1;
|
||||
|
||||
// GPU skinning data (lazily initialized)
|
||||
VertexRenderStruct bindPoseMutable;
|
||||
std::shared_ptr<VBOHolder> boneIndices0VBO;
|
||||
std::shared_ptr<VBOHolder> boneIndices1VBO;
|
||||
std::shared_ptr<VBOHolder> boneWeights0VBO;
|
||||
std::shared_ptr<VBOHolder> boneWeights1VBO;
|
||||
bool gpuSkinningPrepared = false;
|
||||
std::vector<Eigen::Matrix4f> skinningMatrices;
|
||||
};
|
||||
|
||||
std::map<AnimationState, AnimationData> animations;
|
||||
@@ -81,6 +92,11 @@ private:
|
||||
// Returns the animation state to actually play/draw, falling back to IDLE
|
||||
// if the requested state has no loaded animation.
|
||||
AnimationState resolveActiveState() const;
|
||||
|
||||
// GPU skinning: prepare per-animation VBOs (called lazily on first draw)
|
||||
void prepareGpuSkinningVBOs(AnimationData& anim);
|
||||
// GPU skinning: draw using shader-based skinning
|
||||
void drawGpuSkinning(Renderer& renderer);
|
||||
};
|
||||
|
||||
} // namespace ZL
|
||||
Reference in new issue
Block a user