Fix bug in names where same string could get interned twice, some easy optimizations
This commit is contained in:
parent
5d9d321695
commit
56f1eb1d15
@ -68,13 +68,18 @@ from_string :: proc(str: string) -> Name {
|
||||
existing: Name
|
||||
ok: bool
|
||||
{
|
||||
sync.atomic_rw_mutex_shared_guard(&global_container.lock)
|
||||
sync.guard(&global_container.lock)
|
||||
existing, ok = global_container.names_lookup[str]
|
||||
}
|
||||
if ok {
|
||||
return existing
|
||||
} else {
|
||||
sync.atomic_rw_mutex_guard(&global_container.lock)
|
||||
sync.guard(&global_container.lock)
|
||||
|
||||
existing, ok = global_container.names_lookup[str]
|
||||
if ok {
|
||||
return existing
|
||||
}
|
||||
|
||||
new_str := strings.clone_to_cstring(
|
||||
str,
|
||||
@ -93,7 +98,7 @@ from_cstring :: proc(str: cstring) -> Name {
|
||||
|
||||
to_string :: proc(name: Name) -> string {
|
||||
tracy.Zone()
|
||||
sync.atomic_rw_mutex_shared_guard(&global_container.lock)
|
||||
sync.guard(&global_container.lock)
|
||||
return global_container.names_array[name]
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ import "core:log"
|
||||
import "core:sync/chan"
|
||||
import "core:thread"
|
||||
import "libs:physfs"
|
||||
import "libs:tracy"
|
||||
|
||||
ASSET_WATCHER_OPS_BUFFER :: 256
|
||||
|
||||
@ -78,6 +79,8 @@ modtime_watcher_next :: proc(watcher: ^Asset_Modtime_Watcher) -> (asset: Watcher
|
||||
|
||||
@(private = "file")
|
||||
modtime_watcher_thread_proc :: proc(t: ^thread.Thread) {
|
||||
tracy.SetThreadName("Asset Watcher")
|
||||
|
||||
watcher := cast(^Asset_Modtime_Watcher)t.data
|
||||
|
||||
log.debugf("watcher thread")
|
||||
|
@ -116,7 +116,6 @@ World :: struct {
|
||||
track: Track,
|
||||
physics_scene: physics.Scene,
|
||||
pause: bool,
|
||||
car_com: rl.Vector3,
|
||||
car_handle: physics.Body_Handle,
|
||||
engine_handle: physics.Engine_Handle,
|
||||
debug_state: Debug_Draw_State,
|
||||
@ -134,7 +133,6 @@ copy_world :: proc(dst, src: ^World) {
|
||||
scene_copy(&dst.main_scene, &src.main_scene)
|
||||
dst.player_pos = src.player_pos
|
||||
dst.pause = src.pause
|
||||
dst.car_com = src.car_com
|
||||
dst.car_handle = src.car_handle
|
||||
dst.engine_handle = src.engine_handle
|
||||
dst.debug_state = src.debug_state
|
||||
@ -436,10 +434,6 @@ World_Update_Config :: struct {
|
||||
update_world :: proc(world: ^World, dt: f32, config: World_Update_Config) {
|
||||
|
||||
if !world.pause {
|
||||
car_model := assets.get_model(&g_mem.assetman, "assets/ice_cream_truck.glb")
|
||||
car_bounds := rl.GetModelBoundingBox(car_model)
|
||||
world.car_com = (car_bounds.min + car_bounds.max) / 2
|
||||
|
||||
if true {
|
||||
physics.immediate_body(
|
||||
&world.physics_scene,
|
||||
|
@ -279,7 +279,6 @@ copy_mesh :: proc(
|
||||
|
||||
|
||||
transform_mesh :: proc(mesh: ^Half_Edge_Mesh, mat: lg.Matrix4f32) {
|
||||
tracy.Zone()
|
||||
mesh_center_avg_factor := 1.0 / f32(len(mesh.vertices))
|
||||
new_center: Vec3
|
||||
for i in 0 ..< len(mesh.vertices) {
|
||||
|
@ -568,6 +568,7 @@ find_new_contacts :: proc(
|
||||
|
||||
num_contacts_found := 0
|
||||
for leaf_node in bvh.iterator_intersect_leaf_next(&it) {
|
||||
tracy.ZoneN("intersect_bvh_node")
|
||||
for j in 0 ..< leaf_node.prim_len {
|
||||
level_geom_handle := index_to_level_geom(
|
||||
int(
|
||||
@ -581,29 +582,33 @@ find_new_contacts :: proc(
|
||||
sim_cache,
|
||||
level_geom_handle,
|
||||
)
|
||||
|
||||
body_aabb_in_Level_geom_space := aabb_inv_transform(
|
||||
body_aabb,
|
||||
level_geom.x,
|
||||
level_geom.q,
|
||||
)
|
||||
blas_it := bvh.iterator_intersect_leaf_aabb(
|
||||
&blas,
|
||||
aabb_inv_transform(body_aabb, level_geom.x, level_geom.q),
|
||||
body_aabb_in_Level_geom_space,
|
||||
)
|
||||
for blas_leaf_node in bvh.iterator_intersect_leaf_next(&blas_it) {
|
||||
for k in 0 ..< blas_leaf_node.prim_len {
|
||||
tri_idx := int(
|
||||
blas.primitives[blas_leaf_node.child_or_prim_start + k],
|
||||
)
|
||||
tri := get_transformed_triangle(
|
||||
vertices,
|
||||
indices,
|
||||
tri_idx,
|
||||
level_geom.x,
|
||||
level_geom.q,
|
||||
)
|
||||
tri := get_triangle(vertices, indices, tri_idx)
|
||||
prim_aabb := get_triangle_aabb(tri)
|
||||
|
||||
if bvh.test_aabb_vs_aabb(body_aabb, prim_aabb) {
|
||||
if bvh.test_aabb_vs_aabb(
|
||||
body_aabb_in_Level_geom_space,
|
||||
prim_aabb,
|
||||
) {
|
||||
tracy.ZoneN("body_vs_level_geom")
|
||||
|
||||
shapes_it := shapes_iterator(sim_state, body.shape)
|
||||
for shape in shapes_iterator_next(&shapes_it) {
|
||||
tracy.ZoneN("body_shape_vs_level_geom")
|
||||
|
||||
shape_idx := shapes_it.counter - 1
|
||||
shape_aabb := shape_get_aabb(shape^)
|
||||
shape_aabb = body_transform_shape_aabb(
|
||||
@ -614,6 +619,11 @@ find_new_contacts :: proc(
|
||||
min = shape_aabb.center - shape_aabb.extent,
|
||||
max = shape_aabb.center + shape_aabb.extent,
|
||||
}
|
||||
bvh_shape_aabb = aabb_inv_transform(
|
||||
bvh_shape_aabb,
|
||||
level_geom.x,
|
||||
level_geom.q,
|
||||
)
|
||||
|
||||
pair := make_contact_pair_body_level(
|
||||
index_to_body_handle(int(body_idx)),
|
||||
|
Loading…
x
Reference in New Issue
Block a user