Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
compile_commands.json
.cache
.idea
.kotlin
.vscode
external
29 changes: 29 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,32 @@ common --tool_java_language_version=21
common --java_language_version=21

build --worker_max_multiplex_instances=KotlinKsp=1
common --build_tag_filters=-only_build_when_release

# Release builds
build:opt --copt -flto --copt -Os
build:opt --linkopt -flto
build:opt --strip=always
build:opt --compilation_mode=opt
build:opt --build_tag_filters=

# Debug
build:dbg --strip=never
build:dbg --compilation_mode=dbg

# Zig CC
build:linux --sandbox_add_mount_pair=/tmp
build:macos --sandbox_add_mount_pair=/var/tmp

# Android Rules
common --android_platforms=@//:android_arm32,@//:android_arm64,@//:android_x86,@//:android_x86_64

# C++17
common:linux --cxxopt=-std=c++17
common:linux --host_cxxopt=-std=c++17
common:macos --cxxopt=-std=c++17
common:macos --host_cxxopt=-std=c++17
common:windows --cxxopt=/std:c++17
common:windows --host_cxxopt=/std:c++17

common --enable_platform_specific_config
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.3.1
8.4.2
7 changes: 7 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
BasedOnStyle: Google
BreakBeforeBraces: Attach
IndentWidth: 4
ContinuationIndentWidth: 4
TabWidth: 4
UseTab: Never
ColumnLimit: 120
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
repository-cache: true
- name: build
run: |
bazel build \
bazel build --config opt \
--verbose_failures \
//mod:mod_fabric \
//mod:mod_neoforge \
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ local.properties
*.iml
*.ipr
*.iws
.clwb
.ijwb

# vscode

Expand Down Expand Up @@ -44,6 +46,11 @@ replay_*.log

.kotlin

# clangd
compile_commands.json
.cache

# bazel
.bazelbsp
bazel-*
external
7 changes: 7 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ load("//:properties.bzl", "mod_version")
load("@rules_java//java:defs.bzl", "java_plugin")
load("@rules_java//java:defs.bzl", "java_library")

config_setting(
name = "config_release",
values = {
"compilation_mode": "opt",
},
)

kt_compiler_plugin(
name = "serialization_plugin",
compile_phase = True,
Expand Down
36 changes: 33 additions & 3 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,35 @@ module(
version = "0.0.8",
)

bazel_dep(name = "rules_java", version = "8.12.0")
bazel_dep(name = "rules_java", version = "8.16.1")
bazel_dep(name = "rules_kotlin", version = "2.1.9")
bazel_dep(name = "rules_jvm_external", version = "6.7")
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "rules_jvm_external", version = "6.8")
bazel_dep(name = "bazel_skylib", version = "1.8.2")
bazel_dep(name = "bazel_lib", version = "3.0.0-rc.0")
bazel_dep(name = "rules_cc", version = "0.2.9")
bazel_dep(name = "platforms", version = "1.0.0")
bazel_dep(name = "rules_android_ndk", version = "0.1.3")
bazel_dep(name = "rules_jni", version = "0.11.0")
bazel_dep(name = "bullet", version = "3.26.0-rc0")
bazel_dep(name = "hermetic_cc_toolchain", version = "4.0.1")
bazel_dep(name = "hedron_compile_commands", dev_dependency = True)
git_override(
module_name = "hedron_compile_commands",
remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git",
commit = "abb61a688167623088f8768cc9264798df6a9d10",
)

androidndk = use_extension("@rules_android_ndk//:extension.bzl", "android_ndk_repository_extension")
use_repo(androidndk, "androidndk")
register_toolchains("@androidndk//:all")

zig_cc = use_extension("@hermetic_cc_toolchain//toolchain:ext.bzl", "toolchains")
use_repo(zig_cc, "zig_sdk")

register_toolchains(
"@zig_sdk//toolchain/...",
"@zig_sdk//libc_aware/toolchain/...",
)

maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
maven.install(
Expand Down Expand Up @@ -96,6 +121,10 @@ maven.install(
lock_file = "//:maven_install.json",
fetch_sources = True,
)
maven.amend_artifact(
coordinates = "net.fabricmc.fabric-api:fabric-api",
exclusions = ["net.fabricmc.fabric-api:fabric-api-deprecated"],
)
use_repo(maven, "maven")

http_jar = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_jar")
Expand Down Expand Up @@ -135,6 +164,7 @@ http_archive(
"@//third_party/mocha/patches:mutable_entity.patch",
],
)

# Download YSM for its bundled model
http_archive(
name = "yes_steve_model",
Expand Down
2,873 changes: 361 additions & 2,512 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions blazerod/example/ball_block/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ load("//rule:apply_access_widener.bzl", "apply_access_widener")
load("//rule/fabric:merge_jij.bzl", "fabric_merge_jij")
load("//rule:remap_jar.bzl", "remap_jar")
load("//rule:generate_remap_classpath.bzl", "generate_remap_classpath")
load("//rule:decompile_jar.bzl", "decompile_jar")
load("//:properties.bzl", "game_version")

remap_jar(
Expand Down Expand Up @@ -32,11 +31,6 @@ apply_access_widener(
srcs = [":access_widener_dep_named"],
)

decompile_jar(
name = "decompile_client_access_widened_named",
inputs = [":remapped_client_access_widened_named"],
)

java_library(
name = "ball_block_unmapped",
srcs = glob(["src/main/java/**/*.java"]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private void loadModel() {
matrix.getScale().mul(0.5f);
matrix.getTranslation().add(0.5f, 0.5f, 0.5f);
});
BALL_INSTANCE.updateRenderData();
BALL_INSTANCE.updateRenderData(0f);
}).exceptionally(throwable -> {
MinecraftClient.getInstance().execute(() -> {
throw new RuntimeException("Failed to load model: ", throwable);
Expand Down
1 change: 1 addition & 0 deletions blazerod/model/model-assimp/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ modrinth_dependency(

upload_modrinth(
name = "upload_modrinth",
tags = ["only_build_when_release"],
token_secret_id = "modrinth_token",
project_id = "xeMk2Ovz",
version_name = blazerod_version,
Expand Down
1 change: 1 addition & 0 deletions blazerod/model/model-base/Model.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ data class Model(
val scenes: List<Scene>,
val defaultScene: Scene? = null,
val skins: List<Skin>,
val physicalJoints: List<PhysicalJoint> = listOf(),
val expressions: List<Expression> = listOf(),
) {
init {
Expand Down
14 changes: 13 additions & 1 deletion blazerod/model/model-base/NodeComponent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ sealed class NodeComponent {
INFLUENCE_SOURCE(
requireMesh = false,
singleInstanceOnly = false,
),
RIGID_BODY(
requireMesh = false,
singleInstanceOnly = false,
);

companion object {
Expand Down Expand Up @@ -67,4 +71,12 @@ sealed class NodeComponent {
override val type: Type
get() = Type.INFLUENCE_SOURCE
}
}

data class RigidBodyComponent(
val rigidBodyId: RigidBodyId,
val rigidBody: RigidBody,
) : NodeComponent() {
override val type: Type
get() = Type.RIGID_BODY
}
}
22 changes: 22 additions & 0 deletions blazerod/model/model-base/PhysicsJoint.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package top.fifthlight.blazerod.model

import org.joml.Vector3fc

data class PhysicalJoint(
val name: String? = null,
val type: JointType,
val rigidBodyA: RigidBodyId,
val rigidBodyB: RigidBodyId,
val position: Vector3fc,
val rotation: Vector3fc,
val positionMin: Vector3fc,
val positionMax: Vector3fc,
val rotationMin: Vector3fc,
val rotationMax: Vector3fc,
val positionSpring: Vector3fc,
val rotationSpring: Vector3fc,
) {
enum class JointType {
SPRING_6DOF,
}
}
37 changes: 37 additions & 0 deletions blazerod/model/model-base/RigidBody.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package top.fifthlight.blazerod.model

import org.joml.Vector3fc
import java.util.*

data class RigidBody(
val name: String? = null,
val collisionGroup: Int,
val collisionMask: Int,
val shape: ShapeType,
val shapeSize: Vector3fc,
val shapePosition: Vector3fc,
val shapeRotation: Vector3fc,
val mass: Float,
val moveAttenuation: Float,
val rotationDamping: Float,
val repulsion: Float,
val frictionForce: Float,
val physicsMode: PhysicsMode,
) {
enum class ShapeType {
SPHERE,
BOX,
CAPSULE,
}

enum class PhysicsMode {
FOLLOW_BONE,
PHYSICS,
PHYSICS_PLUS_BONE,
}
}

data class RigidBodyId(
val modelId: UUID,
val index: Int,
)
Loading
Loading